Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push Notification delegate call backs are not getting called

I am registering for Push Notification by calling the following piece of code:

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

But in some rare cases following delegate does not get called:

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

Not even following method gets called:

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

What could be the reason for this. I am proceeding with my app flow once I received the device token. So, in some rare scenarios my app hungs.

Any clue?

like image 716
Abhinav Avatar asked Jan 20 '23 06:01

Abhinav


1 Answers

According to the documentation, neither of the callbacks will happen until the device has a persistent connection with the push server. So if there is no wifi or data connection available, the callbacks won't happen - and apple doesn't regard this as an error condition. As far as I can tell, the only errors that can happen to cause the didFail... callback are an incorrect certificate/app permissions issue (a development problem), or the user declined permission (though I am only sporadically able to reproduce this by changing the date and turning the phone off).

like image 61
Hammm3r Avatar answered Jan 31 '23 09:01

Hammm3r