How do I troubleshoot failed Amazon SNS push notification deliveries?
Last updated: 2020-12-21
How do I confirm the delivery status of Amazon Simple Notification Service (Amazon SNS) push notifications, and how do I determine why some notifications fail?
When you enable Amazon SNS delivery status logging for your platform application, your push notification transactions are logged with Amazon CloudWatch Logs. The logs include both successful and failed deliveries.
Turn on delivery status logging
- Open the Amazon SNS console.
- Open the left navigation menu, expand Mobile, and then choose Push notifications.
- Under Platform applications, select the platform application you want to enable delivery status for, and then choose Edit.
- Expand Delivery status logging – optional, and then choose Create new service role.
- Choose Create new roles. The AWS Identity and Access Management (IAM) console opens in a new tab or window.
- On the IAM console permission request page, choose Allow.
- Choose Save changes.
Note: You can also enable delivery status by using AWS SDKs and the AWS Command Line Interface (AWS CLI). If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.
View delivery status logs
- Open the CloudWatch console.
- In the left navigation pane, choose Logs.
- Under Log Groups, find your application's delivery status logs.
Note: Delivery status logs aren't available until messages are published to an endpoint. For push notifications, successful publication occurs when Amazon SNS hands off the message to the provider. However, that hand off doesn't guarantee that the notification was delivered to the device.
Depending on the application type, you might see two log groups—one for successful notifications, and one for failed notifications. Logs for Firebase Cloud Messaging (FCM) and Apple Push Notification service (APNs) are in log groups named like the following example:
"Failure" is appended to a log entry if delivery is unsuccessful. For example:
Some log details include the messageId, statusCode, time taken (dwellTimeMs), destination endpoint (destination), and providerResponse. For log examples, see Amazon SNS message delivery status CloudWatch log examples.
Troubleshoot notification failures
Look up the statusCode with the provider service, such as FCM or APNs. For the provider's exact response message, view the providerResponse.