Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/pages/chat-apps/core-messaging/create-a-client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ The `dbEncryptionKey` client option is not used by the Browser SDK for due to te

To learn more about database operations, see the [XMTP MLS protocol spec](https://github.com/xmtp/libxmtp/blob/main/xmtp_mls/README.md).

### Database encryption key loss during iOS device transfers

When you transfer data to a new iOS device, the local database file may be moved without the encryption key, causing decryption errors. This commonly occurs when users choose Apple's direct transfer option during new device setup, as Apple aggressively moves files to the new device. To prevent this issue, exclude the database directory from backups and device transfers.

For example, if you set a custom `dbPath` to a known directory, you can mark it as excluded from backups in iOS:

```swift
func addSkipBackupAttribute(var folder: URL) throws {
try folder.setResourceValue(true, forKey: .isExcludedFromBackupKey)
}
```

To learn more about this function, see [isExcludedFromBackupKey](https://developer.apple.com/documentation/foundation/urlresourcekey/isexcludedfrombackupkey) in Apple's documentation.

### View an encrypted database

For debugging, it can be useful to decrypt a locally stored database. When a `dbEncryptionKey` is used, the XMTP client creates a [SQLCipher database](https://www.zetetic.net/sqlcipher/) which applies transparent 256-bit AES encryption. A `.sqlitecipher_salt` file is also generated alongside the database.
Expand Down