0

I would like to apply the native feature of ON/OFF toggle for push notifications at app level. When i applied the same in my app and when I switch OFF, i am unable to receive notifications. However, when I switch ON, i am not receiving notifications. To have my notifications enabled, I need to uninstall and then install my app.

any possible solution is appreciated.

  • Check this.. http://stackoverflow.com/questions/20345823/ios-how-to-disable-push-notification-at-logout – Dinesh Dec 06 '13 at 08:01
  • You can open native setting app from your app to enable or disable notifications.http://stackoverflow.com/questions/5655674/opening-the-settings-app-from-another-app/24952919#24952919 – Karan Dua Dec 25 '14 at 08:14

1 Answers1

0

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)];

For checking ON or OFF iPhone Push Notifications try this code,

UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types == UIRemoteNotificationTypeNone) 
 // Yes it is..
Toseef Khilji
  • 17,192
  • 12
  • 80
  • 121