join method

Future<void> join({
  1. required String token,
  2. required bool publish,
})

Joins the stage with Amazon's participant token, or leaves if already connected.

token must be the string from CreateParticipantToken (participantToken.token in the JSON response). It is not an IAM access key ID, secret access key, or session token.

publish controls whether this participant publishes camera + microphone (host-style) or is receive-only, subject to the capabilities encoded in the token.

Implementation

Future<void> join({required String token, required bool publish}) async {
  if (!ivsNativeStageSupported) {
    throw UnsupportedError(
      'IVS Real-Time native stage is only available on Android and iOS.',
    );
  }
  await _ensureMicrophonePermission();
  if (publish) {
    await _ensureCameraPermission();
  }
  try {
    await _channel.invokeMethod<void>('join', <String, Object?>{
      'token': token,
      'publish': publish,
    });
  } on PlatformException catch (e) {
    throw IvsStageException(e.message ?? e.code, e);
  }
}