https://github.com/lukasandreano/capacitor-cloudkit-api
A capacitor plugin for using CloudKit Key-value APIs in Capacitor Apps
https://github.com/lukasandreano/capacitor-cloudkit-api
capacitor cloudkit cloudkit-api ios
Last synced: 12 months ago
JSON representation
A capacitor plugin for using CloudKit Key-value APIs in Capacitor Apps
- Host: GitHub
- URL: https://github.com/lukasandreano/capacitor-cloudkit-api
- Owner: LukasAndreano
- Created: 2024-06-20T13:41:01.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-20T13:42:18.000Z (almost 2 years ago)
- Last Synced: 2025-04-07T12:49:31.308Z (about 1 year ago)
- Topics: capacitor, cloudkit, cloudkit-api, ios
- Language: Swift
- Homepage: https://npmjs.com/package/capacitor-cloudkit-api
- Size: 987 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# capacitor-cloudkit-api
Plugin for using [Apple CloudKit Key-Value API](https://developer.apple.com/documentation/cloudkit/) in your Capacitor Apps.
## Install
```bash
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
```typescript
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)
* [`getKeyValue(...)`](#getkeyvalue)
### saveKeyValue(...)
```typescript
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(...)
```typescript
getKeyValue(options: { key: string; }) => Promise<{ key: string; value: string; }>
```
| Param | Type |
| ------------- | ----------------------------- |
| **`options`** | { key: string; } |
**Returns:** Promise<{ key: string; value: string; }>
--------------------