
Security News
Node.js Drops Bug Bounty Rewards After Funding Dries Up
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.
react-native-qq-lib-u
Advanced tools
React Native bridging library that integrates QQ SDKs. QQ 登陆 分享,集成 QQ SDK react-native 版本需要 0.40.0 及以上
首先向各位声明,本库是在 react-native-qq 基础上进行重写。
本身是维护给自己使用的,考虑到自身使用和其它开发者的需要,最终决定开一个新仓库,提供给新项目使用。
最后,感谢 lvbingru,tdzl2003 和各位开发者为 react-native-qq 做出的贡献。
Android SDK 版本:opensdk_3511_lite_2022-02-15(2022-02-16)
IOS SDK 版本:TencentOpenApi(Lite)_3.5.11.211(2022-02-16)
yarn add react-native-qq-lib-u
或
npm install -D react-native-qq-lib-u
然后执行
cd ios && pod install && cd ..
在工程 plist 文件中加入 qq 白名单:(ios9 以上必须) 请以文本方式打开 Info.plist,在其中添加
<key>LSApplicationQueriesSchemes</key>
<array>
<!-- QQ、Qzone URL Scheme 白名单-->
<string>mqq</string>
<string>mqqapi</string>
<string>tim</string>
<string>mqqopensdknopasteboard</string>
<string>mqqopensdkapiV2</string>
<string>mqqgamebindinggroup</string>
<string>mqqopensdkavatar</string>
<string>mqqopensdkfriend</string>
<string>mqqopensdklaunchminiapp</string>
<string>mqzone</string>
<string>tencentapi.qq.reqContent</string>
<string>tencentapi.qzone.reqContent</string>
<string>mqqthirdappgroup</string>
<string>mqqopensdkminiapp</string>
</array>
在Info->URL Types 中增加 QQ 的 scheme: Identifier 设置为qq, URL Schemes 设置为你注册的 QQ 开发者账号中的 APPID,需要加前缀tencent,例如tencent1104903684
在你工程的AppDelegate.m文件中添加如下代码:
#import <TencentOpenAPI/TencentOAuth.h>
#import <TencentOpenAPI/QQApiInterface.h>
#import <TencentOpenAPI/QQApiInterfaceObject.h>
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
return [TencentOAuth HandleOpenURL:url];
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
return [TencentOAuth HandleOpenURL:url];
}
在android/app/build.gradle里,defaultConfig 栏目下添加如下代码:
manifestPlaceholders = [
QQ_APPID: "<平台申请的APPID>"
]
以后如果需要修改 APPID,只需要修改此一处。
项目android/app/src/main/AndroidManifest.xml添加
<activity
android:name="com.tencent.tauth.AuthActivity"
android:noHistory="true"
android:launchMode="singleTask" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tencent平台申请的APPID" />
</intent-filter>
</activity>
<activity
android:name="com.tencent.connect.common.AssistActivity"
android:screenOrientation="behind"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
import * as QQAPI from 'react-native-qq-lib-u';
初始化,调用其他api时请先调用该api
调用 QQ 登录,可能会跳转到 QQ 应用或者打开一个网页浏览器以供用户登录。在本次 login 返回前,所有接下来的 login 调用都会直接失败。
返回一个Promise对象。成功时的回调为一个类似这样的对象:
{
"access_token": "CAF0085A2AB8FDE7903C97F4792ECBC3",
"openid": "0E00BA738F6BB55731A5BBC59746E88D"
"expires_in": "1458208143094.6"
"oauth_consumer_key": "12345"
}
分享到 QQ 好友,参数同 QQAPI.shareToQzone,返回一个Promise对象
分享到 QZone,参数为一个 object,可以有如下的形式:
// 分享图文消息
{
type: 'news',
title: 分享标题,
description: 描述,
webpageUrl: 网页地址,
imageUrl: 远程图片地址,
}
// 分享文本消息
{
type: 'text',
text: 分享内容,
}
// 分享图片
// By:这里的 imageUrl 和 imageLocalUrl 都要传而且保持一致(别问我为啥埋这个坑,问就是腾讯的 SDK 这样搞的)
// 支持的路径如: file:// content:// /data/user/0/com.xxxxx/cache/
{
type: 'image',
imageUrl: 图片路径,
imageLocalUrl: 图片路径,
}
// 其余格式尚未实现。
图片路径不支持 http 和 https 网络地址(网络地址的先自己下载图片,这里推荐rn-fetch-blob库)。
import RNFetchBlob from 'rn-fetch-blob';
const _image = 图片地址或路径;
if (RegExp(/http:\/\//).exec(_image) || RegExp(/https:\/\//).exec(_image)) {
// 判断是网络地址的话先下载图片,然后再分享图片
RNFetchBlob.config({
fileCache: true,
appendExt: "png",
})
.fetch("GET", _image)
.then((res) => {
const qq = QQAPI.shareToQzone({
type: "image",
imageUrl: res.path(),
imageLocalUrl: res.path(),
});
qq.then(() => {
__onSucceed();
}).catch(() => {
});
})
.catch((error) => {
});
} else {
const qq = QQAPI.shareToQzone({
type: "image",
imageUrl: _image,
imageLocalUrl: _image,
});
qq.then(() => {
}).catch(() => {
});
}
通常出现这个原因是因为 Manifest 没有配置好,检查 Manifest 中有关 Activity 的配置。
通常出现这个原因是因为 MainActivity.java 中缺少 onActivityResult 的调用。
出现这个原因是因为sdk在同意隐私政策之前就自动初始化了,目前3.1.0版本已将初始化api暴露,取消了自动初始化,可在RN端自由调整初始化时机。
创建 apple-app-site-association文件,不带.json,在应用管理Universal Link 状态点击验证通过
{
"applinks": {
"apps": [],
"details": [
{
"appID": "9JA89QQLNQ.com.apple.wwdc",
"paths": [ "/wwdc/news/", "/videos/wwdc/2015/*","/qq_conn/平台申请的APPID/*"]
},
{
"appID": "ABCD1234.com.apple.wwdc",
"paths": [ "*","/qq_conn/平台申请的APPID/*" ]
}
]
}
}
FAQs
QQ Login and Share support in React Native.
The npm package react-native-qq-lib-u receives a total of 12 weekly downloads. As such, react-native-qq-lib-u popularity was classified as not popular.
We found that react-native-qq-lib-u demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.