Migration_v3.x topic

This document aims to help users understand the APIs changes and feature improvements, and provide a migration guide for the upgrade process.


It is an incompatible change if marked with breaking changes. All remaining changes is compatible and uses the deprecated prompt. Of course, it will also be completely abandoned in the version after a certain period of time.


You can run this command in the root directory of your project to output warnings and partial error prompts to assist you in finding deprecated parameters/functions or errors after upgrading.

dart analyze | grep zego


Versions



3.5.3


Introduction

In this migration guide, we will explain how to upgrade from version 3.5.2 to the latest 3.5.3 version.

Major Interface Changes

  • ZegoUIKitPrebuiltLiveStreamingController
    • rename user.addFake to user.addFakeUser
    • rename user.removeFake to user.removeFakeUser


3.5.0


Introduction

In this migration guide, we will explain how to upgrade from version 3.4.+ to the latest 3.5.0 version.

Major Interface Changes

  • ZegoUIKitPrebuiltLiveStreamingController
    • move room.addFakeUser to user.addFake
    • move room.removeFakeUser to user.removeFake


3.4.0


Introduction

In this migration guide, we will explain how to upgrade from version 3.3.0 to the latest 3.4.0 version.

Major Interface Changes

  • ZegoUIKitPrebuiltLiveStreamingConfig
    • move maxCoHostCount to coHost.maxCoHostCount
    • move stopCoHostingWhenMicCameraOff to coHost.stopCoHostingWhenMicCameraOff
    • move disableCoHostInvitationReceivedDialog to coHost.disableCoHostInvitationReceivedDialog
    • move turnOnCameraWhenCohosted to coHost.turnOnCameraWhenCohosted

3.3.0


Introduction

In this migration guide, we will explain how to upgrade from version 3.2.0 to the latest 3.3.0 version.

Major Interface Changes

  • ZegoLiveStreamingPKBattleConfig
    • rename pKBattleViewTopPadding to topPadding
    • rename pkBattleViewTopBuilder to topBuilder
    • rename pkBattleViewBottomBuilder to bottomBuilder
    • rename pkBattleViewForegroundBuilder to foregroundBuilder



3.1.7


Introduction

In this migration guide, we will explain how to upgrade from version 3.1.6 to the latest 3.1.7 version.

Major Interface Changes

  • rename ZegoInnerText to ZegoUIKitPrebuiltLiveStreamingInnerText
  • rename ZegoMenuBarButtonName to ZegoLiveStreamingMenuBarButtonName
  • rename ZegoDialogInfo to ZegoLiveStreamingDialogInfo
  • rename ZegoStartLiveButtonBuilder to ZegoLiveStreamingStartLiveButtonBuilder
  • rename ZegoIncomingPKBattleRequestTimeoutEvent to ZegoLiveStreamingIncomingPKBattleRequestTimeoutEvent
  • rename ZegoIncomingPKBattleRequestCancelledEvent to ZegoLiveStreamingIncomingPKBattleRequestCancelledEvent
  • rename ZegoOutgoingPKBattleRequestAcceptedEvent to ZegoLiveStreamingOutgoingPKBattleRequestAcceptedEvent
  • rename ZegoOutgoingPKBattleRequestRejectedEvent to ZegoLiveStreamingOutgoingPKBattleRequestRejectedEvent
  • rename ZegoOutgoingPKBattleRequestTimeoutEvent to ZegoLiveStreamingOutgoingPKBattleRequestTimeoutEvent
  • rename ZegoPKBattleEndedEvent to ZegoLiveStreamingPKBattleEndedEvent
  • rename ZegoPKBattleUserOfflineEvent to ZegoLiveStreamingPKBattleUserOfflineEvent
  • rename ZegoPKBattleUserQuitEvent to ZegoLiveStreamingPKBattleUserQuitEvent





3.1.2


Introduction

In this migration guide, we will explain how to upgrade from version 3.1.1 to the latest 3.1.2 version.

