'React Native event trigger when app quit state
I want to trigger alarm in app when fcm push notification received, when app is closed (quit state) but there is no event trigger.
I'm using
- @react-native-firebase/app
- @react-native-firebase/messaging
Is there any way to trigger an event when app is in quit state.
I'm using this package for alarm
- react-native-alarm-notification
All is working fine in foreground and in background.
Solution 1:[1]
Try adding this in the index.js in the root directory:
const backgroundHandler= async (message)=>{
If(message){
console.log(this is the firebase quit state message,
message)}
return
}
appregistry.registerheadlesstask(
'ReactNativeFirebaseMessagingHeadlessTask',
(message)=>backgroundHandler )
This happens when there is no notification object in the object that is recieved from fcm. This is a way to fix this issue if this was you problem
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Bestine |