CloudKit + 没有有效的 aps-environment 权利错误 [英] CloudKit + no valid aps-environment entitlement error
问题描述
我尝试在我的应用中使用 CloudKit
订阅,但 didReceiveRemoteNotification
没有被触发.
I try to use CloudKit
subscriptions in my app, but didReceiveRemoteNotification
not get triggered.
我将 CKSubscription
保存到 CloudKit
.为了确保它们存在,当应用程序启动时,我将它们绘制出来,例如:
I saved CKSubscription
to CloudKit
. To be sure they exists, when app starts, I plot them out, like:
我尝试在 APN 服务器上注册我的设备,如 apple doc 推荐,但错误委托方法被调用,并带有消息:
I try to register my device at APN server, as apple doc recommend, but error delegate method get called, with message:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: .Alert, categories: nil))
application.registerForRemoteNotifications()
return true
}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
println("error: \(error.localizedDescription)")
//error: no valid aps-environment entitlement found for application
}
CloudKit
功能开启- 我没有无效的配置文件
- 我已经做到了:
Xcode
>Preferences
>Accounts
>pick your Account
>选择你的团队
>查看详情
>PRESS REFRESH BUTTON
- 我什至用新的 iCloud Container 创建了一个新应用,移动了所有逻辑,但错误是一样的,订阅通知不起作用.
CloudKit
capability is on- I have no invalid provision profile
- I have done the trick:
Xcode
>Preferences
>Accounts
>pick your Account
>pick your Team
>View Details
>PRESS REFRESH BUTTON
- I even created a fresh App, with new iCloud Container, moved all the logic, but the error is the same and subscription notification does not work.
推荐答案
即使 Apple Doc 说 此处:您无需在会员中心接收订阅通知.当您启用 CloudKit 时,Xcode 会自动将 APNs 授权添加到您的授权文件中.
Even though Apple Doc says here: You don’t need to enable push notifications for the app’s explicit App ID in Member Center to receive subscription notifications. Xcode automatically adds the APNs entitlement to your entitlement file when you enable CloudKit.
如果您在 App IDs
下的 Developer Portal
中添加 Push Notification
它将起作用,或者至少对我来说第二次尝试它起作用了.
If you add Push Notification
in Developer Portal
under App IDs
it will work, or at least for second try for me it worked.
这篇关于CloudKit + 没有有效的 aps-environment 权利错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!