鸿蒙分享微信好友卡片未拉起微信 uni-app

鸿蒙分享微信好友卡片未拉起微信 uni-app

开发环境 版本号 项目创建方式
Mac 15.6.1 (24G90) HBuilderX

示例代码:

uni.share({ provider: ‘weixin’, scene: ‘WXSceneSession’, type: 5, title: shareData.value.shareName, imageUrl:shareData.value.shareImg, miniProgram: { id: ‘小程序原始id’, path: Url, type: safeStorage.get(‘formal’), webUrl: ‘https://your-domain.com/#/pages/goods/detail’ }, success: () => { uni.showToast({ title: ‘已分享给微信好友’, icon: ‘none’ }); closePopup(1); }, fail: (err) => { console.error(‘分享失败:’, err); uni.showToast({ title: ‘分享失败,请重试’, icon: ‘none’ }); }, })


## 操作步骤:


--

预期结果:


## 实际结果:


--

bug描述:

8:10:17.940 [wxopensdk::WXApi] canOpenLink fail by err: BusinessError 17700056: The scheme of the specified link is not in the querySchemes.
18:10:17.944 [wxopensdk::WXApi] sendReq, use want
18:10:17.971 [wxopensdk::WXApi] openWechatWithWant fail by err: Internal error.
18:10:17.999 [wxopensdk::WXApi] openWechatWithWant fail by err: Internal error.
18:10:18.036 [wxopensdk::WXApi] openWechatWithWant fail by err: Internal error.
18:10:18.064 [wxopensdk::WXApi] openWechatWithWant fail by err: Internal error.
18:10:18.096 [wxopensdk::WXApi] openWechatWithWant fail by err: Internal error.
18:10:18.116 [wxopensdk::WXApi] openWechatWithWant fail by err: Internal error.  
未拉起微信但是走成功回调了success中了  

更多关于鸿蒙分享微信好友卡片未拉起微信 uni-app的实战教程也可以访问 https://www.itying.com/category-93-b0.html

2 回复

你这个 obs 里有个 package 为啥要这么设置?看报错没有正确配置 querySchemes 找一下配置文件,正确放入到 hamrony-configs 文件夹内

更多关于鸿蒙分享微信好友卡片未拉起微信 uni-app的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


从日志分析,这是鸿蒙系统上微信分享的典型兼容性问题。关键错误信息是:

  1. The scheme of the specified link is not in the querySchemes - 表明微信的URL Scheme未在鸿蒙系统中正确注册
  2. openWechatWithWant fail by err: Internal error - 微信客户端打开失败
  3. 虽然触发了success回调,但实际未拉起微信

解决方案:

  1. 检查微信安装状态:确保设备已安装微信且版本支持分享功能
  2. 鸿蒙权限配置:在manifest.json中确认已配置微信的URL Scheme:
"app-plus": {
  "distribute": {
    "android": {
      "schemes": ["weixin"]
    }
  }
}
  1. 使用条件编译:针对鸿蒙系统做特殊处理:
// #ifdef APP-PLUS
if(uni.getSystemInfoSync().platform == 'harmony') {
  // 鸿蒙系统可能需要其他分享方式
  uni.showModal({
    content: '请确保已安装微信'
  });
  return;
}
// #endif
回到顶部