acceptTakingInvitation method
Accept the seat invitation from the host. The context
parameter represents the Flutter context object.
Related APIs: ZegoLiveAudioRoomControllerSeatHostImpl.inviteToTake
Implementation
Future<bool> acceptTakingInvitation({
required BuildContext context,
bool rootNavigator = false,
}) async {
ZegoLoggerService.logInfo(
'acceptTakingInvitation, context:$context, rootNavigator:$rootNavigator',
tag: 'audio room',
subTag: 'controller.seat',
);
return ZegoUIKit()
.getSignalingPlugin()
.acceptInvitation(
inviterID: private.seatManager?.hostsNotifier.value.first ?? '',
data: '',
)
.then((result) async {
ZegoLoggerService.logInfo(
'accept host take seat invitation, result:$result',
tag: 'live audio',
subTag: 'controller.seat',
);
if (result.error != null) {
ZegoLoggerService.logInfo(
'accept host take seat invitation error: ${result.error}',
tag: 'live audio',
subTag: 'controller.seat',
);
return false;
}
return requestPermissions(
context: context,
isShowDialog: true,
innerText: private.seatManager?.innerText ??
ZegoUIKitPrebuiltLiveAudioRoomInnerText(),
rootNavigator: rootNavigator,
kickOutNotifier: ZegoLiveAudioRoomManagers().kickOutNotifier,
popUpManager: ZegoLiveAudioRoomManagers().popUpManager,
).then((_) async {
/// agree host's host, take seat, find the nearest seat index
return await private.seatManager
?.takeOnSeat(
private.seatManager?.getNearestEmptyIndex() ?? -1,
isForce: true,
isDeleteAfterOwnerLeft: true,
)
.then((result) async {
if (result) {
ZegoUIKit().turnMicrophoneOn(true);
}
return result;
}) ??
false;
});
});
}