This commit is contained in:
Norcy 2024-08-19 15:37:09 +08:00
parent f356067265
commit 80739f7ab7

View File

@ -154,6 +154,36 @@ following fields:
| lang | String | The user language | | lang | String | The user language |
| country | String | The user country | | 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) 分享文本 #### ShareText(ShareTextMetadata) 分享文本
ShareTextMetadata ShareTextMetadata