Navigator Key is not Initialised When Waking the App From Call Kit

34 Views Asked by At

I have integrated VoIP calls into my Flutter app using sip_ua package and I have integrated flutter_callkit_incoming.

Flow

Listening to Call State Changes from SIPHelper

  • On receiving the notification in the terminated state, the SIPController is initialized and the user is registered on the SIP server.

  • On accepting the incoming call, the Call Screen is pushed.

Listening to FlutterCallKitIncoming Events

  • When the User accepts the incoming call from notification in the terminated state, it triggers the Call Accept event, and that tries to push the Call Screen if the navigatorKey is not null.

Handling Background Messages

@pragma('vm:entry-point')
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
  WidgetsFlutterBinding.ensureInitialized();

  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );
  NotificationService firebaseService = NotificationService();

  await firebaseService.configureFirebaseMessaging();

  crashlyticsSetup();

  await initUserAuthentication();
  // Initialising the SIP Controller
  await initSIP();
}

The Problem

When the FlutterCallKitIncoming triggers the call accept event, the flutter's widget tree has not been rendered yet and the navigatorKey is null.

My Query

I'm wondering if a change in flow in handling the SIPController initialization or the Screen push can help me get around this issue.

0

There are 0 best solutions below