Notification doesn't fire App is in foreground android ?
See original GitHub issueHi,
I have integrate remote notification in my react native app. When App is killed and background the notification is coming on notification center and working fine, but when app is in foreground there is nothing happen. No one method is called,
I have do the below code for notification. The issue is only in android, iOS working fine.
Code :
export function setupPushNotification(handleNotification) {
PushNotification.configure({
// (optional) Called when Token is generated (iOS and Android)
// smallIcon: "ic_notification",
onRegister: function (token) {
console.log('TOKEN:', token.token);
AsyncStorage.setItem('deviceToken', token.token);
//setStoredData('deviceToken', token.token)
PushNotification.popInitialNotification((notification) => {
if (notification) {
console.log('** NOTIFICATION:', notification);
handleNotification(notification);
}
});
},
// (required) Called when a remote or local notification is opened or received
onNotification: function (notification) {
console.log('** NOTIFICATION: **', notification);
if (Platform.OS === 'ios') {
if (notification.alert.length !== 0) {
handleNotification(notification)
notification.finish(PushNotificationIOS.FetchResult.NoData);
}
} else {
handleNotification(notification)
}
},
// ANDROID ONLY: GCM Sender ID (optional - not required for local notifications, but is need to receive remote push notifications)
senderID: "303349031154",
// IOS ONLY (optional): default: all - Permissions to register.
permissions: {
alert: true,
badge: true,
sound: true
},
popInitialNotification: false,
requestPermissions: true,
});
return PushNotification
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:7
Top Results From Across the Web
Notification Doesn't work in the foreground - Stack Overflow
1 Answer 1 ... FCM has different behaviours for app status (foreground and background / killed). You should handle this by the payload...
Read more >Event 'push-notification' doesn't fire when app is in foreground
I have a standard implementation of listening to event and show a popup with notification contents. Expected behavior: When app is in ......
Read more >Foreground services - Android Developers
Foreground services perform operations that are noticeable to the user. Foreground services show a status bar notification, so that users are actively aware ......
Read more >Push notification doesn't open specific screen when app is ...
I have a problem where I need to redirect user to specific post when he taps on notification, but that only works when...
Read more >Notifications Not Shown - Mobile Push
Android Settings App > Notifications > Your App you should see "Show notifications" enable and all categories underneath enabled. If you have a...
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
I just resolved this by fixing the AndroidManifest.xml to what’s in the README. I was migrating from GCM to FCM and missed a few lines:
For you it could be any number of things, but I’d make sure to go through both the README and configuring Firebase Cloud Messaging: https://firebase.google.com/docs/cloud-messaging/android/client
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.