iOS Push Notifications Unregistering From Push Notifications


Example

To unregister from Remote Notifications programatically you can use

Objective-C

[[UIApplication sharedApplication] unregisterForRemoteNotifications];

Swift

UIApplication.sharedApplication().unregisterForRemoteNotifications()

this is similar to going into the setting of your phone and manually switching off Notifications for the application.

NOTE: There may be rare cases where you would need this(eg: when your app no longer supports push notifications)

If you just want to allow the user to temporarily disable Notifications. You should implement a method to remove device token in the database on your server. else if you only disable Notification locally on your device your server will still send messages.