CloudKit + no valid aps-environment entitlement error

629 views Asked by At

I try to use CloudKit subscriptions in my app, but didReceiveRemoteNotification not get triggered.

I saved CKSubscription to CloudKit. To be sure they exists, when app starts, I plot them out, like:

<CKSubscription: 0x15576310; ; Query Subscription: recordType=DailyVote, predicate=TRUEPREDICATE, subscriptionOptions=7, subscriptionID=1FA456A6-9BA5-411D-97B9-1EB57121A5D0, zoneID=(null)> predicate: TRUEPREDICATE subscriptionType: (Enum Value) subscriptionOptions: C.CKSubscriptionOptions

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 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.
2

There are 2 answers

0
János On BEST ANSWER

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.

If you add Push Notification in Developer Portal under App IDs it will work, or at least for second try for me it worked.

0
Geet On

the error mostly prompts that, the provisioning profile, which you have used, does not support the aps-environment, make sure that you refresh the provisioning profile after you have made modification in your app id,

try this out, open your Provisioning profile in a text editor and search for the following,

aps-environment

if you dont find this, then the problem is provisioning profile associated,if it does then try this out..

How to fix "no valid 'aps-environment' entitlement string found for application" in Xcode 4.3?