fluwx icon indicating copy to clipboard operation
fluwx copied to clipboard

鸿蒙微信无法获取回调,onReq 和 onResp 都没有触发

Open LevineHua opened this issue 5 months ago • 0 comments

无论是直接使用fluwx插件还是引入源码,都触发不了回调,但iOS和Android同样的使用方法,是没问题的;

fluwx 版本 5.5.2

flutter 版本 3.22.1-ohos-1.0.0

下面是我引入源码使用插件添加的日志,都没打印: ` onReq = (req: wechatSDK.BaseReq): void => { console.log('========= onReq') if (req instanceof wechatSDK.LaunchFromWXReq) { const _result: Map<string, ESObject> = new Map(); _result.set("extMsg", req.message?.messageExt); _result.set("messageAction", req.message?.messageAction); _result.set("lang", req.lang); _result.set("country", req.country); this.channel?.invokeMethod("onWXLaunchFromWX", _result); } }

onResp = (resp: wechatSDK.BaseResp): void => { console.log('========= onResp') if (resp instanceof wechatSDK.SendAuthResp) { this.onAuthResponse(resp); return; }

if (resp instanceof wechatSDK.SendMessageToWXResp) {
  this.onSendMessageToWXResp(resp);
  return;
}

if (resp instanceof wechatSDK.PayResp) {
  this.onPayResp(resp);
  return;
}

if (resp instanceof wechatSDK.LaunchMiniProgramResp) {
  this.onLaunchMiniProgramResp(resp);
  return;
}

} `

flutter代码,responseListener 内的日志都没打印: ` @override void initState() { super.initState(); print('login init');

responseListener = (response) {
  print('==========login');
  print(response);
  if (response is WeChatLaunchMiniProgramResponse) {
    print('==========login');
    print(response.extMsg);

    if (response.extMsg != null) {
      Map<String, String> params =
          LodashUtils.convertStringToObject(response.extMsg!);
      var code = params['code'];
      var scene = params['scene'];
      if (code != null && scene == 'login') {
        _login(code);
      }
    }
  }
};

fluwx.addSubscriber(responseListener);

} `

LevineHua avatar May 22 '25 07:05 LevineHua