Sunday, December 19, 2010

Push notifications in distribution builds

Push notifications may have been sailing along just fine for your app during development. But once you flip the switch to distribution, things may not work as smoothly.

Firstly, I recommend implementing the selector:
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
Throw an alert to tell you what's going on here (you can't NSLog it because you can't attach a debugger to a distribution build -- yet another annoyance).

If you get a message something like: "no valid aps-environment entitlement string found for application," like I did today, you may wonder what that means.

It's a simple solution. Go to developer.apple.com and create a new provisioning profile. Make sure the app ID is set to your actual app ID (without any wildcards). Also make sure that your app has Production push notifications enabled properly. The trick is this new provisioning profile. Get it made, download it, and install it in Xcode. Switch your project to sign using this new profile, and you should be golden.

No comments: