UIApplication unregisterForRemoteNotifications
Unregister for notifications received from Apple Push Service.
- (void)unregisterForRemoteNotifications
Discussion of [UIApplication unregisterForRemoteNotifications]
You should call this method in rare circumstances only, such as when a new version of the application drops support for remote notifications. Users can temporarily prevent applications from receiving remote notifications through the Notifications section of the Settings application. Applications unregistered through this method can always re-register.
UIApplication unregisterForRemoteNotifications example.
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
Example of [UIApplication unregisterForRemoteNotifications].
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
UIApplication unregisterForRemoteNotifications example.
Bool isOn = [[NSUserDefaults standardUserDefaults] boolForKey:@"SwitchKey"];
if (isOn) {
NSLog(@"ok");
}
if (!isOn) {
[[[UIApplication sharedApplication] delegate] unregisterForRemoteNotifications];
}
if (isOn) {
NSLog(@"ok");
}
if (!isOn) {
[[[UIApplication sharedApplication] delegate] unregisterForRemoteNotifications];
}
End of UIApplication unregisterForRemoteNotifications example article.