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

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];  

Answers


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


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.


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;
}

Resetting the Push Notifications Permissions Alert on iOS

For the first time a push-enabled applications, registers for push notifications. iOS asks the user if they wish to receive remote notifications for that particular app. Once the user has responded to this alert it is not presented again and 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.

For more details check this out.


Make sure you call this method at your AppDelegate's didFinishLaunchingWithOptions

 [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
 UIRemoteNotificationTypeBadge | 
 UIRemoteNotificationTypeAlert | 
 UIRemoteNotificationTypeSound]; 

so that everytime the app will ask for Notifications

also check with your device settings to check notifications are turned on or not?


all you have to do is remove one of the notification methods from your register code and it will ask you again to allow notifications (for example remove UIRemoteNotificationTypeSound)


To make our app ask it again and again.. call

[[UIApplication sharedApplication] unregisterForRemoteNotifications];

first. Then call

 [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
 UIRemoteNotificationTypeBadge | 
 UIRemoteNotificationTypeAlert | 
 UIRemoteNotificationTypeSound]; 

Hope that helps. Thanks.


Need Your Help

HTML input covering A attribute

javascript php jquery html ajax

I have a search bar that usiing AJAX to bring up results, but the input box covers the first result rendering it unclickable (you can see it, you just can't click on it), I've tried everything but i

What is Closure Compiler?

javascript

If you have no idea what I am talking about, check this out: http://closure-compiler.appspot.com/home (it's a JavaScript minifier)