Search code examples
iosamazon-web-servicesamazon-snsaws-mobilehub

Testing Amazon SNS for iOS using the Mobile Hub but can't get it to work


Per the title, I'm trying to get AWS SNS push notification to work on iOS device. For testing purpose I wanted try the Mobile Hub (https://console.aws.amazon.com/mobilehub) and work my way on top of the sample app that's given.

I just can't seem to make it work. I know it's difficult to ask for help when it involves a multi layered instructions, but I've spent all weekend wrestling this issue, and just couldn't seem to figure it out. In AppDelegate, didReceiveRemoteNotification call should receive something when I trigger an SNS within Amazon SNS Mobile Console after selecting a Topic. But this protocol is not being called.

  1. In terms of Provisioning Profile, I've created both Development & Distribution. Tested with both.
  2. In terms of certificates I have tried with both Apple Push Notification service SSL (Sandbox) and Apple Push Notification service SSL (Sandbox & Production). It's obvious you have to select the latter since with the former, the notification permission alert doesn't even show when you install the app. Only does it show when you've installed it with the latter.

  3. I made sure the bundle IDs match.

  4. I've turned on all my notifications on my iphone 6s.

  5. On console I see this success message:

2016-03-30 20:57:57.103 MySampleApp[284:47861] AWSiOSSDKv2 [Info] AWSPushManager.m line:186 | -[AWSPushManager interceptApplication:didRegisterForRemoteNotificationsWithDeviceToken:] | The device token: 435d5se354s38s9ddge2edcs2a3601e18ss9c83e47s629164ebced21s16abb39974sg3

  1. "didFailToRegisterForRemoteNotificationsWithError" never gets called.

  2. "didRegisterForRemoteNotificationsWithDeviceToken" successfully gets called.

  3. I also get this success message on my console:

2016-03-30 21:34:16.635 MySampleApp[321:57551] AWSiOSSDKv2 [Info] PushNotificationViewController.m line:112 | -[PushNotificationViewController topicDidSubscribe:] | Successfully subscribed to a topic: AWSPushTopic: 0x14c6da770

I'm absolutely lost. Please let me know if there is more info for me to post to solve this issue.

Update: Rohan Dubal, thanks for the comment. Here are the following things you asked me for.

  1. Yes, I have always went from "My Sample App" navigationbar view -> "Push Notifications" row -> "Push Notifications" navigation bar view -> click Demo Push Notifications on the bottom -> the toggle is on (green) and the "topic" line is checkmarked and I have sent the APNS to that referring Topic.

  2. Yes I've tried minimizing and also closing the app as well. The top bar notification or any notification doesn't show at all.

Thanks for your feedback. Please do suggest any other tests I can run.

Also, I thought that maybe it has to do w/ my iphone 6s so i tried it w/ iphone 5s and it still doesn't work. iphone 6s is ios9.2 and iphone 5s is ios 8.3.


Solution

  • Well, this sounds similar to the problem that I was just having. Mobile Hub only seems to let you setup Production APNS and not Development ones. When I debug the app with XCODE I'd need to use the sandbox APNS, so I did the following:

    1. Create an SNS Application of type Apple Development (APNS_SANDBOX)
    2. Use the .p12 from my Development Certificate in the App ID
    3. Started my App and recorded the device token that didRegisterForRemoteNotificationsWithDeviceToken gave me
    4. Minimised my App (otherwise notifications don't appear)
    5. in SNS console I registered an Endpoint using the device token
    6. Used the Publish to this Endpoint button in SNS console to send a message ('Hello World', obviously)
    7. Saw notification
    8. Did engineers victory dance

    Hopefully that helps you. The key to this for me was realising that I'd need to create another SNS queue. TBH I'm not seeing the benefit of the Mobile Hub.