Major Interface Changes

  • ZegoUIKitPrebuiltLiveStreamingConfig (💥 breaking changes)

type of turnOnCameraWhenCohosted, change from bool to bool Function()?.

  • function prototype:
bool Function()? turnOnCameraWhenCohosted;

Modify your code based on the following guidelines to make it compatible with version 3.1.2:

3.1.1 Version Code:

/// Example code in version 3.1.1

 ZegoUIKitPrebuiltLiveStreaming(
   ...
   config: ZegoUIKitPrebuiltLiveStreamingConfig(
     turnOnCameraWhenCohosted: true,
   ),
   ...
 );

3.1.2 Version Code:

/// Example code in version 3.1.2

 ZegoUIKitPrebuiltLiveStreaming(
   ...
   config: ZegoUIKitPrebuiltLiveStreamingConfig(
     turnOnCameraWhenCohosted: (){
       return true;
     },
   ),
   ...
 );





3.1.0


Introduction

In this migration guide, we will explain how to upgrade from version 3.0.3 to the latest 3.1.0 version.

Major Interface Changes

  • rename ZegoLiveStreamingPKController to ZegoLiveStreamingControllerPKImpl





3.0.3


Introduction

In this migration guide, we will explain how to upgrade from version 3.0.2 to the latest 3.0.3 version.

Major Interface Changes

  • ZegoLiveStreamingDurationEvents
    • rename onUpdate to onUpdated





3.0.2


Introduction

In this migration guide, we will explain how to upgrade from version 3.0.1 to the latest 3.0.2 version.

Major Interface Changes

  • rename ZegoPKMixerLayout to ZegoLiveStreamingPKMixerLayout
  • rename ZegoPKMixerDefaultLayout to ZegoLiveStreamingPKMixerDefaultLayout
  • rename zegoPK2MixerCanvasWidth to zegoLiveStreamingPKMixerCanvasWidth
  • rename zegoPK2MixerCanvasHeight to zegoLiveStreamingPKMixerCanvasHeight





3.0


The 3.0 version has standardized and optimized the API and Event, simplifying the usage of most APIs.

Most of the changes involve modifications to the calling path, such as:

  • Changing from ZegoUIKitPrebuiltLiveStreamingController().isMinimizing() to ZegoUIKitPrebuiltLiveStreamingController().minimize.isMinimizing.
  • Move the event callback in the ZegoUIKitPrebuiltLiveStreamingConfig to the Event.

After upgrading the live streaming kit, you can refer to the directory index to see how specific APIs from the old version can be migrated to the new version.


Introduction

In this migration guide, we will explain how to upgrade from version 2.x to the latest 3.0 version.

This document aims to help users understand the interface changes and feature improvements, and provide a migration guide for the upgrade process.

Major Interface Changes

ZegoUIKitPrebuiltLiveStreamingController

In version 2.x, the ZegoUIKitPrebuiltLiveStreamingController required declaring the variable and passing to ZegoUIKitPrebuiltLiveStreaming to be initialized.

However, in version 3.0, the ZegoUIKitPrebuiltLiveStreamingController has been changed to a singleton pattern.

This means that you no longer need to declare a separate variable and pass parameters.

Instead, you can directly access the singleton instance and make calls to it.

Migrate Guide

Modify your code based on the following guidelines to make it compatible with version 3.0:

3.x Version Code:

/// Example code in version 2.x
/// ...
ZegoUIKitPrebuiltLiveStreamingController controller;

/// assign controller to ZegoUIKitPrebuiltLiveStreaming
ZegoUIKitPrebuiltLiveStreaming(
   ...
   controller:controller,
   ...
)

controller.xxx(...);

3.0 Version Code:

/// Example code in version 3.0
/// ...
ZegoUIKitPrebuiltLiveStreamingController().xxx(...);
  • move API in connect to coHost
  • move API in connectInvite to coHost
Compatibility Guide

Modify your code based on the following guidelines to make it compatible with version 3.0:

2.x Version Code:

/// Example code in version 2.x

