I have a flutter app that contains WebRTC video calls. Is there a way in Flutter to get the application to show itself or to maximize itself when it receives a call?
So finally I was able to solve it, generally there are 2 scenarios, if the app in the background and if it’s Terminated.
When the app goes to background iOS kills it right away after couple of seconds, so flutter is disconnected and we have to use push notifications.
In iOS you just can't bring an app to foreground that’s just against Apple policies and there is no public api for that. See here .
The only exception for that are calls, which were was my case. I had to use apple VoIP notifications, There are two separate flutter packages to deal with that flutter_voip_push_notification and flutter_call_kit
In case of a Terminated app I had to fork the fire_flutter code in order to add my code. see here Which shows the main activity by calling the same launch intent of the app when a call-related notification arrives
In case if the app was in the background flutter will be connected to the signaling service so I don't use FCM. I send a FCM message to flutter to receive the call. And on the flutter side I wrote a packge just to bring the app to foreground when called from flutter see it here
it's really simple . you call a static function from dart and it'll be brought to foreground
When responding to voip notifications you should display the callkit the instant you get the notification see here. Fail to use the call kit 3 times for whatever reason (even exceptions, or stopping the debugger for a few seconds) and iOS on the client device will start to ignore your voip notifications And that should be REALLY INSTANTLY. Apple support says somewhere (I don’t remember where): if you want to get some data from your server Just show a dummy call kit, Then when the response arrives you can update it with the caller information . When the system bans the app fro,m receiving Voip notifications, I had to do a factory reset on my iPhone 6 to unban my app ( if you find another way please share!) If you're banned you can use the console on your Mac to make sure
I couldn't use firebase for voip notifications because it needs client certificate. I had to use the same WebRtc signaling NodeJS server
Answering on iPhone will open your flutter app So you have to handle the call as soon as you can Or the user will see your home screen instead of the voice of the caller
Some android vendors like Xaiomi will prevent your app's services from bringing activities to the foreground, so you have to tell the user: go to settings, enable some setting, which differs by vendor
Android 10 (Q) have some restrictions too on running an activity from background service.
Launching the same launch intent in android from background will restart the activity instead of just bringing it, I had to play a little bit with the launchMode
in AndroidManifest.xml
in order to make it work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With