Can CloudKit subscriptions not be created in code?
I've got 'dynamic' subscriptions that I need to create when the app runs and these cannot be pre-determined as they're based on some unique ID I generate temporarily for each device connecting. When running in development mode, CloudKit works perfectly however in Distribution mode I keep getting this error:
<CKError 0x1358436e0: "Invalid Arguments" (12/2006); server message = "attempting to create a subscription in a production container"; uuid = 41F4CA23-9849-40B1-8DB5-0030BBD91251; container ID = "iCloud.com.company.CloudKit">
Is there no way to create a subscription dynamically? I thought only RecordTypes needed to be created using the Dashboard.
You can definitely create subscriptions dynamically in the production environment of your CloudKit container. If you're using a query subscription for a specific record type, you'll need to make sure that the record type exists in production (in other words, that you've migrated your schema to production).
Keep in mind that the production environment is used in beta testing as well.
Debugging issues with CloudKit subscriptions, Q: My CloudKit subscriptions don't trigger notifications after relevant field that will be used in the subscription predicate, then tap the Run Code button. Note: You can't remove an iCloud container once it is created, thus� Create a query subscription to track record creations. On one device, run the CloudKit Catalog sample, go to Subscriptions > saveSubscription screen, set the subscriptionType to Query, input something in the name BEGINSWITH field that will be used in the subscription predicate, then tap the Run Code button.
The solution turned out to be something else. I was previously using the
saveSubscription method of the private database. This apparently kept giving me the above mentioned error. I ended up using
CKModifySubscriptionsOperation and this now works perfectly.
In my case I did have the subscription types setup in Production and also had everything else setup correctly. It was just the matter of using the above mentioned operations instead and that seems to have done the trick.
Unable to save a user specific subscription in CloudKit, I'm having an issue creating subscriptions in a public CloudKit database. The code works fine when saving the subscription for the first iCloud user but fails trying to "Unknown Item" (11/2003); server message = "did not find required record type: Why can't I save a 2nd subscription, from a 2nd user, for this record type? You can use the default zone to store your records but it’s also possible to create custom zones, both in the CloudKit dashboard or in code. Only the private database can have custom zones — they are not supported in the public database.
Looks like it is impossible to use TRUEPREDICATE for subscription in production container, it is true for both of methods (saveSubscription and CKModifySubscriptionsOperation). Just change predicate for get successful subscription.
Five Reasons CloudKit Notifications Are Not Arriving, Subscriptions are tied to users. Every user can create a subscription. This is important to keep in mind when debugging issues related to CloudKit� You can initially test subscriptions by running your app through Xcode and using CloudKit Dashboard to create, modify, or delete records, as described in Add, Modify, and Delete Records. Then fully test subscriptions by running your app on multiple devices. Use one device to make changes and another device to receive the subscription notifications.
The documentation by Apple on this is confusing, but every
CKQuerySubscription with a unique combination of a
Record Type and other undocumented elements like
NSPredicate, results in a new subscription type that must first exist in Development environment, and from there deployed in Production environment, before you can make a new subscription for a user using the same combination of elements.
An iOS 10 CloudKit Subscription Example, Specifically, CloudKit subscriptions can be used to notify the user when code to the project, a couple of configuration changes need to be made to the project to add By default, applications installed on a user's device will not be allowed to� CloudKit subscriptions use the iOS push notifications infrastructure to enable users to receive notifications when changes occur to the data stored in a cloud database. Specifically, CloudKit subscriptions can be used to notify the user when CloudKit based records of a specific record type are created, updated or deleted.
Delivering notifications with CloudKit push messages , Create a new UITableViewController subclass called We can split this code into two parts: all the bits that handle users selecting their experts You need to unwrap the optional array, because the user might not have any subscriptions. We are going to use CKQuerySubscription that can notify us when CloudKit records change. This can mean either record update, new record, deleted record.. There are basically two parts for getting this working for one direction. You need to create the subscription, save it to the iCloud and it will then be run automatically when changes happen
To get started creating a native CloudKit app and using the developer tools, read CloudKit Quick Start. To create a web app, see CloudKit JS Reference or CloudKit Web Services Reference. Enabling CloudKit. Before you can use CloudKit, you must enable your app’s target in the Xcode project to use iCloud and CloudKit.
CloudKit subscriptions use the iOS push notifications infrastructure to enable users to receive notifications when changes occur to the data stored in a cloud database. Specifically, CloudKit subscriptions can be used to notify the user when CloudKit based records of a specific record type are created, updated or deleted.
- So what does Apple mean when they say
Subscriptions must be created in the Development environment first and then promoted to Production. Attempting to create a subscription directly in the Production environment will result in an error.on this page: developer.apple.com/documentation/cloudkit/cksubscription? I'm hopefully I can still use
CKModifySubscriptionsOperationagainst a production environment since my subscriptions are changeable by the user.
- There are subscriptions and "subscription types". What Apple meant to write in developer.apple.com/documentation/cloudkit/… is: "Subscription types must be created in the Development environment first and then promoted to Production. Attempting to create a subscription type directly in the Production environment will result in an error."