Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable or Disable Iphone Push Notifications inside the app

I have a iphone app which is enable to receive push notifications. Currently i can disable push notifications for my app by going to the iphone settings/Notifications.

But i want to add a switch or button inside my app to enable or disable push notifications.

It can be done because i saw it in foursqure iphone app did it. They got a section in settings call notification settings and user can enable or disable different kind of notification for the app.

I look all over the net to find a proper solution for this but still not found a way. Can any one please give any idea how to do that ?

Thanks in advance :)

like image 963
Sameera Chathuranga Avatar asked May 09 '12 05:05

Sameera Chathuranga


People also ask

What happens if I disable push notifications?

Nothing will interrupt you, but all the notifications will still appear when you pull down the windowshade. On Android, you can choose "Show Silently," a similar setup. It's not like turning off notifications shuts you out from using the apps you like.

Can you turn off notifications while using an app?

1. Open Settings and tap "Notifications," and you'll find a full list of all your apps. 2. Tap the toggle switch next to each app to turn off its notifications.

How do I enable push notifications for apps on iPhone?

Go to Settings and tap Notifications. Select an app under Notification Style. Under Alerts, choose the alert style that you want. If you turn on Allow Notifications, choose when you want the notifications delivered — immediately or in the scheduled notification summary.

How do I stop push notifications on my iPhone apps?

iOS enables you to both disable push notifications entirely, or turn them off for individual apps. To access iOS notifications settings, go into the Settings > Notifications menu. From that list, you can configure each app's notifications settings or disable them.


2 Answers

[FYI - Few users have reported that it stopped working on iOS 10]

You can easily enable and disable push notifications in your application by calling registerForRemoteNotificationTypes and unregisterForRemoteNotificationTypes respectively again. I have tried this and it works.

like image 133
Varun Bhatia Avatar answered Oct 10 '22 10:10

Varun Bhatia


First thing is that you can not enable and disable push notification in inside the app. If you have found some apps which did it than there must be workaround solution.

Like if you want to do Inside the app then use one identifier and send it to server according push notification enable and disable button. So, your server side coding use this identifier and work according to that. Like identifier is say it's enable than your server will send notification otherwise not.

You can check that user set enable or disable Push Notifications using following code.

Enable or Disable Iphone Push Notifications

UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; if (types == UIRemoteNotificationTypeNone)   // Yes it is.. 

Hope, this will help you..

like image 20
Nitin Avatar answered Oct 10 '22 10:10

Nitin