ZegoUIKitPrebuiltLiveStreamingController().connect.functionName();
ZegoUIKitPrebuiltLiveStreamingController().connectInvite.functionName();

3.0 Version Code:

/// Example code in version 3.0

ZegoUIKitPrebuiltLiveStreamingController().coHost.functionName();
ZegoUIKitPrebuiltLiveStreamingController().coHost.functionName();

ZegoUIKitPrebuiltLiveStreamingConfig

startLiveButtonBuilder

  • move startLiveButtonBuilder from ZegoUIKitPrebuiltLiveStreamingConfig to ZegoLiveStreamingPreviewConfig
Compatibility Guide

Modify your code based on the following guidelines to make it compatible with version 3.0:

2.x Version Code:

/// Example code in version 2.x

 ZegoUIKitPrebuiltLiveStreaming(
   ...
   config: ZegoUIKitPrebuiltLiveStreamingConfig(
     startLiveButtonBuilder: (context){

     },
   ),
   ...
 );

3.0 Version Code:

/// Example code in version 3.0

 ZegoUIKitPrebuiltLiveStreaming(
   ...
   config: ZegoUIKitPrebuiltLiveStreamingConfig(
     previewConfig: ZegoLiveStreamingPreviewConfig(
       startLiveButtonBuilder: (context){
         ...
       },
     ),
   ),
   ...
 );

Unified class prefix as "ZegoLiveStreaming"

  • rename ZegoPrebuiltAudioVideoViewConfig to ZegoLiveStreamingAudioVideoViewConfig
  • rename ZegoTopMenuBarConfig to ZegoLiveStreamingTopMenuBarConfig
  • rename ZegoBottomMenuBarConfig to ZegoLiveStreamingBottomMenuBarConfig
  • rename ZegoMenuBarExtendButton to ZegoLiveStreamingMenuBarExtendButton
  • rename ZegoBottomMenuBarButtonStyle to ZegoLiveStreamingBottomMenuBarButtonStyle
  • rename ZegoMemberButtonConfig to ZegoLiveStreamingMemberButtonConfig
  • rename ZegoMemberListConfig to ZegoLiveStreamingMemberListConfig
  • rename ZegoInRoomMessageConfig to ZegoLiveStreamingInRoomMessageConfig
  • rename ZegoEffectConfig to ZegoLiveStreamingEffectConfig
  • rename ZegoLiveDurationConfig to ZegoLiveStreamingDurationConfig
  • rename ZegoMediaPlayerConfig to ZegoLiveStreamingMediaPlayerConfig

Removed "Config" suffix from the variable names

  • rename mediaPlayerConfig to mediaPlayer
  • rename videoConfig to video
  • rename audioVideoViewConfig to audioVideoView
  • rename topMenuBarConfig to topMenuBar
  • rename bottomMenuBarConfig to bottomMenuBar
  • rename memberButtonConfig to memberButton
  • rename memberListConfig to memberList
  • rename inRoomMessageConfig to inRoomMessage
  • rename effectConfig to effect
  • rename beautyConfig to beauty
  • rename previewConfig to preview
  • rename pkBattleConfig to pkBattle
  • rename durationConfig to duration

move event to ZegoUIKitPrebuiltLiveStreamingEvents (💥 breaking changes)

  • move onLiveStreamingStateUpdate from ZegoUIKitPrebuiltLiveStreamingConfig to ZegoUIKitPrebuiltLiveStreamingEvents and rename to onStateUpdate

  • move onCameraTurnOnByOthersConfirmation from ZegoUIKitPrebuiltLiveStreamingConfig to ZegoUIKitPrebuiltLiveStreamingEvents.audioVideo

  • move onMicrophoneTurnOnByOthersConfirmation from ZegoUIKitPrebuiltLiveStreamingConfig to ZegoUIKitPrebuiltLiveStreamingEvents.audioVideo

  • move onHostAvatarClicked from ZegoTopMenuBarConfig to ZegoUIKitPrebuiltLiveStreamingEvents.topMenuBar

  • move onClicked from ZegoMemberListConfig to ZegoUIKitPrebuiltLiveStreamingEvents.memberList

  • move onLocalMessageSend from ZegoInRoomMessageConfig to ZegoUIKitPrebuiltLiveStreamingEvents.inRoomMessage.onLocalSend

  • move onMessageClick from ZegoInRoomMessageConfig to ZegoUIKitPrebuiltLiveStreamingEvents.inRoomMessage.onClicked

  • move onMessageLongPress from ZegoInRoomMessageConfig to ZegoUIKitPrebuiltLiveStreamingEvents.inRoomMessage.onLongPress

  • move onDurationUpdate from ZegoLiveDurationConfig to ZegoUIKitPrebuiltLiveStreamingEvents.duration.onUpdate

