onNotification is not called when remote notification arrives and app is in background/foreground
See original GitHub issueI’m to update the UI when onNotification
arrives. In general onNotification
works as expected when app is killed. It wakes up -> onNotification
gets called.
BUT onNotification
doesn’t seem to be getting called when the app is NOT killed, i.e. in foreground or background.
I saw people reporting similar issues for local notifs, but I assume for remote notifications it’s different?
Can someone suggest what could be wrong?
import React from 'react'
import { Platform } from 'react-native'
import PushNotification from 'react-native-push-notification'
import PushNotificationIOS from '@react-native-community/push-notification-ios'
const Root = () => {
PushNotification.configure({
onRegister: pushToken => {
console.log(pushToken.token)
},
onNotification: notification => {
console.log('Notification received', notification)
notification.finish(PushNotificationIOS.FetchResult.NoData)
},
onError: err => {
console.log('Error configuring notifications', err)
},
senderID: SENDER_ID,
permissions: {
alert: true,
badge: true,
sound: true,
},
popInitialNotification: true,
requestPermissions: Platform.OS === 'android',
})
return <Router />
}
The library version:
"react-native-push-notification": "^3.5.0",
Issue Analytics
- State:
- Created 3 years ago
- Reactions:20
- Comments:22
Top Results From Across the Web
Android onNotification never called in react-native-push ...
notification received form the server when i clicked on it app is opened but onNotification never called. i put this in componentDidMount() ...
Read more >navigating user on notification click app in background ...
Coding example for the question navigating user on notification click app in background/foreground-React Native.
Read more >didReceiveRemoteNotification not c… - Apple Developer
From the docs it states that this method is called even when the app is in background: Use this method to process incoming...
Read more >Handling incoming iOS notifications - Pusher Beams Docs
When a notification arrives whilst your app is running (foreground or ... method will not be called until the user brings the app...
Read more >How to perform action when user tap on push notification ...
To handle push notification in App Delegate, we will set the ... When the app launch after user tap on notification (originally was...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This solved it for me:
SplashActivity
MainActivity
AndroidManifest
@Dallas62 you were right. On the push-notification-ios#107 issue you eluded to the fix pointed out here enabled me to begin receiving onNotification events while the app was in the background or foreground. Thanks for your pointers!