Is there a way to disable the alert settings from an application through code? I am already enabling these settings using below code, but I cant find any method to disable these settings again on user action.
var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
UIUserNotificationType.Alert |
UIUserNotificationType.Badge |
UIUserNotificationType.Sound,
new NSSet());
UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings);
UIApplication.SharedApplication.RegisterForRemoteNotifications();
There is below method but it doesn't disable the notification in application settings.
UIApplication.SharedApplication.UnregisterForRemoteNotifications
The problem seems to be that iOS prevents registering for push notification with Apple in a manner of time after unregistering. The Apple Docs regarding unregistering say:
https://developer.apple.com/documentation/uikit/uiapplication/1623093-unregisterforremotenotifications?preferredLanguage=occ
So, just don't call unregisterForRemoteNotifications as long as you really need to do it (see Apple Doc).
The user has total control on enabling and disabling notifications for your app, if you want to do it in code, I think you could create a popup leads to setting page. like this questions shows How to turn on and off notifications in iOS?