Compatibility Guide

Modify your code based on the following guidelines to make it compatible with version 3.0:

2.x Version Code:

/// Example code in version 2.x

ZegoUIKitPrebuiltLiveStreaming(
 ...
 config: ZegoUIKitPrebuiltLiveStreamingConfig()
   ..onCameraTurnOnByOthersConfirmation = (context) async {
     return true;
   }
   ..onMicrophoneTurnOnByOthersConfirmation = (context) async {
     return true;
   }
   ..onLiveStreamingStateUpdate = (state) {
     //
   }
   ..topMenuBarConfig.onHostAvatarClicked = (host) {
     //
   }
   ..memberListConfig.onClicked = (user) {
     //
   }
   ..inRoomMessageConfig.onMessageClick = (message) {
     //
   }
   ..inRoomMessageConfig.onMessageLongPress = (message) {
     //
   }
   ..inRoomMessageConfig.onLocalMessageSend = (message) {
     //
   }
   ..durationConfig.onDurationUpdate = (duration) {
     //
   },
 ...
);

3.0 Version Code:

/// Example code in version 3.0


ZegoUIKitPrebuiltLiveStreaming(
   events: ZegoUIKitPrebuiltLiveStreamingEvents(
     onStateUpdate: (state){

     },
     audioVideo: ZegoLiveStreamingAudioVideoEvents(
       onCameraTurnOnByOthersConfirmation: (context){

       },
       onMicrophoneTurnOnByOthersConfirmation: (context){

       },
     ),
     topMenuBar: ZegoLiveStreamingTopMenuBarEvents(
       onHostAvatarClicked: (host){

       },
     ),
     memberList: ZegoLiveStreamingMemberListEvents(
       onClicked: (user){

       },
     ),
     inRoomMessage: ZegoLiveStreamingInRoomMessageEvents(
       onClicked: (message){

       },
       onLocalSend: (message){

       },
       onLongPress: (message){

       },
     ),
     duration: ZegoLiveStreamingDurationEvents(
       onUpdated: (duration){

       },
     ),
   ),
   ...
);

onLeaveConfirmation (💥 breaking changes)

You can use defaultAction.call() to perform the internal default action, which returns to the previous page.

  • move onLeaveConfirmation from ZegoUIKitPrebuiltLiveStreamingConfig to ZegoUIKitPrebuiltLiveStreamingEvents
  • add defaultAction and event in onLeaveConfirmation
Defines

Future<bool> Function(
  ZegoLiveStreamingLeaveConfirmationEvent event,

  /// defaultAction to return to the previous page
  Future<bool> Function() defaultAction,
)? onLeaveConfirmation


class ZegoLiveStreamingLeaveConfirmationEvent {
  BuildContext context;
}

Compatibility Guide

Modify your code based on the following guidelines to make it compatible with version 3.0:

2.x Version Code:

/// Example code in version 2.x

 ZegoUIKitPrebuiltLiveStreaming(
   ...
   config: ZegoUIKitPrebuiltLiveStreamingConfig(
     onLeaveConfirmation: (context){
       debugPrint('onLeaveConfirmation, do whatever you want');
     
       back to the previous page...
     },
   ),
   ...
 );

3.0 Version Code:

