Notification on android device not showing in any state(background/foreground/killed), although onNotification is called
See original GitHub issueBug
Environment info
react-native info
output:
react-native:0.62.2
firebase-messaging: 20.2.1
and SNS
Library version: 3.1.9> &&<=4.0.0
Steps To Reproduce
- Integrate Push Notification in your app
- Trigger a Push notification from FCM console, it worked
- Trigger a Push notification from SNS console with default payload (in GCM format)
- onNotification will be called, notification will be received in callback but notification won’t be shown on your device
Reproducible sample code
export default class PushNotificationController extends Component { constructor(props) { super(props); PushNotification.configure({ // (optional) Called when Token is generated (iOS and Android) onRegister: function(token) { storeObjInPersistentStore(‘notificationToken’, token).then(); },
// (required) Called when a remote or local notification is opened or received
onNotification: notification => {
if (Platform.OS === 'ios' && notification.foreground) {
showNotificationAlert(
notification.alert,
notification,
handleNotificationTap,
);
} else if (!notification.foreground) {
handleNotificationTap(notification);
}
},
// ANDROID ONLY: GCM or FCM Sender ID (product_number) (optional - not required for local notifications, but is need to receive remote push notifications)
senderID:MY_FCM_SENDER_ID,
// IOS ONLY (optional): default: all - Permissions to register.
permissions: {
alert: true,
badge: true,
sound: true,
},
// Should the initial notification be popped automatically
// default: true
popInitialNotification: true,
/**
* (optional) default: true
* - Specified if permissions (ios) and token (android and ios) will requested or not,
* - if not, you must call PushNotificationsHandler.requestPermissions() later
*/
requestPermissions: true,
});
}
render() { return null; } }
I remember I tried the same using 3.5.2 version on 7th July and it was working using same codebase. But stop working after that. I scratched my head for 4-5 days and at last what I got is that the issue is with version, it started working fine in version 3.1.9 without any further change. I also checked with some other versions but none of them worked in my case.
But I’m not convinced with the solution yet that I got. I request the community to please look at this issue and provide a clear picture of that. Note: I have already tried it with the latest version 4.0.0 but this also didn’t work for me.
Issue Analytics
- State:
- Created 3 years ago
- Comments:22
Top GitHub Comments
Use this payload as a custom payload in AWS SSN publishing : { “GCM”:“{ “notification”: { “body”: “Sample message for Android endpoints”, “title”:“TitleTest” } }” }
@Dallas62 Yeah actually this seems to be an issue of Firebase messaging and this lib. Messageid’s from firebase come in completely different format than PushNotification lib gets