Background Call Integration

Android#

Your flutter app should have a firebase cloud messaging integration to receive push notifications for call in background/killed state. Refer this doc to continue firebase cloud messaging integration in chat

Add runtime permissions for push notification#

From Android 13, To receive notification message, we need below permissions:

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

Updating fcm device token#

You need to update the fcm device token to the server, so that server can send push notificationns by using the updated fcm device token. if you want to update the fcm device token, you can utilise the below method.

ArgumentTypeDescription
FCM_TOKENStringfcm device token
flyCallbackFlyResponsecallback to observe the action status
Mirrorfly.updateFcmToken(firebaseToken: value, flyCallBack: (FlyResponse response) {
if(response.isSuccess){
}
});

Handling the received call fcm message#

Upon receiving a Firebase push notification in your Firebase Messaging service, you can utilize the following method to retrieve the notification content and subsequently create and display the notification.

@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
// Handle background messages
// If you're going to use other Firebase services in the background, such as Firestore,
// make sure you call `initializeApp` before using other Firebase services.
await Firebase.initializeApp();
// We are checking the Platform Condition here, because we are handling the call push in iOS via VOIP
if (Platform.isAndroid) {
//Handle the push notification as given below
var notificationData = remoteMessage.data;
Mirrorfly.handleReceivedMessage(notificationData: notificationData, flyCallBack: (_) {});
}
}

iOS#

Please upload your VOIP Certificate to our Console. To know more how to generate and upload VOIP Certificate Click Here.

Enabling VOIP to the Application#

Enable the VOIP in background/killed state, this is necessary to receive calls in iOS.

VOIP

Note : The VOIP registration and token handling will be taken care of inside the Mirrorfly plugin.