I decided to turn off my notification on "reminders" switch control from my app. I added those lines in my app to make it support both iOS 7 and iOS 8 and it is working when I switched off push notification. BUT when I decided to turn on the switch and closed the app,when I opened it again and it went back to OFF instead of being ON. So I have to go to Settings --> Notification Center --> "my app" and turn all the things back on because they are off... Very strange that when I test it on iOS 7 it is working but not for iOS 8. Any suggestion appreciated. Thanks.
- (IBAction)reminderSwitchToggled:(id)sender {
UIApplication *application = [UIApplication sharedApplication];
if ([sender isOn]) {
#ifdef __IPHONE_8_0
if(NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1) {
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}
else
#endif
{
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge| UIRemoteNotificationTypeAlert| UIRemoteNotificationTypeSound];
}
} else {
#ifdef __IPHONE_8_0
if(NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1) {
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings
settingsForTypes:
(UIUserNotificationType)
(UIUserNotificationTypeNone)
categories:nil]];
[application unregisterForRemoteNotifications];
}
else
#endif
{
[application unregisterForRemoteNotifications];
}
}
}