capacitor-cloudkit-api
v1.0.0
Published
Plugin for using CloudKit Key-Value API in Capacitor Apps
Downloads
11
Maintainers
Readme
capacitor-cloudkit-api
Plugin for using Apple CloudKit Key-Value API in your Capacitor Apps.
Install
npm install capacitor-cloudkit-api
npx cap sync
Preparation
Add capability in Signing & Capabilities
in Xcode project settings called iCloud
:
Next, enable Key-value storage
and CloudKit
settings, and create any container by clicking on +
button:
Usage
import {CapacitorCloudkitAPI} from 'capacitor-cloudkit-api';
const saveData = async (key: string, value: string): Promise<{
key: string;
value: string;
}> => {
const result = await CapacitorCloudkitAPI.saveKeyValue({
key,
value,
});
return result
}
const getData = async (key: string): Promise<{
key: string;
value: string;
}> => {
const result = await CapacitorCloudkitAPI.getKeyValue({
key
});
return result
}
API
saveKeyValue(...)
saveKeyValue(options: { key: string; value: string; }) => Promise<{ key: string; value: string; }>
| Param | Type |
| ------------- | -------------------------------------------- |
| options
| { key: string; value: string; } |
Returns: Promise<{ key: string; value: string; }>
getKeyValue(...)
getKeyValue(options: { key: string; }) => Promise<{ key: string; value: string; }>
| Param | Type |
| ------------- | ----------------------------- |
| options
| { key: string; } |
Returns: Promise<{ key: string; value: string; }>