how to make iPhone app asks to register device for push notification multiple times

10,522

Solution 1

Theres a notification option in the settings. Check out your application and turn on the notification from there.

I have learned somewhere that iOs 4 has this bug that it wont ask again even if youremove and reinstall the application.

Try Settings->Notifications-> your app-> Turn it on.

Hope it helps. Thanks

Solution 2

Apple's recommended way to reset the notification

During development only, of course.

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:

Delete your app from the device. Turn the device off completely and turn it back on. Go to Settings > General > Date & Time and set the date ahead a day or more. Turn the device off completely again and turn it back on.

Don't forget to turn it off completely and back on.

Solution 3

It seems like the question was never fully answered so here it is:

You can't make the built in prompt that actually changes the setting come up, but you can manually check if push notifications are currently enabled for your app and display your own alert if now. Here is what the function I use looks like:

+ (BOOL) arePushNotificationsEnabled 
{
    return [[UIApplication sharedApplication] enabledRemoteNotificationTypes] != UIRemoteNotificationTypeNone;
}
Share:
10,522

Related videos on Youtube

Mike
Author by

Mike

Updated on June 01, 2022

Comments

  • Mike
    Mike about 2 years

    I have used the following code to register my app to receive push notification, and I got the alert that asks me to register for push notification and I accidentally press cancel. Now I want to have the alert again so I can fire the delegate method in order to get the device token. But I don't get this alert any more and every time I open the settings I found that the notification is turned off for the app. I tried to delete the app from device, change app version, delete testing profile ,clean the target even I reset all the iPhone settings, but still was not able to solve this.I would very much appreciate any help, thanks

    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
         UIRemoteNotificationTypeBadge | 
         UIRemoteNotificationTypeAlert | 
         UIRemoteNotificationTypeSound];  
    
  • Mike
    Mike about 13 years
    If I turned on the notification from the settings it won't call the mentioned code as it will find that the app is already enable for push notification and won't call delegate method - (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken
  • Mike
    Mike about 13 years
    my notification setting is turned on in iPhone and I already call this code. But the iPhone remembers that I canceled the push notification alerts each time I run the app. And so I can not get the alert to enable notification again.
  • Suresh Varma
    Suresh Varma about 13 years
    dats y i told its a bug with iOs 4 and above... dont think it would be possible to do it
  • Suresh Varma
    Suresh Varma about 13 years
    yeah maybe.. but u can give it a try :)
  • Jamon Holmgren
    Jamon Holmgren over 11 years
    This doesn't actually work. Unregistering and reregistering doesn't ask the user any more than uninstalling and reinstalling does.
  • Jamon Holmgren
    Jamon Holmgren over 11 years
    Unfortunately, I haven't been able to get this to work in iOS 6. Apple's documentation appears to be wrong.
  • Resh32
    Resh32 over 11 years
    Same for me, had to completely reset (erase) the iPod touch on iOS 6 for the notification to reset - really painful.
  • Jamon Holmgren
    Jamon Holmgren over 10 years
    Apple modified their instructions and I've updated my answer with the update. It looks like the addition is that you need to restart completely after uninstalling the app.
  • Gik
    Gik over 9 years
    OK, if that does not work, what does work (programmatically)? Because if the user taps NO (on the allow alert), how can my app ask him again? Just re-registering (as mentioned) does not work. So what is the solution?