Search code examples
iphonexcodepush-notificationapple-push-notifications

Registering the iPhone application for push notification not working


I have tried out the example found in the link http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12 , for my iPhone push notification message. I could successfully run all steps except the steps for registering the app for push notification for the first time.

I have followed different variations of the code:

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

But none worked for me. I am testing it in my iPhone 4 and my Xode version is 4.2 , OS is Lion. Please advice.


Solution

  • You can try the following:

    • Make sure your Xcode project is configured to use the explicit bundle ID from the provisioning portal
    • Make sure you're not building the target with wildcard or team provisioning profile, check this on the project AND target settings
    • If you created your provisioning profile before configuring the app ID for push, regenerate the provisioning profile

    Also look at the error object in the UIApplicationDelegate method

    application:didFailToRegisterForRemoteNotificationsWithError:
    

    EDIT 1

    Open your provisioning profile in a text editor and look for the string

    <key>aps-environment</key>
    

    If your profile does not contain this, it is not correctly set up for push.