hiennguyen92 / flutter_callkit_incoming

Flutter Callkit Incoming
https://pub.dev/packages/flutter_callkit_incoming
MIT License
180 stars 312 forks source link

FlutterCallkitIncoming Event listening not working when app is terminated #596

Open owl-madness opened 1 month ago

owl-madness commented 1 month ago

I implemented the FlutterCallkitIncoming in my project. The call screen using FlutterCallkitIncoming will show when the notification is received from the firebase. Until this everything works fine, the problem is arise when accepting the call on terminated state. It's working fine when the app is in foreground. The only problem is with the listener of the FlutterCallkitIncoming.


@override
  void initState() {
    initializeCallKitEventHandlers(context);
    super.initState();
  }

@pragma('vm:entry-point')
void initializeCallKitEventHandlers(BuildContext context) {
FlutterCallkitIncoming.onEvent.listen((CallEvent event) {
    switch (event!.event) {
      case Event.actionCallIncoming:
        // TODO: received an incoming call
        break;
      case Event.actionCallAccept:
        // TODO: accepted an incoming call
        // TODO: show screen calling in Flutter
        break;
      case Event.actionCallDecline:
        // TODO: declined an incoming call
        break;
        ............
        ............
    }
  });
}

Could't find a solution in web or package documentation. Please solve this or give me a proper solution!!!

owl-madness commented 1 month ago

@hiennguyen92 @ryojiro @AAkira

Please help!!

chantharamanee-prat commented 1 month ago

When a user accepts a call from a terminated state, you can use FlutterCallkitIncoming.activeCalls() when the app initializes. This function will return a list of CallEvent objects, which you can then map to your function that handles Event.actionCallAccept

khactri03 commented 1 month ago

how about delince(Event.actionCallDecline) when app is terminated