0

Overview

We currently have two applications that differ only in their provisioning profiles. Application one is working properly using its own provisioning profiles. Application two, which is a copy of application one, also has its own application ID and provisioning profiles with the exact same entitlements. The only difference is that application two will not register for notifications.

To spice things up, if we take the provisioning profiles for application one and configure application two to use them, then application two will successfully register for push notifications. Switch application two back to its own provisioning profiles and registration stops.

Issue In Question

Application two will fire off the registerForRemoteNotifications method which should then evoke either the application:didFailToRegisterForRemoteNotificationsWithError: or the application:didRegisterForRemoteNotificationsWithDeviceToken: but neither of these are evoked.

When switching application two to use application one's provisioning profiles, the application:didRegisterForRemoteNotificationsWithDeviceToken: method is evoked and the phone registers successfully.

Testing & Debugging

1. After doing some research, I've read that this may be due to the test device, and iPhone 6 Plus in this case, may not be able to contact the APNS (Apple push notification service). Well, that's not the issue in this case because the same test device can successfully register when the profiles are switched. Other test iPhones were unable to register as well.

2. I've recreated the provisioning profiles multiple times. I've also tried various combinations of letting xCode automatically generate them as well as explicitly downloading and configuring the appropriate profiles within xCode.

3. I've removed all provisioning profiles from the devices to make sure that there were no outdated or mis-configured profiles causing an issue.

4. I created a blank iOS project with the same product name and using the culprit provisioning profiles. Added the necessary methods mentioned above and still no success with registering for notifications.

5. Cleaned my build directory and completely removed the application from the test device.

6. Created the *.ipa file and confirmed that the entitlements are correct.

7. Generated the private key for the push notification server as I thought that maybe the phone could not register until a key was generated.

0

1 Answer 1

1

The solution to the above question is to call the correct methods in the appropriate order. Originally it was assumed that calling - (void)registerForRemoteNotifications on the UIApplication object was enough to evoke the appropriate success or failure method. However this is not the case.

The developer must first call - (void)registerUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings method on the UIApplication object to register the application for the various types of notifications. Only after doing so can the application then call the - (void)registerForRemoteNotifications method of the UIApplication object to register for remote notifications.

In this particular case, the provisioning profiles from application one worked because the application was previously granted permission when running under an older version of iOS.

From the UIApplication Documentation

If you want your app’s push notifications to display alerts, play sounds, or perform other user-facing actions, you must call the registerUserNotificationSettings: method to request the types of notifications you want to use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.