From 80739f7ab7841bbe9e1d6e2c5ec3f452cd6c503a Mon Sep 17 00:00:00 2001 From: Norcy Date: Mon, 19 Aug 2024 15:37:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 2cf24b3..a97e08a 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,36 @@ following fields: | lang | String | The user language | | country | String | The user country | +#### authByScan([scope, nonceStr, timestamp, scope, signature, schemeData, callback]) 微信扫码授权登录 + +- `appid` {String} the appid you get from WeChat dashboard +- `nonceStr` +- `timestamp` +- `scope` 写死 snsapi_userinfo 即可 +- `signature` 签名 +- `schemeData` 留空即可 +- `callback` (object) => void + +调用 authByScan 后,需要监听二维码的获取,展示完二维码,用户扫码登录完成后才会回调 callback,字段如下 + +| field | type | description | +| ------- | ------ | ----------------------------------- | +| errCode | Number | Error Code | +| authCode | String | Auth Code | + + +如何监听二维码的获取呢?如下示例,拿到二维码的本地图片链接后,使用 Image 等标签进行展示即可 + +```js +const qrcodeEmitter = new NativeEventEmitter(NativeModules.WeChat); + +const subscription = qrcodeEmitter.addListener('onAuthGotQrcode', (res) => + console.log(res.qrcode) +); +``` + +如有不懂,可以查看[微信官方文档](https://developers.weixin.qq.com/doc/oplatform/Mobile_App/WeChat_Login/Login_via_Scan.html) + #### ShareText(ShareTextMetadata) 分享文本 ShareTextMetadata