Varis Darasirikul
Varis Darasirikul

Reputation: 3063

Turn Off Push Notification function By Swift

I want to make the function that turn off push notification off the app (at the setting page) by Uiswitch

How can i do it

Thanks!

Edited Add example photo

enter image description here

Upvotes: 3

Views: 5996

Answers (2)

Viral Savaj
Viral Savaj

Reputation: 3389

From the application, it is near to impossible, but you can set your change your Service which send Push notification.

If you are using APNS, than you must send Device token to your server, for send push notification.

You can make call to server for disable it with the device token you passed. You can make call on switch value change.

Upvotes: 2

Rahul Mayani
Rahul Mayani

Reputation: 3831

Use this ...

The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day.

if types == UIRemoteNotificationType.None {}

UIApplication.sharedApplication().registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound | UIRemoteNotificationType.Alert, categories: nil))

Note for PushNotification...

Upvotes: -1

Related Questions