简体   繁体   中英

iOs Push notifications, don't get alert asking for authorization

I hope you can help me troubleshoot my issue.
When I install my app, I don't get the message alert asking for the authorization to get push notifications.
I am thinking that if I don't get this message it's not my code to be wrong, but maybe it's a matter of certificates.
Am I right? How can I check if my provisioning file is correct?
I am using Xcode 5 and testing on ios7.0.2
I add a little more: I was never able to get the alert working

I had this issue when developing an app, it turned out I'd not set the entitlements up correctly. So make sure you have in your AppDelegate :

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

Make sure in Developer Center you've generated an AppID for your application as well, specifying that you want to use Push Notifications . Then you need to generate a Provisioning Profile to use for development/deployment with the device ID you want to install it on. Then you need to bring that Provisioning Profile into Xcode, and apply it to your project within the target build settings . That should bring up the Push Notification alert view to get the permission for the app to use push notifications. You then get the fun of setting up the SSL certificates but that's a whole other topic.

I found the Ray Wenderlich Push Notification Tutorial incredibly helpful when I went through it, I'd recommend following through if you're finding yourself stuck.

Edit; also keep in mind Push Notifications do not work on the Simulator , you must test them against an actual device as you won't see the alert view at all on the Simulator .

If you accept or decline it once this screen would not appear again. Go to setting and check permission for push notifications for your app.

Settings->Notifications->YOUREAPP

In order to see the alertView:

  1. uninstall the app
  2. set the device date to at least 1 day after the current date
  3. Reboot the device
  4. Install and launch the app

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM