Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon sns (push notification) does not send to IOS application

Recently the app can not receive notification, the android side works fine but the ios one has fail

so here is what I have attempt:

1) generate token from apple apn service
2) create the endpoint at amazon backend
3) publish the message at amazon backend
4) it does not receive message and the endpoint will go to disabled after a while.

And I have checked the following:

1) try serveal ios device , including iphone/ ipad/ipod touch also the same result
2) checked the secret key/ platform arn it is matched
3) created another platform ARN but still the same.

So , what direction should I continue to debug , e.g. is the push notification cert ? which part of coding should I check, as it works before but only fail recently.

Thanks a lot.

like image 955
user782104 Avatar asked Jan 09 '23 05:01

user782104


2 Answers

  1. Create your APNs sandbox(development) certificate(make sure you are selecting bundle identifier of your development certificate)

  2. Once you create sandbox certificate, verify push notification service is enabled for your provisioning profile(you can not create provisioning profile with your APNS certificate, you have to use your provisioning profile created with development certificate)

  3. If you have already installed development provisioning profile then delete is from following path "xcode-prefrences-select apple developer account - view details - provisiong profile"

  4. Download development provisioning profile from member center and install it. Select newly installed profile and certificate

  5. Login to Amazon SNS and select nearest location(at top right corner) as shown in below image with red oval. Change Location place

  6. Under "Mobile Services" section select SNS (Push Notification Service )

  7. Now you will be at SNS Home Screen, now select Application from side Menu

  8. Click on "Create Platform Application". Enter application name then select Push Notification Platform as "Apple Development" and Push Certificate type as "iOS Push Certificate"

  9. Now you have to upload privateKey.p12

Process to get privateKey.p12

To get privateKey.p12, download APNs(sandbox) certificate and install it in krychain. then open keychain Access and expand certificate then select name of developer account holder(it will have icon of key and Kind as "private key") Now right click on account holder name and click on export(enter password to file if you want or else leave it blank) then name is as privatekey.p12 and store it on desktop

  1. Choose privateKey.p12 from desktop then enter password if you have set then click on "Load Certificate from File" then certificate and private key fields will be populated with values exported from privateKey.p12.

  2. Click on "Create Application Platform", your new ios Application is created.

  3. Click on ARN, it will go inside your app. now click on "Create Platform Endpoint"

  4. Run your mobile app and get deviceToken

  5. Enter device token in "Device token" field and give device name in user data. Now click on "Add Endpoint"

  6. Select added endpoint and click on "Publish to Endpoint"

Select message format as per your need then enter your message then click on "Publish Message".

like image 55
Dattatray Deokar Avatar answered Jan 10 '23 17:01

Dattatray Deokar


If the SNS endpoint is disabled after a while, that means your APNS certificate has some issue. Do you mistakenly use a sandbox certificate for prod, or visa versa? Do you have the right certificate and private key combo? See http://docs.aws.amazon.com/sns/latest/dg/mobile-push-apns.html for more information.

like image 43
Yangfan Avatar answered Jan 10 '23 18:01

Yangfan