uni-app HX3.1.13 Android端 uni.share QQ分享纯文字报错

uni-app HX3.1.13 Android端 uni.share QQ分享纯文字报错

示例代码:

uni.share({  
    provider: 'qq',  
    type: '1', // 1: 为纯文字分享  
    title: this.courseName,  
    // href: 'url', // type为0时才必填  
    summary: this.shareContent,  
    success: () => {  
      uni.showToast({  
        title: '分享成功',  
        icon: 'none',  
      });  
    },  
    fail: (e) => {  
      uni.showToast({  
        title: '分享失败~',  
        icon: 'none',  
      });  
    },  
});

操作步骤:

代码示例

预期结果:

纯文字分享正常

实际结果:

{
  "errMsg": "share:fail 非纯图片分享必须传递链接地址!,http://ask.dcloud.net.cn/article/282",  
  "errCode": -1,  
  "code": -1  
}

bug描述:

Android端 QQ分享无法分享纯文字内容,iOS端功能正常!

uni.share({  
    provider: 'qq',  
    type: '1', // 1: 为纯文字分享  
    title: '分享标题',  
    // href: 'url', // type为0时才必填  
    summary: '分享内容文本',  
    success: () => {  
      uni.showToast({  
        title: '分享成功',  
        icon: 'none',  
      });  
    },  
    fail: (e) => {  
      uni.showToast({  
        title: '分享失败~',  
        icon: 'none',  
      });  
    },  
});

// 纯文字分享报错必填href

{
  "errMsg": "share:fail 非纯图片分享必须传递链接地址!,http://ask.dcloud.net.cn/article/282",  
  "errCode": -1,  
  "code": -1  
}

图片

Image 1 Image 2

开发环境 版本号 项目创建方式
Mac 11.4 HBuilderX
Android 11
OPPO
OPPO Reno Ace

更多关于uni-app HX3.1.13 Android端 uni.share QQ分享纯文字报错的实战教程也可以访问 https://www.itying.com/category-93-b0.html

2 回复

QQ分享规则上不让发纯文字分享

更多关于uni-app HX3.1.13 Android端 uni.share QQ分享纯文字报错的实战教程也可以访问 https://www.itying.com/category-93-b0.html


这是一个已知的Android平台兼容性问题。QQ分享在Android端不支持纯文字分享类型,必须传递链接地址。

解决方案是在分享时添加href参数,即使type为1(纯文字分享):

uni.share({  
    provider: 'qq',  
    type: '1',
    title: this.courseName,  
    href: 'https://www.example.com', // 添加一个有效的URL
    summary: this.shareContent,  
    success: () => {  
      uni.showToast({  
        title: '分享成功',  
        icon: 'none',  
      });  
    },  
    fail: (e) => {  
      uni.showToast({  
        title: '分享失败~',  
        icon: 'none',  
      });  
    },  
});
回到顶部