Scott Jungwirth
Scott Jungwirth

Reputation: 6675

how to test sns APNS push notifications to a single device

How can I verify my AWS SNS credentials for APNS in production? I needed to update the credentials (public/private key) because the original certificate is expiring, now I want to test sending a push notification to a single device so that I don't spam every user with a test push notification.

Upvotes: 0

Views: 1478

Answers (1)

Scott Jungwirth
Scott Jungwirth

Reputation: 6675

First you need to determine the SNS ARN for the specific device you want to send a push notification to, usually this can be done by inspecting the network traffic of the app with Charles Proxy. Look for a request to sns.us-east-1.amazonaws.com and find the EndpointArn attribute in the request that contains a guid after your SNS Application Name:

SNS EndpointArn value

Then you can trigger the push notification using the AWS CLI command below, replacing the target-arn option with the EndpointArn determined from the previous step.

aws sns publish --target-arn "arn:aws:sns:us-east-1:<aws account id>:endpoint/APNS/<sns application name>/<device guid>" --message "test"

Other tips:

  • Push notifications only work with apps downloaded via the App Store (including Test Flight), but not with apps installed via XCode.
  • Be sure to include the device GUID after the application name to target a single device only in the target-arn argument.

Upvotes: 2

Related Questions