Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
LevineHua opened this issue May 22, 2025 · 0 comments
Open

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

LevineHua opened this issue May 22, 2025 · 0 comments

Comments

@LevineHua
Copy link

无论是直接使用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);

}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant