How to get back "Allow Push Notifications" dialog after it was dismissed once?

IosIphoneObjective CPush NotificationApple Push-Notifications

Ios Problem Overview


I am building an app that is heavily relies on APN. Upon the very first start of my app, iOS asks if this app is allowed to use APN (as a result of registerForRemoteNotificationTypes: call). However once dismissed, this dialog is never popping up back. I have to manually go to Settings->Notifications->MyApp to enable/disable things there. So is there a way to avoid this hustle and actually experience what user will experience upon the very first start every time I start my app in debug mode?

Ios Solutions


Solution 1 - Ios

Here's how Apple say you can do it:

> Resetting the Push Notifications Permissions Alert on iOS > > 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 you want to simulate a first-time run of your app, you can leave > the app uninstalled for a day. You can achieve the latter without > actually waiting a day by following these steps: > > 1. Delete your app from the device. > > 2. Turn the device off completely and turn it back on. > > 3. Go to Settings > General > Date & Time and set the date ahead a day or more. > > 4. Turn the device off completely again and turn it back on.

Solution 2 - Ios

Since time is money and the other methods take FOREVER—just change your bundle ID over and over while debugging, each time notifications will get queried fresh. Once you are satisfied with code return to original bundle ID.


Key Notes from comments below:

  • Temporarily turn off all other Capabilities (like IAP) to get around needing to change the provisioning profile.

Solution 3 - Ios

On iOS 9.x, you can get the prompt every time you delete the app and reinstall it. This is true for both AppStore production downloads and adhoc mode. The device token will be unique each time.

@chengsam verified this is true in iOS 10 as well. @WongWray verified this is true in iOS 11 as well.

Solution 4 - Ios

On IOS10 i can now get the prompt again by just deleting the app.

Solution 5 - Ios

Currently their is no programmatic way to prompt a user to re-accept Push Notificaitons after they have already decided to say no.

You should simply check if you have been granted access, and if not display a view reminding the user to manually give permission in the privacy settings in order to enable push notification features of your application.

Solution 6 - Ios

If you're just testing that the Push Notifications prompt appears correctly, use the simulator. All you need to do is uninstall the app and reinstall, and the prompt will appear again when you try to register for push notifications.

Solution 7 - Ios

My problem was not registering for UserNotificationSettings. This allowed the APN to work but not the background sound or badge.

      [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];

Solution 8 - Ios

From iOS 13 and above you need to do the whole changing-date-reset thing, as pointed out by Eran.

From iOS 12 and below, uninstalling the app is enough. This also works on simulator, you wont get token though since simulator does not support push notifications.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSchultz9999View Question on Stackoverflow
Solution 1 - IosEranView Answer on Stackoverflow
Solution 2 - IosAlbert RenshawView Answer on Stackoverflow
Solution 3 - IosGenkiView Answer on Stackoverflow
Solution 4 - IosDavid AanisView Answer on Stackoverflow
Solution 5 - IosWoodstockView Answer on Stackoverflow
Solution 6 - IosmofojedView Answer on Stackoverflow
Solution 7 - IosbuckleyJohnsonView Answer on Stackoverflow
Solution 8 - IosrgkobashiView Answer on Stackoverflow