5

I have to create call application with help of Agora. When app is in foreground it is okay, but i want to accept calls when app is on background or terminated. I am trieng to use Callkeep plugin for accepting calls of background I found a way via FCM background message,but i dont know how to implement solutiion for IOS,it does not have FCM background message I tried use VOIP notification, but i dont know how to send them to my flutter app I use Firebase as a backend I need solution for both Android and IOS Thanks

2 Answers2

2

For IOS you will have to implement a server side script that will send VOIP Push notifications to the user before the real VOIP call comes in. From what I know, you cannot user Firebase for this.

Please refer to https://developer.apple.com/documentation/pushkit/responding_to_voip_notifications_from_pushkit to know more about the changes about handling VOIP calls in background.

Also, refer to https://developer.apple.com/documentation/pushkit/responding_to_voip_notifications_from_pushkit to know more about sending VOIP Push notifications on server side.

0

this goes to the people of the future. Use this package: CallKit/CallKeep . This package really works and it's kinda easy to set up. I'm using FCM for call notifications, here's a example:

Future<void> _fcmBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
final FirebaseFirestore _firestore = FirebaseFirestore.instance;
print('Acho q isso chegou por aqui: ${message.data}');
//Random random = new Random();
PushNotificationData pushData = 
PushNotificationData.fromJson(message.data);
if (message.data['action'] == "Incoming call") {
final callUUID = Uuid().v4();
final params = callKeepParams(pushData);
await FlutterCallkitIncoming.showCallkitIncoming(params);
var calls = await FlutterCallkitIncoming.activeCalls();
FlutterCallkitIncoming.onEvent.listen((event) {
  print(event);
  onCallKeepEventReceived(event, pushData);
});
return null;

} }

await FlutterCallkitIncoming.showCallkitIncoming(params); will start the callkepp/callkit mode.

FlutterCallkitIncoming will listen to the callback.

Then it's up to you to start the Agora.io functions. I made it so that whenever I change my route to a specific page(the meeting page), all of Agora.io functions get booted up. And whenever I leave the page, Agora.io gets destroyed. Of course, I'm using getX as well so the results may differ. Sorry for the bad English. I hope I've helped you