I'm trying to detect a click on a notification.
I use react-native 0.61 and : react-native-notifications 3.1.4
(but get the same results with react-native-push-notification 3.1.9
).
Everything works well but one thing: if I tap a notification or if I open my app from a notification with a notification from Firebase admin (or curl to FCM) I don't get those events fired:
Notifications.events().registerNotificationOpened
and
Notifications.getInitialNotification()
Howewer if I post a simple local notification with Notifications.postLocalNotification
, everything works well.
Here is my standard curl request:
curl -X POST \
https://fcm.googleapis.com/fcm/send \
-H 'Authorization: key=mykey' \
-H 'Content-Type: application/json' \
-H 'Host: fcm.googleapis.com' \
-d '{
"to" : "cgh6P5BESPesyBJwYlaSPi:APA91bEuLwxgZq4JUlo2Su-_l1DqNVoAPzC2eHQy07IQlTuUcZNRuFiLzlbiFuCsHhU74SgYbrIkY7e2v4uQbYCspzRLlDrwrfha40Ozv613xwyYPtR3lJMaTuNcNAhGh8bdrmMY4B3N",
"payload" : {
"body" : "Body of Your Notification in Data",
"title": "Title of Your Notification in Title",
"pushNotification": true,
}
Again, the notification appears but if I click on it, I don't get any event fired. However if I use postLocalNotification
I get those events.
I have been struggling with this for days now, do I have to do something with intents
in my AndroidManifest
? Is there an example project with this working?
After struggling for days, the problem was inside
AndroidManifest
where I had two activities, one for the splash screen and an other one for the notifications.My AndroidManifest is now like this: