Enable/Disable Apple Push Notification from iPhone App

Enable/Disable Apple Push Notification from iPhone app?

Unfortunately you can't enable or disable the Push Notifications for your app from the app code. The dialog asking for permission is displayed only once.
Usually, other apps display instructions to the user to enable / disable push notifications by going into Settings-> Notification-> AppName.

Enable/Disable push notification after did finish launch or inside our app

You should not use unregisterForRemoteNotifications, it will unregister APNS completely as apple said

You should call this method in rare circumstances only, such as when a
new version of the app removes support for all types of remote
notifications. Users can temporarily prevent apps from receiving remote notifications through the Notifications section of the Settings app.

here is link

It will be better if you implement disabling push notifications on your server side. Just told your server guy to make service to not send APNs.

or you can also open notifications section of the settings app as below

if (&UIApplicationOpenSettingsURLString != NULL){
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}

How to enable/disable push notification from my app

If a user denied permissions for push notifications you can not let him enable it from within the app.

You could however, set a button in your settings app (ViewController), and let the user switch the notifications off and on there. Then you can set a boolean to check before sending notifications. This way a user might use it instead of disabling the app's notification permission on the device settings.

Enable or Disable Iphone Push Notifications inside the app

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..

How to correctly disable/enable push notifications

According to docs for unregisterForRemoteNotifications:

You should call this method in rare circumstances only, such as when a
new version of the app removes support for all types of remote
notifications. Users can temporarily prevent apps from receiving
remote notifications through the Notifications section of the Settings
app. Apps unregistered through this method can always re-register.

The correct way (actually the way I have seen in the projects I have worked on) is to call an api and tell the backend that push notification should not be sent.

Get Push Notification enabled/disabled event from settings app ios?

You can poll for changes with this call. You can call this on your viewDidAppear when you return to your app. You can also call it from your appDelegate on your applicationDidBecomeActive to check someone's status.

 UNUserNotificationCenter.current().getNotificationSettings { settings in

}


Related Topics



Leave a reply



Submit