- Newest
- Most votes
- Most comments
The issue you're experiencing with AWS SNS and FCM messages not appearing on Android devices while working fine on iOS is not uncommon. There are a few potential reasons for this and some steps you can take to troubleshoot and resolve the issue:
- Message format: While the format you're using is generally correct, you might want to try adjusting it slightly. For Android devices using FCM through SNS, you could try this structure:
{
"GCM": "{ \"data\": { \"message\": \"Test message\" }, \"notification\": { \"title\": \"Test title\", \"body\": \"Test body\" } }"
}
This includes both a data payload and a notification payload, which can help ensure the message is received in various app states.
-
Time to Live (TTL): The long delay you're experiencing (8+ hours) suggests there might be an issue with the TTL setting. Make sure you're setting an appropriate TTL for your messages. If it's set too low, messages might expire before they're delivered.
-
Firebase Cloud Messaging (FCM) configuration: Double-check your FCM configuration in your Android app and in the AWS SNS console. Ensure that the server key and sender ID are correct and up-to-date.
-
Android app configuration: Verify that your Android app is properly set up to receive FCM messages, including having the necessary permissions and services declared in the manifest file.
-
Background restrictions: Some Android devices have strict background processing limitations. Ensure your app is exempted from battery optimization settings on test devices.
-
Token registration: Make sure the FCM registration tokens for your Android devices are correctly registered with SNS and are up-to-date.
-
Message priority: Try setting a high priority for your messages, which can help with faster delivery on Android:
{
"GCM": "{ \"data\": { \"message\": \"Test message\" }, \"notification\": { \"title\": \"Test title\", \"body\": \"Test body\" }, \"android\": { \"priority\": \"high\" } }"
}
-
CloudWatch logs: While the logs show SUCCESS, this only means SNS successfully sent the message to FCM. It doesn't guarantee delivery to the device. You may need to implement additional logging in your Android app to track message receipt.
-
Test with a direct FCM send: If sending directly through FCM works but not through SNS, there might be an issue with how SNS is formatting the message for FCM. In this case, you may need to contact AWS support for further assistance.
If none of these solutions work, you may need to implement more detailed logging in your Android app to understand where the messages are being lost, or reach out to AWS support for more in-depth troubleshooting.
Sources
Amazon Simple Notification Service (SNS) FAQs | Messaging Service | AWS
Sending a message - AWS End User Messaging Push
Sending mobile push notifications with Amazon SNS - Amazon Simple Notification Service
answered 2 years ago
I've tried the solutions you provided but none of them work.
I've checked the configuration and everything is correct. As I mentioned everything works in iOS but in Android I don't receive the messages and if I receive them, they take several hours to arrive.
answered 2 years ago
The issue you're experiencing with delayed or undelivered push notifications on Android devices when using AWS SNS with FCM is concerning. Let's address this step-by-step:
1. Verify FCM Configuration:
Ensure your FCM configuration in AWS SNS is correct.
2. Message Format:
The format you're using looks correct, but you might want to try this alternative structure:
{ "GCM": "{ \"data\": { \"message\": \"Test message\" } }" }
This format is recommended in the AWS documentation for FCM messages [1].
3. Check Device Tokens:
Verify that the device tokens for your Android devices are up-to-date and correctly registered with FCM.
4. Investigate Delivery Delays:
The 8-hour delay you're experiencing is unusual. This could indicate a problem with the FCM service or network connectivity issues.
5. CloudWatch Logs:
While CloudWatch shows SUCCESS, this only means SNS successfully sent the message to FCM. It doesn't guarantee delivery to the device.
6. FCM Troubleshooting:
Review the FCM troubleshooting guide [2] for common issues that might prevent message delivery.
7. Android App Configuration:
Ensure your Android app is properly configured to receive and handle FCM messages, including necessary permissions and background services.
8. Best Practices:
Follow AWS SNS best practices for mobile push notifications [3], which include using production and sandbox environments appropriately and monitoring delivery rates.
If the issue persists, consider opening a support ticket with AWS for more in-depth investigation.
Sources:
[2] https://firebase.google.com/docs/cloud-messaging/android/client#sample-register
[3] https://docs.aws.amazon.com/sns/latest/dg/mobile-push-notifications-best-practices.html
Relevant content
asked 3 years ago
- AWS OFFICIALUpdated 3 years ago
