Skip to content

Releases: xmtp/xmtp-react-native

v1.22.0

08 Dec 02:00
8a3d762
Compare
Choose a tag to compare

1.22.0 (2023-12-08)

Features

  • update all consent entries to be returned (c25bd23)

v1.21.0

02 Dec 01:36
5ea4174
Compare
Choose a tag to compare

1.21.0 (2023-12-02)

This release introduces support for custom content types and a breaking change to message content.

Custom content types

React Native now supports custom codecs, enabling you to send any type of content that makes sense for you and your app.

Important: Your custom content type WILL NOT automatically be supported by other apps. Other apps will display the fallback text defined in your custom codec instead.

First, create a custom codec and be sure to include fallback text:

const ContentTypeNumber: ContentTypeId = {
  authorityId: 'xmtp.org',
  typeId: 'number',
  versionMajor: 1,
  versionMinor: 0,
}

class NumberCodec implements JSContentCodec<number> {
  contentType = ContentTypeNumber

  // a completely absurd way of encoding number values
  encode(content: number): EncodedContent {
    return {
      type: ContentTypeNumber,
      parameters: {
        number: JSON.stringify(content),
      },
      content: new Uint8Array(),
    }
  }
  decode(encodedContent: EncodedContent): number {
    return JSON.parse(encodedContent.parameters.number) as number
  }

  fallback(content: number): string | undefined {
    return 'A number was sent.'
  }
}

Then, when spinning up a client, instantiate the custom codec and register it.

const client = await Client.create({
    env: 'production',
    codecs: [new NumberCodec()],
  })

Now you can encode, send, and decode messages using your custom content type by passing in an optional SendOptions.

await conversation.send(12, { contentType: ContentTypeNumber })

Breaking change

XMTP used to register supported codecs for you by default. Now you must register all codecs you’d like to support manually on client create.

const client = await Client.create(wallet, {
    env: 'production',
    codecs: [new XMTP.ReactionCodec(), new XMTP.ReplyCodec(), new XMTP.ReadReceiptCodec(), new XMTP.RemoteAttachmentCodec(), new XMTP.StaticAttachmentCodec()],
  })

Because of this message content is now a function which returns the actual content. You can get that content by call message.content() now instead of message.content . This may involve more filtering on the message side to make sure you are handling different contentTypes appropriately.

For a list of defined content types, see Native Codecs.

Features

  • fix up small code issues (6798b64)

What's Changed

New Contributors

Full Changelog: v1.20.2...v1.21.0

v1.20.2

24 Nov 16:13
22b79fa
Compare
Choose a tag to compare

1.20.2 (2023-11-24)

Bug Fixes

v1.20.1

13 Nov 21:51
9138b40
Compare
Choose a tag to compare

1.20.1 (2023-11-13)

Bug Fixes

v1.20.0

08 Nov 03:15
f1e74ef
Compare
Choose a tag to compare

1.20.0 (2023-11-08)

Features

  • allow numeric timestamp in listMessages (98de258)

v1.19.2

07 Nov 21:36
7111dd1
Compare
Choose a tag to compare

1.19.2 (2023-11-07)

Bug Fixes

  • upgrade to the latest android for stream performance (4693ea7)

v1.19.1

03 Nov 19:51
5f34ecc
Compare
Choose a tag to compare

1.19.1 (2023-11-03)

Bug Fixes

  • bump android version for message load performance (fde1841)

v1.19.0

02 Nov 21:00
cb62530
Compare
Choose a tag to compare

1.19.0 (2023-11-02)

Features

  • add fallback types to content types (c944481)

v1.18.1

01 Nov 22:38
31bdfec
Compare
Choose a tag to compare

1.18.1 (2023-11-01)

Bug Fixes

  • update the wording around consent (0c27d52)

v1.18.0

26 Oct 22:56
d9072c3
Compare
Choose a tag to compare

1.18.0 (2023-10-26)

Features

  • add the swift side of PPPP (cb49145)