My goal end goal is to send push notifications to an iOS app via SNS. I am stepping through this tutorial: http://docs.aws.amazon.com/sns/latest/dg/mobile-push-apns.html.
I have added in my AWS credentials, and added in the corresponding apns credentials for my development key, certificate, private key, and a current push token for my app. When I run the tutorial I get:
Exception in thread "main" java.lang.NullPointerException
at com.amazonaws.sns.samples.tools.AmazonSNSClientWrapper.getValidNotificationAttributes(AmazonSNSClientWrapper.java:162)
at com.amazonaws.sns.samples.tools.AmazonSNSClientWrapper.publish(AmazonSNSClientWrapper.java:80)
at com.amazonaws.sns.samples.tools.AmazonSNSClientWrapper.demoNotification(AmazonSNSClientWrapper.java:131)
at com.amazonaws.sns.samples.mobilepush.SNSMobilePush.demoAppleSandboxAppNotification(SNSMobilePush.java:438)
at com.amazonaws.sns.samples.mobilepush.SNSMobilePush.main(SNSMobilePush.java:68)
At the top of SNSMobilePush.java there is a Map called attributesMap. It originally has values set to null for keys Platform.APNS and Platform.APNS_SANDBOX. These values never get changed anywhere during the code and are responsible for causing the null pointer exception. The tutorial does not indicate to change these values.
I did not do anything above or beyond the tutorial instructions.
I know that my credentials are correct as I did send a message to my iOS app using these same credentials via Amazon Management Console.
Can anyone indicated
- if the tutorial is incomplete
- what the values associated with Platform.APNS_SANDBOX should be in order to get this working
- any hint to help me trouble shoot this
update I added in a null check to getValidNotificationAttributes() and now I am able to send push notifications using sns and apns using this tutorial.