mocode9
mocode9

Reputation: 239

iOS 10 (Swift) Reject Notification Permissions

I want to have a UISwitch in my app that when pressed will either request notification authorization or if already authorized reject it.

Is there a way to perform a rejection? I know that if requestAuthorization is called and the user has already authorized the app then nothing will happen. So I was curious if there is a way in app to remove the notification permissions without forcing the user to go to the settings app on their device and doing it from there.

Upvotes: 0

Views: 1036

Answers (2)

brimstone
brimstone

Reputation: 3400

Although you cannot change it from your app as Paulw11 says, you can open the settings page and ask the user to change it.

UIApplication.shared.openURL(URL(string:"prefs:root=NOTIFICATIONS_ID")!)

From this answer

Upvotes: 1

Paulw11
Paulw11

Reputation: 114826

Once a user has granted (or denied) location permissions by responding to the original permission request dialog, the only way that the permissions can be changed is by the user themselves using the device settings app.

Your app can simply not make use of a permission that it has. For example, if the user turns off the 'notifications' switch in your app, unscheduled any scheduled local notifications and don't schedule any more.

Upvotes: 2

Related Questions