Using a CKSubscription from CloudKit to listen for updates and changes on the database and receiving silent notifications works fine on Development but once in Production it doesn't work at all.
Trying to save a CKSubscription
on a CKDatabase
using save(_:completionHandler:) throws the error:
<CKError 0x600001eab3f0: "Invalid Arguments" (12/2006); server message = "attempting to create a subscription in a production container"; op = F4A51E76AB7CBA90; uuid = FF807DA3-0BAC-4B99-A653-E26EE35DC95F; container ID = "iCloud.my.cool.app.42">
On the CloudKit Dashboard (the web interface) logs the subscriptions are working fine on development but on production they have the error: BAD_REQUEST
for the log type: subscription modify
.
Right on the documentation it says:
Note
Create subscriptions in the development environment first and then promote them to production. Attempting to create a subscription directly in the production environment results in an error.
So first I need to create it on development and then promote it for production, ok, but how?
I couldn't find much clarification on the documentation, but reading some useful posts and blogs, including this one from Filip Němeček, they point out that this is done on the CloudKit Dashboard.
The process should be quite simple:
CKSubscription
on development (using just the simulator works fine).The problem is that point 3
doesn't work for me, there is no new subscription appearing under Subscriptions on the Dashboard.
How can I promote the subscription to production?
Reading more comments on forums folks mention you can only see subscriptions on CloudKit dashboard created by the active account logged on the dashboard, I'm using a Sandbox Account for testing.
There is a button on CloudKit Dashboard to help with this: Act As iCloud Account…
. But the functionality is very limited once you activate it. Also this was not an alternative for me.
I found out that if you create a CKSubscription
on the development environment (and it succeeds, without throwing errors) this will be ready for promoting, even if you can't see it on the dashboard.