问题描述
我正在用React Native编写应用程序,但是在Android设备上登录Facebook时遇到问题。我的代码如下:
LoginManager.logInWithPermissions(['public_profile,email'])
.then((response) => {
if (!response.isCancelled) {
Accesstoken.getCurrentAccesstoken().then((data) => {...})
}
})
当我请求权限时:public_profile->一切正常。但是,当我添加电子邮件权限时,而不是仅在首次安装我的应用程序时,loginWithPermissions返回isCancelled = false
。每当我收到回复isCancelled = true;
时。
因此,此代码仅一次有效,isCancelled
是正确的。
有人知道为什么会这样吗?我该如何解决?
解决方法
我弄清楚我做错了什么。我不小心将权限写为以逗号分隔的数组的一项:Container loginText() {
return Container(
padding: const EdgeInsets.only(top: 20.0),child: MouseRegion(
cursor: SystemMouseCursors.text,child: GestureDetector(
onTap: () => _toLogin(),child: Text(
'Bereits registriert? Zum Login',),);
。
它应该是数组['public_profile,email']
中两个分开的项目。