> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# @portal-hq/icloud-storage

> The @portal-hq/icloud-storage package contains a storage adapter intended for use with the @portal-hq/core package. This storage adapter allows end users to save backup MPC shares to their iCloud filesystem.

The `@portal-hq/icloud-storage` package contains a storage adapter intended for use with the `@portal-hq/core` package.

This storage adapter allows end users to save backup MPC shares to their iCloud filesystem.

***Note**: This storage provider is only supported on iOS devices, so should not be used as your sole backup storage adapter unless you are explicitly releasing an iOS-only app.*

***Note:** you will need a paid developer account to use iCloud backup*

### Basic usage

#### Install the package in your React Native project.

<Tabs>
  <Tab title="yarn">
    ```bash theme={null}
    yarn add @portal-hq/icloud-storage
    ```
  </Tab>

  <Tab title="npm">
    ```bash theme={null}
    npm install --save @portal-hq/icloud-storage
    ```
  </Tab>
</Tabs>

#### Import the package into the component where you initialize the Portal class

```typescript theme={null}
import Portal, { BackupMethods } from '@portal-hq/core'
import ICloudStorage from '@portal-hq/icloud-storage'
```

#### Register your storage adapter and initialize the Portal class

```typescript theme={null}
const portal = new Portal({
  // ...your other config options
  backup: {
    [BackupMethods.iCloud]: new ICloudStorage(),
  },
})
```

#### Check if the user is connected to iCloud

```typescript theme={null}
// Returns one of the following:
// "available", "not_signed_in", "no_access"
await portal.backup[BackupMethods.iCloud].getAvailability();
```

### Setting up iCloud Backups in your iOS app

1. Open your project in XCode.
2. Navigate to `Signing & Capabilities`:
3. Click the `+` Button right below it, scroll down and select `iCloud`.
4. Under iCloud Services select `Key-value storage`.
