Skip to content

Commit

Permalink
Merge branch 'custom-content-types' of https://github.com/xmtp/xmtp-r…
Browse files Browse the repository at this point in the history
…eact-native into custom-content-types
  • Loading branch information
nakajima committed Nov 30, 2023
2 parents bf95df0 + bbea7f9 commit db7e361
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,22 @@ The SDK preregisters the following codecs:
});
```

### Using custom content types

```tsx
import { Client } from '@xmtp/xmtp-react-native'
// Create the client with a `Signer` from your application and specify any custom codecs
const xmtp = await Client.create(wallet, { env: 'production', codecs: [new CustomCodec()]})
// Register the custom codec so you can encode and decode it
xmtp.register(new CustomCodec())
// Use the content type name from you custom codec when sending messages with them
await conversation.send(<CUSTOMCONTENT>, { contentType: ContentTypeCustom })
```

To learn more about how to build a custom content type, see [Build a custom content type](https://xmtp.org/docs/content-types/introduction#create-custom-content-types).

Custom codecs and content types may be proposed as interoperable standards through XRCs. To learn about the custom content type proposal process, see [XIP-5](https://github.com/xmtp/XIPs/blob/main/XIPs/xip-5-message-content-types.md).

## Manually handle private key storage

The SDK will handle key storage for the user by encrypting the private key bundle using a signature generated from the wallet, and storing the encrypted payload on the XMTP network. This can be awkward for some server-side applications, where you may only want to give the application access to the XMTP keys but not your wallet keys. Mobile applications may also want to store keys in a secure enclave rather than rely on decrypting the remote keys on the network each time the application starts up.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/NativeCodecs/ReadReceiptCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export class ReadReceiptCodec
}

fallback(content: object): string | undefined {
return 'read'
return undefined
}
}

0 comments on commit db7e361

Please sign in to comment.