/// Example code in version 3.0

 ZegoUIKitPrebuiltLiveStreaming(
   ...
   events: ZegoUIKitPrebuiltLiveStreamingEvents(
     onLeaveConfirmation: (
         ZegoLiveStreamingLeaveConfirmationEvent event,
         /// defaultAction to return to the previous page
         Future<bool> Function() defaultAction,
     ) {
       debugPrint('onLeaveConfirmation, do whatever you want');
     
       /// you can call this defaultAction to return to the previous page,
       return defaultAction.call();
     },
   ),
   ...
 );

onLeaveLiveStreaming/onLiveStreamingEnded/onMeRemovedFromRoom (💥 breaking changes)

Due to the fact that all three events indicate the end of a live streaming, they will be consolidated into ZegoUIKitPrebuiltLiveStreamingEvents.onEnded and differentiated by the ZegoLiveStreamingEndEvent.reason.

And you can use defaultAction.call() to perform the internal default action, which returns to the previous page.

  • move onLeaveLiveStreaming from ZegoUIKitPrebuiltLiveStreamingConfig to ZegoUIKitPrebuiltLiveStreamingEvents.onEnded(ZegoLiveStreamingEndEvent(reason: ZegoLiveStreamingEndReason.localLeave), defaultAction)
  • move onLiveStreamingEnded from ZegoUIKitPrebuiltLiveStreamingConfig to ZegoUIKitPrebuiltLiveStreamingEvents.onEnded(ZegoLiveStreamingEndEvent(reason:ZegoLiveStreamingEndReason.hostEnd), defaultAction)
  • move onMeRemovedFromRoom from ZegoUIKitPrebuiltLiveStreamingConfig to ZegoUIKitPrebuiltLiveStreamingEvents.onEnded(ZegoLiveStreamingEndEvent(reason:ZegoLiveStreamingEndReason.kickOut), defaultAction)
Defines
void Function(
 ZegoLiveStreamingEndEvent event,
 VoidCallback defaultAction,
)? onEnded

class ZegoLiveStreamingEndEvent {
 /// the user ID of who kick you out
 String? kickerUserID;

 /// end reason
 ZegoLiveStreamingEndReason reason;

 /// The [isFromMinimizing] it means that the user left the live streaming
 /// while it was in a minimized state.
 ///
 /// You **can not** return to the previous page while it was **in a minimized state**!!!
 /// just hide the minimize page by [ZegoUIKitPrebuiltLiveStreamingController().minimize.hide()]
 ///
 /// On the other hand, if the value of the parameter is false, it means
 /// that the user left the live streaming while it was not minimized.
 bool isFromMinimizing;
 }
}

/// The default behavior is to return to the previous page.
///
/// If you override this callback, you must perform the page navigation
/// yourself to return to the previous page!!!
/// otherwise the user will remain on the current call page !!!!!
enum ZegoLiveStreamingEndReason {
 /// the call ended due to a local hang-up
 hostEnd,

 /// the call ended when the remote user hung up, leaving only one local user in the call
 localLeave,

 /// the call ended due to being kicked out
 kickOut,
}
Compatibility Guide

Modify your code based on the following guidelines to make it compatible with version 3.0:

2.x Version Code:

/// Example code in version 2.x

 ZegoUIKitPrebuiltLiveStreaming(
   ...
   config: ZegoUIKitPrebuiltLiveStreamingConfig(
     onLeaveLiveStreaming = (isFromMinimizing){

     },
     onLiveStreamingEnded = (isFromMinimizing){

     },
     onMeRemovedFromRoom = (fromUserID){

     },
   ),
   ...
 );

3.0 Version Code:

