create static method

Future<JCClient> create(
  1. String appKey,
  2. JCClientCallback callback,
  3. CreateParam? createParam
)

创建 JCClient 对象

JCClient 的所有接口函数,如无特殊说明,都建议在主线程调用

@note

  • 请确保在调用其他 API 前先调用该方法创建并初始化 JCClient 对象
  • 调用此方法创建 JCClient 对象后,期间没有调用过 @ref destroy 方法销毁对象,然后又重复调用此方法,会直接返回第一次创建的 JCClient 对象

context 上下文句柄 appKey 用户从 Juphoon Cloud 平台上创建应用获取的 AppKey 字符串,详见获取 appKey callback JCClientCallback 对象,用于回调相关通知 createParam 创建参数,详细定义见 CreateParam。传 null 则使用默认值 @return JCClient 对象 @exception "context、appKey、JCClientCallback 任意参数传空就会抛出异常"

Implementation

static Future<JCClient> create(String appKey, JCClientCallback callback,
    CreateParam? createParam) async {
  if (_sClient == null) {
    _sClient = new JCClientImpl();
  }
  bool result =
      await _sClient!.createNativeJCClient(appKey, callback, createParam);

  if (result) {
    NativeImpl.registerEventHandler();
    return Future.value(_sClient);
  }
  return Future.error("_createNativeJCClient  exception");
}