Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nkalupahana/capacitor-cloudkit
Basic CloudKit web authentication plugin for getting ckWebAuthToken on all platforms.
https://github.com/nkalupahana/capacitor-cloudkit
capacitor typescript
Last synced: 2 months ago
JSON representation
Basic CloudKit web authentication plugin for getting ckWebAuthToken on all platforms.
- Host: GitHub
- URL: https://github.com/nkalupahana/capacitor-cloudkit
- Owner: nkalupahana
- Created: 2022-05-06T21:01:41.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-05T04:15:40.000Z (7 months ago)
- Last Synced: 2024-10-06T16:15:46.385Z (3 months ago)
- Topics: capacitor, typescript
- Language: Java
- Homepage: https://www.npmjs.com/package/capacitor-cloudkit
- Size: 354 KB
- Stars: 3
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# capacitor-cloudkit
Basic CloudKit authentication plugin. v1 is Capacitor 4, v2 is Capacitor 5, v3 is Capacitor 6.
## Install
```bash
npm install capacitor-cloudkit
npx cap sync
```## Setup
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 to `cloudkit-icloud.baseline.getbaseline.app://callback`.
- Android: Token configured to redirect to `https://example.com` or 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] = [:]) -> Bool` in `AppDelegate`:```swift
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)
* [`fetchRecord(...)`](#fetchrecord)
* [Interfaces](#interfaces)### authenticate(...)
```typescript
authenticate(options: SignInOptions) => Promise<{ ckWebAuthToken: string; }>
```| Param | Type |
| ------------- | ------------------------------------------------------- |
| **`options`** |SignInOptions
|**Returns:**
Promise<{ ckWebAuthToken: string; }>
--------------------
### fetchRecord(...)
```typescript
fetchRecord(options: FetchRecordOptions) => Promise
```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
|