/// Example code in version 3.0

 ZegoUIKitPrebuiltLiveStreaming(
   ...
   events: ZegoUIKitPrebuiltLiveStreamingEvents(
     onEnded: (event, defaultAction){
       debugPrint('onEnd by ${event.reason}, do whatever you want');
       
       switch(event.reason) {
           case ZegoLiveStreamingEndReason.hostEnd:
             final isFromMinimizing = event.isFromMinimizing;
             // TODO: Handle this case.
             break;
           case ZegoLiveStreamingEndReason.localLeave:
             final isFromMinimizing = event.isFromMinimizing;
             // TODO: Handle this case.
             break;
           case ZegoLiveStreamingEndReason.kickOut:
             final fromUserID = event.kickerUserID ?? '';
             break;
       }
       
       /// you can call this defaultAction to return to the previous page
       defaultAction.call();
     },
   ),
   ...
 );

ZegoUIKitPrebuiltLiveStreamingEvents

coHost

  • rename onMaxCoHostReached to coHost.onMaxCountReached
  • reanme onCoHostsUpdated to coHost.onUpdate
  • rename hostEvents to coHost.host
  • rename audienceEvents to coHost.audience
  • rename ZegoUIKitPrebuiltLiveStreamingHostEvents to ZegoLiveStreamingCoHostHostEvents
  • rename ZegoUIKitPrebuiltLiveStreamingAudienceEvents to ZegoLiveStreamingCoHostAudienceEvents
  • host
    • rename onCoHostRequestReceived to onRequestReceived
    • rename onCoHostRequestCanceled to onRequestCanceled
    • rename onCoHostRequestTimeout to onRequestTimeout
    • rename onActionAcceptCoHostRequest to onActionAcceptRequest
    • rename onActionRefuseCoHostRequest to onActionRefuseRequest
    • rename onCoHostInvitationSent to onInvitationSent
    • rename onCoHostInvitationTimeout to onInvitationTimeout
    • rename onCoHostInvitationAccepted to onInvitationAccepted
    • rename onCoHostInvitationRefused to onInvitationRefused
  • audience
    • rename onCoHostRequestSent to onRequestSent
    • rename onActionCancelCoHostRequest to onActionCancelRequest
    • rename onCoHostRequestTimeout to onRequestTimeout
    • rename onCoHostRequestAccepted to onRequestAccepted
    • rename onCoHostRequestRefused to onRequestRefused
    • rename onCoHostInvitationReceived to onInvitationReceived
    • rename onCoHostInvitationTimeout to onInvitationTimeout
    • rename onActionAcceptCoHostInvitation to onActionAcceptInvitation
    • rename onActionRefuseCoHostInvitation to onActionRefuseInvitation
Compatibility Guide

Modify your code based on the following guidelines to make it compatible with version 3.0:

2.x Version Code:

/// Example code in version 2.x

 ZegoUIKitPrebuiltLiveStreaming(
   ...
   events: ZegoUIKitPrebuiltLiveStreamingEvents(
     onMaxCoHostReached: (maxCoHostCount){

     },
     onCoHostsUpdated: (List<ZegoUIKitUser> coHosts){

     },
     hostEvents: ZegoUIKitPrebuiltLiveStreamingHostEvents(

     ),
     audienceEvents: ZegoUIKitPrebuiltLiveStreamingAudienceEvents(

     ),
   ),
   ...
 );

3.0 Version Code:

/// Example code in version 3.0

 ZegoUIKitPrebuiltLiveStreaming(
   ...
   events: ZegoUIKitPrebuiltLiveStreamingEvents(
     coHost: ZegoLiveStreamingCoHostEvents(
       onMaxCountReached: (count){

       },
       onUpdated: (List<ZegoUIKitUser> coHosts){

       },
       host: ZegoLiveStreamingCoHostHostEvents(
 
       ),
       audience: ZegoLiveStreamingCoHostAudienceEvents(
 
       ),
     ),  
   ),
   ...
 );

PK

In version 2.x, there are two versions of PK.

The old version of PK only supports two participants, while the new version of PK supports multiple participants.

