Android: run code when app is killed
See original GitHub issueI’m trying to run some code when I receive a notification with my app killed. I haven’t got any success on my Android app (I’m not targeting IOS yet).
I’ve setup a fetch
call to a log server directly on my index.android.js
file, just to log if the app is being launched. I’ve also puts logs on FCM.getInitialNotification
promise and FCMEvent.Notification
event. Neither of these logs get called when I send notifications with the app closed (I close it by swiping it away from “Recent Screens”).
To send the notifications, I’m using fcm-node
package, with the following configuration:
const message = {
to: registrationToken,
data: {
my_data: "test",
},
};
Sending push notifications with the property notification
(and its title
and body
) set will show in the device, with the app in background or killed.
The package versions I’m using are listed below.
{
"react": "16.0.0-alpha.6",
"react-native": "0.44.0",
"react-native-fcm": "^7.0.0",
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:33 (9 by maintainers)
Top GitHub Comments
@JulioC released in v7.5.0. Now android can trigger JS code when app is killed. Haven’t find iOS implementation. Let me know if it exists You can close the issue if it works for you.
@JulioC great finding. I will see if I can do similar things. But still it may be only available for android