# 开通

  • 登录腾讯开放平台,打开 “应用管理” -> “移动应用” 页面
  • Select "Create App" -> "Create Mobile App" on the page, and fill in the information to create an app according to the prompts
  • After the creation is successful, the APP ID can be obtained on the page of the application details
  • In the "Basic Information" -> "Platform Information" of the application details page, click "Modify" to set the UniversalLink for the iOS platform

For more information, please refer to the official QQ document [Overview of Mobile Application Access](https://wiki.connect.qq.com/%e7%a7%bb%e5%8a%a8%e5%ba%94%e7%94 %a8%e6%8e%a5%e5%85%a5%e6%a6%82%e8%bf%b0)

# 配置

  • appid QQ开放平台申请应用的AppID值
  • UniversalLinks iOS平台通用链接,必须与QQ开放平台配置的一致,推荐使用一键生成iOS通用链接

Notice

  • The standard real machine running base in HBuilderX uses the AppID and other information that DCloud applies for the HBuilder application, which is only used to experience the QQ sharing function
  • The configuration parameters need to be submitted to the cloud to be packaged to take effect. Please use the [custom debugging base] when the real machine is running (https://ask.dcloud.net.cn/article/35115)

# 使用QQ分享

# 示例代码

  • uni-app项目
uni.share({
    provider: 'qq',
	success: function (res) {
		console.log("success:" + JSON.stringify(res));
	},
	fail: function (err) {
		console.log("fail:" + JSON.stringify(err));
	}
});
  • 5+ App项目
var qqShare = null;
plus.share.getServices(function(services) {
	for (var i in services) {
		var service = services[i];
		// 获取QQ分享对象
		if (service.id == 'qq') {
			qqShare = service;
			break;
		}
	}
	qqShare.send( {
	}, function(){
		// 分享成功
	}, function(err) {
    // 分享操作失败
    // err.code is the error code
	})
}, function(err) {
	// Failed to get services
})