In version 3.0, we have deprecated the old version of PK that supports only two participants, and removed the "V2" suffix from the name of the previous new version of PK.

  • rename ZegoLiveStreamingPKBattleStateV2 to ZegoLiveStreamingPKBattleState

  • ZegoUIKitPrebuiltLiveStreamingConfig

    • rename ZegoLiveStreamingPKBattleV2Config to ZegoLiveStreamingPKBattleConfig
    • rename pkBattleV2Config to pkBattle
  • ZegoUIKitPrebuiltLiveStreamingEvents

    • rename pkV2Events -> pk
    • ZegoUIKitPrebuiltLiveStreamingPKV2Events -> ZegoLiveStreamingPKEvents
      • onIncomingPKBattleRequestReceived -> onIncomingRequestReceived
      • onIncomingPKBattleRequestCancelled -> onIncomingRequestCancelled
      • onIncomingPKBattleRequestTimeout -> onIncomingRequestTimeout
      • onOutgoingPKBattleRequestAccepted -> onOutgoingRequestAccepted
      • onOutgoingPKBattleRequestRejected -> onOutgoingRequestRejected
      • onOutgoingPKBattleRequestTimeout -> onOutgoingRequestTimeout
      • onPKBattleEnded -> onEnded
      • ZegoIncomingPKBattleRequestReceivedEventV2 -> ZegoIncomingPKBattleRequestReceivedEvent
      • ZegoIncomingPKBattleRequestCancelledEventV2 -> ZegoIncomingPKBattleRequestCancelledEvent
      • ZegoIncomingPKBattleRequestTimeoutEventV2 -> ZegoIncomingPKBattleRequestTimeoutEvent
      • ZegoOutgoingPKBattleRequestAcceptedEventV2 -> ZegoOutgoingPKBattleRequestAcceptedEvent
      • ZegoOutgoingPKBattleRequestRejectedEventV2 -> ZegoOutgoingPKBattleRequestRejectedEvent
      • ZegoOutgoingPKBattleRequestTimeoutEventV2 -> ZegoOutgoingPKBattleRequestTimeoutEvent
      • ZegoPKBattleEndedEventV2 -> ZegoPKBattleEndedEvent
      • ZegoPKBattleUserOfflineEventV2 -> ZegoPKBattleUserOfflineEvent
      • ZegoPKBattleUserQuitEventV2 -> ZegoPKBattleUserQuitEvent
Compatibility Guide

Modify your code based on the following guidelines to make it compatible with version 3.0:

2.x Version Code:

/// Example code in version 2.x

 ZegoUIKitPrebuiltLiveStreaming(
   ...
   config: ZegoUIKitPrebuiltLiveStreamingConfig(
     pkBattleV2Config: ZegoLiveStreamingPKBattleV2Config(
       
     ),
   ),
   events: ZegoUIKitPrebuiltLiveStreamingEvents(
     pkEvents: ZegoUIKitPrebuiltLiveStreamingPKV2Events(
       xx: onXXX() {}
     ),
   ),
   ...
 );

3.0 Version Code:

/// Example code in version 3.0

 ZegoUIKitPrebuiltLiveStreaming(
   ...
   config: ZegoLiveStreamingPKBattleConfig(
     pkBattle: ZegoLiveStreamingPKBattleV2Config(
       
     ),
   ),
   events: ZegoUIKitPrebuiltLiveStreamingEvents(
     pk: ZegoLiveStreamingPKEvents(
       xx: onXXX() {}
     ),
   ),
   ...
 );

ZegoUIKitPrebuiltLiveStreamingPKService

  • rename ZegoUIKitPrebuiltLiveStreamingPKUser -> ZegoLiveStreamingPKUser

If you migrate below version v2.23, which will migrate from the old version of two-player PK to the new version of multiplayer PK, please refer to the following:

  • APIs

The methods in ZegoUIKitPrebuiltLiveStreamingPKService can be replaced with the methods in ZegoUIKitPrebuiltLiveStreamingController().pk .

ZegoUIKitPrebuiltLiveStreamingPKService ZegoUIKitPrebuiltLiveStreamingController().pk description
sendPKBattleRequest sendRequest The
requestID is the ID of the current PK session.
cancelPKBattleRequest cancelRequest

