joinWithToken method

  1. @override
Future<ChatResult<InviteResult>> joinWithToken(
  1. String roomId, {
  2. required String token,
})
override

Joins the current user to a public room using an invitation token.

The growth-link counterpart of invite: where invite adds other users, this self-joins the authenticated user to roomId presenting the room's public token (the publicToken the backend returns when a public/invitable room is created, carried on ChatRoom.publicToken). Convenience wrapper over invite(roomId, userIds: [self], mode: inviteAndJoin, token: token).

Wire it to a deep-link handler: parse the incoming link with ChatInviteLink.tryParse and call this with the extracted room id and token. The backend still gates the join on ban/audience, so the returned InviteResult may report a per-user failure even on a 2xx.

final link = ChatInviteLink.tryParse(incomingUri);
if (link != null) {
  await client.members.joinWithToken(link.roomId, token: link.token);
}

Implementation

@override
Future<ChatResult<InviteResult>> joinWithToken(
  String roomId, {
  required String token,
}) => invite(
  roomId,
  userIds: [_client.currentUserId],
  mode: RoomUserMode.inviteAndJoin,
  token: token,
);