iOS - Ask to enable push notifications after initial decline
Solution 1
You can't make iOS show the alert again. Here's a better approach:
- Keep a flag in your
NSUserDefaults
indicating whether you should register for push notifications at launch. By default the flag is false. - When you launch, check the flag. If it's true, register immediately. Otherwise, don't register.
- The first time the user does something that would cause a push notification, register for push notifications and set the flag in
NSUserDefaults
.
This way, when the user gets the push notifications alert, he has some idea why he's getting it, and might actually say yes.
Solution 2
I am also facing a similar kind of issue. After searching so much, I decided to do what you call Plan B. That is, show the user my own alert saying that push needs to be enabled for better experience, or something like that.
To check that required push types are enabled, use this method:
- (UIRemoteNotificationType)enabledRemoteNotificationTypes
I think that this is the clean solution. Consider a case where after accepting the request at first, the user turns off push, this thing will work even in that scenario.
Solution 3
The best way to do it would be to (if you're making a game) ask them a preemptive question (e.g. Do you want us to notify you when your crops are ready to be harvested? -Yes -No), and when they answer "yes", then fire the native iOS push popup. then you can layer in multiple questions along the user funnel, and you'll eventually catch them all.
Comments
-
Joel over 3 years
I would like to know if it's possible to force the "XXXXX would like to send you push notifications" popup from within an app, after an initial decline. The use case is as follows:
The user installs the app, gets the alert about push notifications, and declines because they don't know/trust the app yet.
They use the app and proactively request within the app to be alerted when something happens (say for example something they want to buy is sold out so they want to be alerted when it is back in stock).
So now the user has asked the app to notify them about something specific but has push notifications disabled at the operating system level.
So if the user requests an alert, but I detect that they declined alerts on first run, I need to notify them of this and have them turn push notifications on for the alert to work.
Ideally, I would like to force the "XXXX would like to send you push notifications alert" at this point (a second time since they installed the app).
I guess plan b would be to show them my own message telling them they have to go into their system settings and turn it back on manually in order to receive the alert they want. This is far from ideal.
Any help would be appreciated. Thanks.
-
Joel over 12 yearsThanks for the quick reply. I just came to the exact same conclusion after reading the answer in this post stackoverflow.com/questions/2438400/… (I searched repeatedly before posting but of course found the answer after posting). I wonder why almost all apps register at first launch? It seems like such a better model to register once the user has experienced the app.
-
Matej Balantič about 12 yearsActually, registering at first launch is a suggestion made in documentation: "An application should register every time it launches and give its provider the current token. /.../ By requesting the device token and passing it to the provider every time your application launches, you help to ensure that the provider has the current token for the device. If a user restores a backup to a device or computer other than the one that the backup was created for, he must launch the application at least once for it to receive notifications again."
-
rob mayoff about 11 yearsI have revised my answer to clarify that you should only defer registration if you don't have a reason to register at launch.
-
Jeff Bowen about 9 yearsIn iOS 8 you can check
[[UIApplication sharedApplication] isRegisteredForRemoteNotifications]
at app start and only register if it returnsYES
. Then you can show the prompt at any point you want. -
Arnaud about 9 yearsNot sure what PsychoDad meant, but you can test it by creating a new scheme and setting the Run Build Configuration to "Release".
-
Zorayr about 9 yearsWhat do you do after the user has accepted the preemptive question but has declined the system dialog?
-
Brian Sachetta almost 9 yearsThis is a good solution but to a different problem. Not exactly relevant to the original question.
-
guilherme.minglini over 8 yearsIt is deprecated on iOS8, look at this answer: stackoverflow.com/a/25197833/616032