Hi I am stuck with this issue for over a week now. I followed this tutorial here to add Push Notification in my app. On initial run of my app the "App would like to send you push notification" is not appearing. But when I go to the Apps Notification it is already registered for notification for sounds and banners only and the Badge App Icon is not ON. But when I Login in my app the Badge App Icon Notification Type is no longer there. (sorry cant post image)
And when I check my logs I have this run time error: Attempting to badge the application icon but haven't received permission from the user to badge the application
Here's my code in my AppDelegate.m
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSString *hexToken= [[[[deviceToken description]
stringByReplacingOccurrencesOfString: @"<" withString: @""]
stringByReplacingOccurrencesOfString: @">" withString: @""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
[[NSUserDefaults standardUserDefaults] setObject:hexToken forKey:@"deviceToken"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
Any help will be appreciated. Thanks.