|acceptIncomingPKBattleRequest|acceptRequest |The requestID is the event.requestID that you received in the onIncomingRequestReceived event. |

|rejectIncomingPKBattleRequest|rejectRequest |The requestID is the same as the event.requestID that you received in the onIncomingRequestReceived event.|

|stopPKBattle|stop|The requestID is the result.requestID returned by the sendRequest function.| |muteAnotherHostAudio|muteAudios|| |startPKBattleWith|none|After accepting the PK invitation, the interface will automatically switch to the PK screen, and no further action is required.

If you want the other party to directly enter the PK after the invitation is sent, you can set the isAutoAccept parameter to true in the sendRequest function.|

For example, if you previously used ZegoUIKitPrebuiltLiveStreamingService().sendPKBattleRequest(hostUserID) to send a PK invitation, now you should use ** ZegoUIKitPrebuiltLiveStreamingController().pk.sendRequest(hostUserID)**.

  • Events

The events in ZegoUIKitPrebuiltLiveStreamingConfig.pkBattleEvents can be replaced with the events in ZegoUIKitPrebuiltLiveStreamingEvents.pk.

ZegoUIKitPrebuiltLiveStreamingConfig.pkBattleEvents ZegoUIKitPrebuiltLiveStreamingEvents.pk description

|onIncomingRequestReceived|onIncomingRequestReceived |The requestID parameter from the event will be required when using the acceptRequest or rejectRequest functions.|

|onIncomingRequestCancelled|onIncomingRequestCancelled ||

|onIncomingRequestTimeout|onIncomingRequestTimeout ||

|onOutgoingRequestAccepted|onOutgoingRequestAccepted ||

|onOutgoingRequestRejected|onOutgoingRequestRejected ||

|onOutgoingRequestTimeout|onOutgoingRequestTimeout ||

|onPKBattleEndedByAnotherHost|onEnded||

ZegoUIKitPrebuiltLiveStreamingMiniOverlayMachine

In 3.0, the entire ZegoUIKitPrebuiltLiveStreamingMiniOverlayMachine has been deprecated, and the public APIs have been moved to ZegoUIKitPrebuiltLiveStreamingController().minimize.

  • move state to ZegoUIKitPrebuiltLiveStreamingController().minimize.state
  • move isMinimizing to ZegoUIKitPrebuiltLiveStreamingController().minimize.isMinimizing
  • move restoreFromMinimize to ZegoUIKitPrebuiltLiveStreamingController().minimize.restore()
  • move toMinimize to ZegoUIKitPrebuiltLiveStreamingController().minimize.minimize()
  • move resetInLiving to ZegoUIKitPrebuiltLiveStreamingController().minimize.hide()
Compatibility Guide

Modify your code based on the following guidelines to make it compatible with version 3.0:

2.x Version Code:

/// Example code in version 2.x

 final minimizeState = ZegoUIKitPrebuiltLiveStreamingMiniOverlayMachine().state;

 final isMinimizing = ZegoUIKitPrebuiltLiveStreamingMiniOverlayMachine().isMinimizing;

 ZegoUIKitPrebuiltLiveStreamingMiniOverlayMachine().restoreFromMinimize();

 ZegoUIKitPrebuiltLiveStreamingMiniOverlayMachine().toMinimize();

 ZegoUIKitPrebuiltLiveStreamingMiniOverlayMachine().resetInLiving();

3.0 Version Code:

/// Example code in version 3.0

 final minimizeState = ZegoUIKitPrebuiltLiveStreamingController().minimize.state;

 final isMinimizing = ZegoUIKitPrebuiltLiveStreamingController().minimize.isMinimizing;

 ZegoUIKitPrebuiltLiveStreamingController().minimize.restore();

 ZegoUIKitPrebuiltLiveStreamingController().minimize.minimize();

 ZegoUIKitPrebuiltLiveStreamingController().minimize.hide();







Feedback Channels

If you encounter any issues or have any questions during the migration process, please provide feedback through the following channels:

We appreciate your feedback and are here to help you successfully complete the migration process.