# 开通

  • 登录腾讯开放平台,打开 “应用管理” -> “移动应用” 页面
  • 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 login 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.login({
    provider: 'qq',
    success: function (loginRes) {
        // login successful
        uni.getUserInfo({
            provider: 'qq',
            success: function(info) {
                // Obtain user information successfully, info.authResult saves user information
            }
        })
    },
    fail: function (err) {
        // 登录授权失败
        // err.code is the error code
    }
});
  • 5+ App项目
var qqOauth = null;
plus.oauth.getServices(function(services) {
	for (var i in services) {
		var service = services[i];
		// 获取QQ登录对象
		if (service.id == 'qq') {
			qqOauth = service;
			break;
		}
	}
	qqOauth.login( function(oauth){
		// 授权成功,qqOauth.authResult 中保存授权信息
	}, function(err) {
    // 登录授权失败
    // err.code is the error code
	})
}, function(err) {
	// Failed to get services
})