Open shofizone opened 3 years ago
you can use it like this:
Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) {
print('backgroundMessage: message => ${message.toString()}');
Map<dynamic, dynamic> payload = message['data'] as Map<dynamic, dynamic>;
String callerId = payload['caller_id'] as String;
String callerName = payload['caller_name'] as String;
bool appIsOpened = await _callKeep.backToForeground();
if (appIsOpened) {
print('APP is opened, use callkeep display incoming call now.');
await displayIncomingCall(callerId, callerName);
} else {
print('APP is closed, wake it up and use callkeep to display incoming calls.');
}
}
First, you need to wake up the app, and then operate everything in the foreground. Whether you want to reject or accept, you should operate in the app after startup.
Still not working ! Now it's not event displaying the call. await _callKeep.backToForeground(); This method not working, When app is killed ! I don't know what did wrong !
class Application : FlutterApplication(), PluginRegistrantCallback {
override fun onCreate() {
super.onCreate()
FlutterFirebaseMessagingService.setPluginRegistrant(this);
FlutterMain.startInitialization(this)
}
override fun registerWith(registry: PluginRegistry?) {
if (!registry!!.hasPlugin("io.flutter.plugins.firebasemessaging")) {
FirebaseMessagingPlugin.registerWith(registry!!.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
}
if (!registry!!.hasPlugin("com.dexterous.flutterlocalnotifications")) {
FlutterLocalNotificationsPlugin.registerWith(registry!!.registrarFor("com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin"));
}
if (!registry!!.hasPlugin("com.github.cloudwebrtc.flutter_callkeep")) {
FlutterCallkeepPlugin.registerWith(registry!!.registrarFor("com.github.cloudwebrtc.flutter_callkeep.FlutterCallkeepPlugin"));
}
}
}
if (!_callKeepInited) {
await _callKeep.setup(<String, dynamic>{
'ios': {
'appName': '${StringResources.appName}',
},
'android': {
'alertTitle': 'Permissions required',
'alertDescription':
'This application needs to access your phone accounts',
'cancelButton': 'Cancel',
'okButton': 'ok',
},
});
_callKeepInited = true;
}
bool appIsOpened = await _callKeep.backToForeground();
if(appIsOpened){
_callKeep.displayIncomingCall(callUUID, callerNmae,
localizedCallerName: callerNmae, hasVideo: hasVideo);
}else{
print('APP is closed, wake it up and use callkeep to display incoming calls.');
}
how to wake up if app is closed? incaming call screen appear but buttons are no effective. @cloudwebrtc
@cloudwebrtc How to wake up app?
You can use await _callKeep.backToForeground();
@suhailzoft @xyzbilal
You can use
await _callKeep.backToForeground();
@suhailzoft @xyzbilal
this work only on android what if i need to do that in ios ?
I have configured FCM onBackgroundMessage: myBackgroundMessageHandler. When app is closed/killed on new notification it can display incoming call . But when I tried to accept the call , noting happened. on CallKeepPerformAnswerCallAction It should woke up the app and should execute CallKeepPerformAnswerCallAction call back. But it doesn't ! NB: I am working with agora SDK. So After accept the call, I want transfer the control to flutter side.
Another thing .. When I received a call, I create a call log on phone's native dialer, is it possible to hide?