Skip to content

How to know if the app was lunched with the accpet click in notification #75

@hatemragab

Description

@hatemragab

Hello thanks for your great effort
i have question i have tried alot before i open this
How to know if the app was lunched with the accpet click in notification
And if user decline the call in the app was terminated i speak about the android version only
i lunch this from the background handler for the firebase

@pragma('vm:entry-point')
Future<void> vFirebaseMessagingBackgroundHandler(RemoteMessage message) async {}

The call appears good but when i click to accept or reject i need to perform some action in background
espically for the decline i need to call the api to stop the call and mark it as rejected
Here what iam doing
in the vFirebaseMessagingBackgroundHandler function
init first

  Future<void> initCallKeep() async {
    final config = CallKeepConfig(
      appName: 'CallKeep',
      // Other plugin configurations
      android: CallKeepAndroidConfig(

          // Android configuration
          ),
      ios: CallKeepIosConfig(
          // iOS configuration
          ),
      // Headers if needed
      headers: <String, dynamic>{'apiKey': 'Abc@123!', 'platform': 'flutter'},
    );
    CallKeep.instance.configure(config);
    setEventHandler();
  }

and then

  Future<void> setEventHandler() async {
  CallKeep.instance.handler = callkeep.CallEventHandler(
    onCallStarted: (event) {
      print('call started: ${event.toMap()}');
    },
    onCallEnded: (event) {
      print('call ended: ${event.toMap()}');
    },
    onCallAccepted: (event) async {
      //try to set some string in key to print it in next app lunch 
      await VAppPref.setStringKey(
        "onCallAcceptedxx",
        "jsonEncode(event.toMap())",
      );
      await Future.delayed(Duration(seconds: 4));
      VChatController.I.navigatorKey.currentContext!.toPage(Scaffold());
    },
    onCallDeclined: (event) async {
      print('call declined: ${event.toMap()}');
    },
  );
}
  • try to set some string in key to print it in next app lunch
  • put it prints null
    show call by this
 final data = callkeep.CallEvent(
    uuid: "s",
    callerName: 'Test User',
    handle: '0123456789',
    hasVideo: false,
    duration: 30000,
    extra: <String, dynamic>{'userId': '1a2b3c4d'},
  );

  await CallKeep.instance.displayIncomingCall(data);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions