# iCloud

Back up your end users device's key shares to iCloud.

This is how you set up iCloud backups in your iOS app.

1. Open your project in XCode.
2. Navigate to **Signing & Capabilities**.

3. Click the **+** button right below, scroll down, and select **iCloud**.

4. Under **iCloud Services**, select **Key-value storage**.

5. If you are using the React Native SDK add to your project:

```typescript
import {
  backupKeyset,
  CloudBackupOptions,
  BackupProvider,
} from '@fordefi/wallet-sdk-react-native';
```
6. Using for backup:


React Native

```
const backupOptions: CloudBackupOptions = {
  backupProvider: BackupProvider.iCloud,
};
const result = await backupKeyset(keysetId, backupOptions);
```

Swift

```
import FordefiSdk
import FordefiBackupCloudProvidersSdk

class ViewController: UIViewController {
   private var fordefi: Fordefi
   private let keysetID = "<KEYSET_ID>"

   override func viewDidAppear(_ animated: Bool) {
       ...
       FordefiBackupCloudProviders.getInstance().initialize(
            configuration: FordefiBackupCloudProvidersConfiguration())

        do {
           self.fordefi = try Fordefi.getInstance(configuration: FordefiConfiguration(
               baseURL: "https://api.fordefi.com"
           ))
        } catch let error {
           print("Failed to initialize Fordefi. Error: \(error.localizedDescription)")
           return
        }

        self.fordefi?.backupKeyset(keysetID: self.keysetID,
                backupCloudProvider: FordefiBackupCloudProvider.iCloud,
                completionHandler: { error in
        self.handleBackupKeyset(error: error)
       })
   }

	private func handleBackupKeyset(error: FordefiError?) {
        if error != nil {
            print("Faield to backup keyset. Error: \(error!.errorDescription!)")
            return
       }
   }
```