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?
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 :(