简体   繁体   English

注册Apple推送通知

[英]Register for Apple Push Notifications

My question is I used the following code: 我的问题是我使用了以下代码:

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

in

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

But it never shows the alert asking the user if he want to receive push notifications. 但它从未显示警告,询问用户是否要接收推送通知。

I configured my provisioning profile on App ID for push notifications enabled for development. 我在App ID上配置了配置文件,以便为开发启用推送通知。 I downloaded the certificate and provisioning profile and added it, and then, running on iPad mini I never receive the alert. 我下载了证书和配置文件并添加了它,然后,在iPad mini上运行我从未收到警报。 What I am doing wrong? 我做错了什么?

这是一个很棒的教程,你只需要知道: http//www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12

Did you receive the alert to ask if you authorised push once? 您是否收到警报询问您是否授权推送一次? I've noticed that after the first time it will not ask again. 我注意到在第一次之后它不会再问。 If this is the case completely remove the app from your device and you might see it again the first time you start up. 如果是这种情况,请从您的设备中完全删除应用,并在第一次启动时再次看到它。

Personally I would recommend using Parse.com or Urban Airship for push - both are very good. 我个人建议使用Parse.com或Urban Airship进行推送 - 两者都非常好。

Ok, given the error you got in the fail callback, it may be a problem with the certificate. 好的,鉴于您在失败回调中遇到的错误,它可能是证书的问题。

Do the following: 请执行下列操作:

  • In the iOS provisioning portal, check that you have an App Id that is enabled for push notifications 在iOS配置门户中,检查您是否具有为推送通知启用的应用ID
  • Still in the provisioning portal, check that the povisioning profile you are using is connected to the App Id enabled for push notification 仍在配置门户中,检查您正在使用的配置文件是否已连接到为推送通知启用的应用程序ID
  • In you project, check whether the Code Signing Identity you for the current target use the right profile 在您的项目中,检查当前目标的代码签名标识是否使用正确的配置文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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