我在装有 iOS 8 的 iPhone 5 上设置推送通知时遇到错误:
2015-04-29 00:23:14.688 pushNotificationTest[192:6284] Did Fail to Register for Remote Notifications 2015-04-29 00:23:14.698 pushNotificationTest[192:6284] Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x15e89820 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}, no valid 'aps-environment' entitlement string found for application Message from debugger: failed to send the k packet
我使用这个链接来实现它
http://code.tutsplus.com/tutorials/setting-up-push-notifications-on-ios--cms-21925
我已经在这个链接上尝试了不同人提供的这些解决方法:
Getting an error from push notification
我用来注册的代码
UIUserNotificationSettings *settings=[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
最佳答案
确保在Build Settings中,用于调试的Code Signing Identity设置为正确的Provisioning Profile
您在其中启用了推送通知。
您不必删除或重新创建任何内容。您只需让 Xcode 更新您的事件证书(包括新的推送通知证书)。
只需转至 Xcode > 首选项 > 帐户 > 选择您的帐户 > 选择您的团队 > 查看详细信息
点击左下角的刷新按钮。 (同时检查build设置中的代码签名)
要创建证书和配置文件,请遵循这个很棒的 Tutorial
关于ios - 注册远程推送通知失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29936975/