Push Notification delegate call responses are not called

I register for Push Notification by calling the following code snippet:

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

But in some rare cases, the following delegate is not called:

 - (void)application:(UIApplication *)iApplication didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)iNewDeviceToken { 

Not even the following method is called:

 - (void)application:(UIApplication *)iApplication didFailToRegisterForRemoteNotificationsWithError:(NSError *)iError { 

What could be the reason for this. I use the application token when I received the device token. So, in some rare scenarios my application hangs.

Any clue?

+4
source share
4 answers

According to the documentation, none of the callbacks will be made until the device has a permanent connection to the push server. Therefore, if Wi-Fi or data connection is not available, callbacks will not be performed - and apple does not consider this a condition for error. As far as I can tell, the only errors that could have been caused by the didFail callback ... are incorrect problems with access rights to certificates / applications (development problem) or the user has refused permission (although I can only reproduce this sporadically by changing the date and disconnect the phone).

+9
source

The key is right there: you get an instance of NSError when it fails. Therefore, to find out why these are errors, check NSError and see what it tells you.

You should probably at least handle this case in your application, for example, display an error message in the line "Application registration error, try again ...".

0
source

You need to enable Push notifications in the preparation profile, configure it on the developers portal using the application identifier. Then it should work.

0
source

One more thing: if you use the phone with the root key / jail for use with another network, etc., you will have problems. My phone was rooted and no delegates were called. I had an employee who put it on an iPad and it worked fine, so I know that the code is ok.

So, I reinstalled the OS on my phone and started working.

0
source

All Articles