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

别等时光非礼了梦想. 提交于 2019-12-01 07:39:18

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.

Dattatray Deokar
  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".

Make your Response as follow : if you're consuming from android use GCM or for ios use APNS_SANDBOX

$sns = AWS::createClient('sns');
    $message = json_encode(['default' => '', 'APNS_SANDBOX' => json_encode($data), 'GCM' => json_encode(['data' => $data])]);
    $sns->publish([
        'TargetArn' => $arn,
        'Message' => $message,
        'MessageStructure' => 'json'
    ]);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!