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

邮差的信 提交于 2019-12-03 00:18:10

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

Jamon Holmgren

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!