React-native-push-notification: onNotification is fired off in the background, not when notification is clicked.

Created on 30 May 2018  路  13Comments  路  Source: zo0r/react-native-push-notification

I have seen many people struggling with the same thing along with others not struggling at all. Is this an issue with the package or just the way each person implements it? My onNotification is being called when I receive a notification in the background rather than when it is clicked.

The package specifies that " // (required) Called when a remote or local notification is opened or received" for onNotification. Does this mean that there is an option to fire off onNotification when it is received OR when it is clicked? I am very confused by this.

If anyone has some input on this, I'd appreciate it!

Stale question

Most helpful comment

I receive only one notification, when app is opened, when app is closed, and I'm clicking on the notification, onNotification method is not triggered at all.

All 13 comments

struggle in this problem +1, onNotification only called after user click the notification

same problem here, facing this problem on ios device.

I used iOS 10.10 unnotificationcenter to achieve this, but this package do not support yet

the same error, but on Android, any ideas how to fix that?

Can you log the parameter sent to onNotification ?
Normally, you should receive two notifications: One for background and one because of the click on the icon.

@Gp2mv3 here is notification in onNotification
collapse_key :"com.xxx"
foreground:true
google.message_id:"xxx"
google.sent_time:1530884451638
google.ttl:2419200
id:"-1209190223"
notification:{body: "You鈥檝e got $1 on the way", icon: "ic_launcher", title: "Approved"}
show:"CONFIRMATION"
userInteraction:false

I receive only one notification, when app is opened, when app is closed, and I'm clicking on the notification, onNotification method is not triggered at all.

@Luckygirlllll Did you any solution?

@muhzi4u I didn't find any solution, this bug is not resolved yet, I decided to use another library for PN.

@Luckygirlllll #547 Resolved the issue

@muhzi4u How did you exactly resolve the issue? You just copied and pasted RNPushNotification class as it was shown in issue 547?

@Luckygirlllll Yes

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.

Was this page helpful?
0 / 5 - 0 ratings