how to put the settings functionality for Push Notification on/off inside the app in ios

1.2k views Asked by At

I made push notification for iOS according to my app requirement. If I want to manually turn off the push notifications, I will go to Settings and click the Notification off then Notifications are off.

But I want to implement notifications settings functionality inside the app. This means I'm going to my app menu and click the settings button and off the notifications. Then push notifications should get turned off. Is it possible to put the push notifications settings functionality inside the app for notifications are on/off?

2

There are 2 answers

0
Bhumeshwer katre On

To unregister for remoteNotification you can use

[[UIApplication sharedApplication]unregisterForRemoteNotifications];

When you again want to register then follow standard approach.

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeNewsstandContentAvailability|
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)];

But you can't change in settings programatically.

0
Maulik On

You can you use UISwitch control for on/off OR you can also use separate UIButton for on/off.

You just need to unregister for remoteNotification by : ( Off )

[[UIApplication sharedApplication] unregisterForRemoteNotifications];

When you want to register again then ( On )

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)];