Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Cloud Messaging With AWS SNS

I am trying to integrate FCM with SNS. I read in this answer that the setup should be identical with GCM. I managed to create an FCM app and can send messages to an android device. The device receives a notif in tray when app is in background, or print received message when app is in foreground. I am trying to integrate it now to SNS but I can't seem to make it work, no error message whatsoever.

In create platform, which key should I use? I used the one form firebase console-> project settings-> cloud messaging -> Server key Is this wrong?

For the platform endpoint, I used FCM token for Device Token, which is also used when sending notif in firebase console. Also what should I put in User Data, will any arbitrary string do?

For the message, I used the Json Generated in SNS console. Does FCM accept different format from GCM?

Am I missing something?

like image 225
Karlo Serrano Avatar asked Mar 20 '26 11:03

Karlo Serrano


1 Answers

If you are using Firebase ensure you modify the AWS SNS publish to endpoint message to look like this:

{
"GCM": "{ \"notification\": { \"body\": \"test aws\", \"title\": \"test aws\" } }"
}

It must have a body and a title as well as change "data" to "notification", otherwise your message will not be received on your device.

like image 94
mtirona Avatar answered Mar 23 '26 01:03

mtirona



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!