APNS INVALID_TOKEN Since XCode 8.1 upgrade

...Hi,


I recently update my XCODE to 8.1, ever since my APNS stopped working. I follow this the code for APNS device registration. https://www.raywenderlich.com/123862/push-notifications-tutorial.


The problem is that i use Objective C instead of Swift and the device token i get following the above coding steps, is always comes back as Invalid_token. The same code in Swift works well and device token is valid.


Additionally, the delegate method like didRegisterUserNotificationSettings is getting called three times.


I have been stuck with this issues for past couple of days, can some one please help.


Here is my code snippet.


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


NSLog(@"did finish launch called");

[self registerForPushNotifications:application];

....

}


-(void) registerForPushNotifications :(UIApplication *) application{

UIUserNotificationSettings *settings=[UIUserNotificationSettings settingsForTypes:(UNAuthorizationOptionSound|UNAuthorizationOptionAlert|UNAuthorizationOptionBadge) categories:nil];

[application registerUserNotificationSettings:settings];

}


-(void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{

if(notificationSettings.types){

[application registerForRemoteNotifications];

}

}


-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{

const char *data = [deviceToken bytes];

NSMutableString *token = [NSMutableString string];


for (NSUInteger i = 0; i < [deviceToken length]; i++) {

[token appendFormat:@"%02.2hhx", data[i]];

}

self.deviceId=token;

NSLog(@"Device id is set ");

//NSLog(self.deviceId);

}


-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{

NSLog(@"Error while registering for remote notification %@", error.localizedDescription);


}

- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{

NSLog(@"Cashout payload :: %@",userInfo);

[[NSUserDefaults standardUserDefaults]setObject:userInfo forKey:@"new-vendor-message"];

}



My device version IOS 9.3.2.


Thank you

venkat

APNS INVALID_TOKEN Since XCode 8.1 upgrade
 
 
Q