- Newest
- Most votes
- Most comments
Hello,
I suggest checking that everything is in place first.
- Make that the ARN being used for the last point has the most up-to-date and correct token for the device. Tokens may stop functioning if the software is uninstalled, reinstalled, or the cache memory is cleaned.
- The FCM frequently doesn't automatically display a notification when its application is in the foreground. The application will receive the notification's data instead, and it is up to it to manage it in the code. As a result, try sending the notification while the application is shut down completely or running in the background.
- WS SNS requires a certain message format for some systems. In this case, it is acceptable to use the key "GCM" for your useful data, but make sure your JSON format is valid and complies with the requirements of the FCM HTTP v1 API:
https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages
And it should looks like:
{
GCM: JSON.stringify({
data: {
title: "Your title",
body: "Your message",
},
}),
}
- To properly process your custom payload while delivering push notifications, you might need to set the message structure property to "json".
You can update the "publishParams" like:
const publishParams = {
Message: message,
MessageStructure: 'json',
TargetArn: endpointARN,
};
- Check that your Android manifest file has essential permissions enabled. You must have the 'com.google.android.c2dm.permission' permission. Request permission. Make sure the server key in your Firebase Cloud Messaging configuration and the SNS platform app (in the AWS console) match.
You can also look into CloudWatch logs for any related error messages or issues.
Hey, good to hear that you've solved the issue!
Yes, the “MessageStructure” parameter is mentioned in the AWS SNS documentation. In the “Publish” request parameters, you'll find the “MessageStructure” parameter. The “MessageStructure” parameter must be set to “json” if distinct messages are being sent for each protocol.
The top-level JSON keys for the JSON object may be any or all of the following: “default”, “email”, “sqs", “lambda”, “http”, “https”, “sms", "APNS", "APNS_SANDBOX", "APNS_VOIP", "APNS_VOIP_SANDBOX", "MACOS", "MACOS_SANDBOX", "GCM", "ADM", "BAIDU", "WNS", "MPNS", and "FCM".
You can send a separate message for each protocol when you set the "MessageStructure" property to "json". In your case, setting it to "json" allows you to specifically format your message for GCM/FCM.
Publish – Amazon Simple Notification Service:
Alright, thank you for explanation. Really appreciate that.
Relevant content
- asked 3 years ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
Thank you for the detailed response. Really appreciate that. I have verified everything, the only issue was that I was not specifying the MessageStructure in publishParams. Is this something mentioned in AWS SNS documentation?