setDataFromNative

Introduction

Pass the login status from Native SDK to our TUIKit for Flutter. Used for developing with both Native SDK and Flutter TUIKit in an APP, and with the initialization and login process done in Native.

It's unnecessary to call this method, only if you developing with both Native SDK and Flutter TUIKit in an APP, and with the initialization and login process done in Native.

You have to make sure the following steps done, before invoking this method.

Initialized the SDK successfully on Native SDK.

Logged in successfully on Native SDK.

Parameter details

Parameter name Parameter type Required Platform Description
onTUIKitCallbackListener Function(TIMCallback TIMCallback) no All This listener is used to get information including: errors form SDK API / errors form Flutter / some remind information that may need to pop up to prompt users. Usage and details, see this document.
language LanguageEnum no All The language on TUIKit, do not specified means using the language with system.
config TIMUIKitConfig no All The global configuration of TUIKit.
userId String yes All THe logged in user ID.

Returned template

Future<void>

Return value details

This function has no return value

Code example

    final CoreServicesImpl coreInstance = TIMUIKitCore.getInstance();
    coreInstance.setDataFromNative(
      onTUIKitCallbackListener: (TIMCallback callbackValue) {
        switch (callbackValue.type) {
          case TIMCallbackType.INFO:
            Utils.toast(callbackValue.infoRecommendText!);
            break;
          case TIMCallbackType.API_ERROR:
            print(
                "Error from TUIKit: ${callbackValue.errorMsg}, Code: ${callbackValue.errorCode}");
            if (callbackValue.errorCode == 10004 &&
                callbackValue.errorMsg!.contains("not support @all")) {
              Utils.toast("The current group does not support @all");
            } else if (callbackValue.errorCode == 80001 &&
                callbackValue.errorMsg!.contains("not support @all")) {
              Utils.toast("Illegal statement in message");
            } else {
              Utils.toast(
                  callbackValue.errorMsg ?? callbackValue.errorCode.toString());
            }
            break;
          case TIMCallbackType.FLUTTER_ERROR:
          default:
            if (callbackValue.catchError != null) {
              Utils.toast(callbackValue.catchError.toString());
            } else {
              print(callbackValue.stackTrace);
            }
        }
      },
      language: LanguageEnum.en, 
      config: TIMUIKitConfig(isShowOnlineStatus: true), 
      userId: '', 
    );

results matching ""

    No results matching ""