How to implement Callkeep with Agora in Flutter?
Asked Answered
I

2

6

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

Immigrate answered 29/1, 2021 at 11:37 Comment(0)
C
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.

Cambogia answered 20/2, 2021 at 15:15 Comment(1)
You can use firebase push notifications to handle this in flutterTutuila
G
1

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

Gewirtz answered 30/6, 2023 at 21:56 Comment(1)
any affiliation? /help/promotionEnervated

© 2022 - 2024 — McMap. All rights reserved.