An open API service indexing awesome lists of open source software.

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

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`:
![](https://github.com/lukasandreano/capacitor-cloudkit-api/blob/main/docs/icloud.png?raw=true)

Next, enable `Key-value storage` and `CloudKit` settings, and create any container by clicking on `+` button:
![](https://github.com/lukasandreano/capacitor-cloudkit-api/blob/main/docs/cloudkit-settings.png?raw=true)

## 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; }>

--------------------