react-native-wechat-lib icon indicating copy to clipboard operation
react-native-wechat-lib copied to clipboard

sendAuthRequest 用户选择拒绝,拿不到回调结果

Open chj-damon opened this issue 3 years ago • 1 comments

image

ErrCode: ERR_OK = 0(用户同意) ERR_AUTH_DENIED = -4(用户拒绝授权) ERR_USER_CANCEL = -2(用户取消

实际调用时:const { errCode, code } = await Wechat.sendAuthRequest('xxx', 'xxx'); 如果用户点了拒绝,这里的errCode拿不到。 只有在用户点同意的时候,这里的errorCode和code才能拿到

chj-damon avatar Oct 14 '20 03:10 chj-damon

看了一下历史的issue,感觉这个问题其实一直没有被解决。

目前我是这样处理的(虽然安卓的errCode不能正常返回,但是他返回了一个code): .catch(reason => { if (reason && reason.name && reason.name === 'WechatError') { // 使用 react-native-wechat-lib 后,安卓的errCode = -2/-4 都不能正常返回, // 这里errCode = -4 时只能返回code = -4, // 而errCode = -2 则分两种情况: // ① 双微信选择时,直接点取消,没有任何回调。 // ② 前往到指定微信后,点击系统返回,触发取消授权,会返回code = -2 if (reason.code && reason.code === -2) { this._handleLoginException('用户取消授权') return } if (reason.code && reason.code === -4) { this._handleLoginException('用户拒绝授权') return } } this._handleLoginException(reason) });

ToyDelusion avatar Jul 29 '23 18:07 ToyDelusion