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
SIPControlleris initialized and the user is registered on the SIP server.On accepting the incoming call, the
Call Screenis pushed.
Listening to FlutterCallKitIncoming Events
- When the User accepts the incoming call from notification in the
terminatedstate, it triggers theCall Acceptevent, and that tries to push theCall Screenif thenavigatorKeyis 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.