capacitor-cloudkit
v4.0.0
Published
Basic CloudKit authentication plugin.
Readme
capacitor-cloudkit
Basic CloudKit authentication plugin.
- v1: Capactior 4
- v2: Capacitor 5
- v3: Capacitor 6
- v4: Capacitor 7
Install
npm install capacitor-cloudkit
npx cap syncSetup
Each different platform requires a different ckAPIToken.
- Web: Token configured for
postMessage. - iOS: Token configured to redirect to your container's URL scheme. It'll show up on the CloudKit dashboard in a dropdown when you create an API key. Mine is
cloudkit-icloud.baseline.getbaseline.app://, so I'll be using that as an example. I set mine tocloudkit-icloud.baseline.getbaseline.app://callback. - Android: Token configured to redirect to
https://example.comor some similar existant but blank domain.
Setup (iOS)
- Add your callback URL as a URL scheme in your app, in the Info tab. (e.g.
cloudkit-icloud.baseline.getbaseline.app) - Add the following to the beginning of
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> BoolinAppDelegate:
if (url.scheme == "PUT CALLBACK URL SCHEME HERE (e.g. cloudkit-icloud.baseline.getbaseline.app)") {
NotificationCenter.default.post(name: NSNotification.Name("cloudkitLogin"), object: url);
}API
authenticate(...)
authenticate(options: SignInOptions) => Promise<{ ckWebAuthToken: string; }>| Param | Type |
| ------------- | ------------------------------------------------------- |
| options | SignInOptions |
Returns: Promise<{ ckWebAuthToken: string; }>
fetchRecord(...)
fetchRecord(options: FetchRecordOptions) => Promise<any>Only available on iOS.
| Param | Type |
| ------------- | ----------------------------------------------------------------- |
| options | FetchRecordOptions |
Returns: Promise<any>
Interfaces
SignInOptions
| Prop | Type |
| ------------------------- | ------------------------------------------ |
| containerIdentifier | string |
| environment | 'development' | 'production' |
| ckAPIToken | string |
FetchRecordOptions
| Prop | Type |
| ------------------------- | ---------------------------------------------- |
| containerIdentifier | string |
| database | 'private' | 'public' | 'shared' |
| by | 'recordName' |
| recordName | string |
