Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 28480

double push notification created with React Native + Expo + FCM

$
0
0

I'm trying to create an app that can receive push notification. The push notifications are sent using AWS SNS and using FCM token rather than Expo's Token. The notifications were received, however, every notification was received twice by the system tray. I tried using a phone without expo installed, but it still received 2 notifications.

this is my payload request when sending to SNS

{
"GCM": "{ \"notification\": { \"text\": \"test message\" } }"
}

Any idea why this is happening? I'm willing to provide the code, however I have no idea which part should I put. Here's one example. The app name is the same, but the first notification has expo's logo in it. update: after sending through firebase console I realized that the notification with expo icon is the correct one.

EDIT: After trying to send a notification from firebase console, I managed to get 1 notification only. Is the problem lies in SNS?

EDIT[2] I took a look at my Cloudwatch Log for the SNS Platform Application. And the NumberOfMessagesPublished metrics suggest that only 1 message published. So I guess it eliminates the possibility that the SNS api was called twice.

EDIT[3] I tried to use go-fcm package to send notification to fcm directly. I got 2 notifications even without using SNS. But why sending notification to fcm directly has a different output than using Firebase console?

enter image description here

UPDATE

Finally, I managed to get it to work by setting a tag field in the notification field to prevent duplicates.

So the payload is like this:

{
"GCM": "{ \"notification\": { \"text\": \"test message\", \"tag\": \"testing\" } }"
}

However this still does not answer the question on why I got the duplicates :(


Viewing all articles
Browse latest Browse all 28480

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>