Search code examples
androidiosreact-nativemobilereact-native-firebase

Running specific code, while the app is killed or in background state


I am using react-native-firebase for the push notifications and it works fine. I am also using CallKeep for handling VoIP calls. I want to display an incoming call when the app gets a notification while it is killed or in background (ex. like WhatsApp).

Regarding to the documenation if a message is received "the device silently starts your application in a background state. At this point, your background handler" code is triggered. But this does not happen. The handler is trigger only if I tap the notification.

I've also added some code in AppDelegate.mm like mentioned in the description but it not works.

BTW: I am currently on iOS and don't know how the effect is on an Android device.

So how can I achieve this, or it is even possible ?


Solution

  • So I found the solution. The problem was that I used firebase console to send a notification which did not contain "ContentAvailable: true" property. When I send a notification using the C# sdk including "ContentAvailable = true" then the background handler is called, even if the app is in background or killed.