Reputation: 71
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?
Upvotes: 3
Views: 3289
Reputation: 51
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.
Upvotes: 5
Reputation: 908
Did you ever find out what your issue was? This is probably too late to help you, but might help any others that stumble across this question.
In create platform, which key should I use? I used the one form firebase console-> project settings-> cloud messaging -> Server key Is this wrong?
Yep, that key should work. I have managed to get both the "Server key" and the "Legacy server key" to work fine with SNS. I'd say you should use the newer server key just to ensure things don't break in future if the legacy key is retired by Google.
For the platform endpoint, I used FCM token for Device Token, which is also used when sending notif in firebase console.
Yes, that should work. To be clear you want to use the token that's retrieved by your FCM ID listener service.
Also what should I put in User Data, will any arbitrary string do?
Anything here is fine. It's just a note for yourself.
For the message, I used the Json Generated in SNS console. Does FCM accept different format from GCM?
The message format is slightly different - the answer you linked describes the differences. Even with these differences though I think you should be able to receive something just using the SNS JSON message generator.
Upvotes: 0