I am trying to set up Cloudkit-JS to access an existing Cloudkit database through a web browser. The db itself works fine and I have an iOS app which connects to the db without any problems.
I've generated an API Token in the Cloudkit Dashboard and I've set it to allow any domain. I don't know if its significant but I'm trying to get this working through a local html file. It's not running on a web server.
CloudKit.configure({
containers: [{
containerIdentifier: 'iCloud.com.[My App]',
apiToken: '[API Token]',
environment: 'development'
}]
});
var container = CloudKit.getDefaultContainer();
The call to getDefaultContainer() triggers the following error message in the browser console.
ckErrorCode: CONFIGURATION_ERROR
extensionErrorCode: undefined
isCKError: true
isError: true
isServerError: true
isServerExtensionError: true
message: CONFIGURATION_ERROR: Please configure CloudKit
name: Error
reason: CONFIGURATION_ERROR: Please configure CloudKit
recordName: undefined
redirectURL: undefined
retryAfter: undefined
serverErrorCode: undefined
subscriptionID: undefined
uuid: undefined
zoneID: undefined
]
getDefaultContainer (cloudkit.js:12:1146)
Global Code (index.html:29)
Any ideas on what to try next?
Turns out to be a rookie error. I was trying to call getDefaultContainer() before the authentication had completed asynchronously.