reactjs - React-Native Google-SignIn 注销不起作用
问题描述
我有个问题。当我登录我的应用程序并刷新时,我去尝试注销,我必须手动刷新才能看到我已注销。基本上发生的情况是,它卡在了我的 try catch 语句中,因此我什么也看不到,但如果我刷新,我就会很好地注销。但是,如果我从中删除await
关键字GoogleSignIn.revokeAcess()
并且GoogleSignin.signOut()
它按预期工作。文档显示了一个示例,他们正在使用等待。删除等待对我来说是不好的做法吗?提前致谢。
代码:
export function logout(): ThunkResult<void> {
return function(dispatch) {
Keychain.resetGenericPassword().then(async () => {
amplitude.logEvent('Log out');
LoginManager.logOut();
try {
const isSignedIn = await GoogleSignin.isSignedIn();
if (isSignedIn) {
console.log('gets here'); // LOGS THIS
await GoogleSignin.revokeAccess(); // GETS STUCK HERE
console.log('passed revoke access'); // doesn't log this
await GoogleSignin.signOut();
console.log('passed signOut');
}
} catch (err) {
console.log(err);
amplitude.logEvent('Failed Google Logout', err);
}
console.log('passes');
resetAllPreferences();
dispatch(postLogout());
dispatch(fetchMoreActivities());
});
};
}
接着
const mapDispatchToProps = (dispatch: AsyncDispatch) => ({
synchronizeReads: () => dispatch(synchronizeReadInsights()),
logout: () => dispatch(logout()), // here i take the action above from my actions file
});
并像使用它一样
const onLogoutPress = async () => {
await synchronizeReads();
logout();
Navigation.pop(componentId);
};
解决方案
推荐阅读
- html - Heroku vue-loader 构建失败
- filter - 按月计算的数据总和,同时可过滤
- twilio - Twilio API:无法在彩信中下载 jpeg 文件
- oracle-apex - 使用选中的复选框获取所选行的值
- firebase - Meteor 在服务器端加载 Firebase 管理员
- c# - C#对象名称概念解释
- android - 用于新项目的 Android 工作室无法正常工作
- c# - 使用 dataGridView 使用单个文本框搜索多个数据库列
- neural-network - 在 pytorch 中反向传播时自动更新自定义层参数
- python - Def函数的错误