iOS:如何注册推送通知?

dhr*_*hrm 10 objective-c apple-push-notifications ios

我正试图通过Ray Wenderlich的指南为我的iOS 5应用程序实现推送通知:http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12 .

didFinishLaunchingWithOptions在我的AppDelegate 中将以下内容插入到我的方法中:

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
    (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
Run Code Online (Sandbox Code Playgroud)

在我的设备(而不是模拟器)上运行应用程序时,不显示告诉我接受推送通知的弹出/警报.我在线上插入了一个调试点,我可以看到,registerForRemoteNotificationTypes调用了它.

为什么没有发生?

YuA*_*uAo 7

也许,删除您的应用并重试.该对话框只出现一次.但我不确定重新安装该应用程序时是否会再次出现该对话框.

您还可以转到通知中心的设置应用,查看您的应用是否在列表中.

您还可以添加断点,并查看didRegisterForRemoteNotificationsWithDeviceToken是否执行.

  • 感谢您的答复.问题是我在为证书启用推送通知后必须重新生成我的配置文件. (3认同)
  • 我经历了同样的事情并遇到了同样的问题.我认为Apple假定程序员也是加密证书的专家.此外,永远不要使用通配符ID进行推送服务. (2认同)