Is there a way to programmatically unregister a device for push notifications?

Just wondering if this is actually possible. This way I can stop all notifications, for example, how the notification center can stop all notifications.

I do not believe that this is possible, but I wonder what you think.

+8
source share
3 answers

Push notifications are sent from your server ... so you must implement this method yourself and delete or disconnect the device in the database on your server, where you store active devices.

If you only disable them locally on your device, your server will still send messages until you receive a notification from the feedback service .. which you should check ...

+5
source

For Swift 4 and above

 UIApplication.shared.unregisterForRemoteNotifications() 

You can call this method after the user logs out to make sure that the next connected user will have a unique device token.

0
source

All Articles