I need to enable/disable or register/unregister push notification inside our app after did finish launch. I'll do this function after launch and in my app "account setting"
I have try below code but it's not work.
if (cell.switchButton.on) {
if ([[UIApplication sharedApplication]respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) {
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
}
else {
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
}
My requirement: I'll Enable or Disable notification toggle inside my app programmatically instead of directly go to setting -> Notification.