devdork
devdork

Reputation: 305

AWS SNS push notification not received on iPhone 6 and above

My coworker and I are building an app and implementing push notification feature utilizing AWS SNS API. The issue here is that some devices work fine but some like iPhone 6,7,8 receive no notification regardless of the OS version (they're mostly iOS 11,12).

We've covered the basic by checking the below points:

  1. notification turned on on all test devices
  2. testers grant permission to receive notification at the app launch time
  3. the p12 certificate uploaded to AWS is valid and the format is correct

The error messages we got from AWS CloudWatch Logs mostly were "bad device token" or "unregistered", but we are sure that we upload the device token as soon as we got it from APNS.

EDIT: actual code added

Register for notification (within didFinishLaunchingWithOptions)

UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
    if let error = error {
        print("\(error.localizedDescription)")
    } else {
        application.registerForRemoteNotifications()
    }
}

Get token

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    print("Successfully registered for notifications!")
 // upload token to our database for later use
}

Is there anything we are missing?

Upvotes: 1

Views: 693

Answers (0)

Related Questions