views:

31

answers:

1

I am running Push Notification on two test apps. The first test app I got working over a 2 day period. The 2nd test app I tried to implement Push Notification tonight and have been banging my head over it. I am able to swap the certificates and the 1st app receives notifications, but when I use the .pem for the 2nd app, nothing happens.

I have gone through the entire process twice tonight, trying to get the Push to work for this 2nd app. My only conclusion, given that I can swap the .pems and it will work for the 1st app, is that something is wrong with the 2nd .pem or maybe there is a waiting period before the push starts working, and I just didn't realize it during my first setup?

Edit: The problem was that I was using

-(BOOL)application: didFinishLaunchingWithOptions:

in my delegate and not using

-(void)applicationDidFinishLaunching:

I was doing...

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Register for Push Notifications
    UIRemoteNotificationType notifyTypes = (UIRemoteNotificationTypeAlert |     UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge);

}

When I should have been doing

-(void)applicationDidFinishLaunching:(UIApplication *)application {
    //NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];


    // Register for Push Notifications
    UIRemoteNotificationType notifyTypes = (UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound |UIRemoteNotificationTypeBadge);
}
A: 

There is a waiting period before Push starts working, though in my experience said period is generally quite short. Make sure that the little dot is green in your App ID page of the provisioning portal - and make sure that it is for the correct App ID and environment (for example, if you're running in debug, make sure that it is configured for development).

Apart from that, it could be an issue with your .pem or provisioning profile as well.

From the Apple Push Reference guide:

You have to modify the profile in some minor way (for example, toggle an option) for the portal to generate a new provisioning profile. If the profile isn't so “dirtied,” you're given the original profile without the push entitlements.

Do you have any errors coming up when you attempt to push?

Andrew Natoli
The green dot is lit in my AppID/Push Notification Config. I created everything new - AppID, Provisioning, Certificates... Not receiving any errors when sending the notification (from PHP) as far as I can see.
Chris
Hmm... I am not sure about the server side issues in PHP, I've only done it with Rails. It seems a bit strange that it is working now that you changed your DidFinishLaunching - I used DidFinishLaunchingWithOptions in my app and it works fine - in fact, using the withOptions version is required if you want to launch the app with different actions as the result of a push!
Andrew Natoli