iOS8 comes with rregisterUserNotificationSettings: delegate method. Using this method we can do some patches.Please review them and Let us know your comments.Please these is only work with iOS8.
= > / .
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)])
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
}
=> Here below the method is called After Alert Notification Fire. Using any button action (do not allow or allow), we forcefully register the notification completely. and Dow with some fixes.
#ifdef __IPHONE_8_0
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
[application registerForRemoteNotifications];
}
=> We do the trick here
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
NSLog(@"devToken: %@",devToken);
#if !TARGET_IPHONE_SIMULATOR
NSString* deviceToken = [[[[[devToken description]
stringByReplacingOccurrencesOfString: @"<" withString: @""]
stringByReplacingOccurrencesOfString: @">" withString: @""]
stringByReplacingOccurrencesOfString: @" " withString: @""] retain];
NSLog(@"deviceToken : %@",deviceToken);
NSUserDefaults *standardDefaults = [NSUserDefaults standardUserDefaults];
if((![[standardDefaults valueForKey:@"DeviceToken"] isEqualToString:deviceToken]) || [standardDefaults valueForKey:@"DeviceToken"]==nil){
[self sendProviderDeviceToken:deviceToken];
}else{
}
}
source
share