Is there any way in iOS mobile application so that in the app itself we give a button to turn off push notifications from the app(I am using Swift language for programming). Any help will be really helpful.
-
Do it with server side – karthikeyan May 10 '17 at 05:45
-
Handle it from Server Side. Make API call to turn off it from server side on button changed action – Balaji Galave May 10 '17 at 05:50
-
Register and De-register for push notification. This will prevent the push notification from being displayed. – Arasuvel May 10 '17 at 05:52
-
`iOS setting app` already provide this. You should prefer it instead of giving button in your app! It is the real user experience! there is no need to give separate button in your app! – Ketan Parmar May 10 '17 at 05:59
-
If you want to disable only few notifications or say wants customization of notifications then might need to call backend APIs – shaqir saiyed Apr 24 '20 at 10:01
5 Answers
Recommended approach: Try to handle this from the backend. It will be helpful in future time.
Solution: You can use unregisterForRemoteNotifications
. This function is used to unregister all the notification from Apple Store. Again when you want to turn on push notifications, you can register using registerForRemoteNotifications
This is how you need to register/unregister if you don't know how to do that.
UIApplication.shared.unregisterForRemoteNotifications()
UIApplication.shared.registerForRemoteNotifications()

- 4,124
- 2
- 22
- 45
You can remove/set device token from server on remote notification on/off toggle button

- 5,318
- 10
- 50
- 84
You should implement disabling push notifications on the server side. Apple docs said that you should call
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
only if you will not provide notifications in app anymore. Link
In other hand, iOS8 provides API to open Settings.app, where user can disable notifications for your app using switch control. Usage sample:
if (&UIApplicationOpenSettingsURLString != NULL)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

- 91
- 4
You can manage it from your server side , create an API for it. Which is the best solution according to me. Else you can Unregister you device from APN or Open app settings and let user turn off it.

- 745
- 6
- 24