Flutter集成Facebook登录遇「App not active」错误如何解决?
问题描述
在Flutter应用中集成Facebook登录功能时,遇到「App not active」错误:添加为测试账号的账户可正常登录,但其他用户登录时会触发该错误,错误提示如下:
App not active. This app is not currently accessible and the app developer is aware of the issue. You will be able to log in when the app is reactivated.
使用flutter_facebook_auth包实现功能,核心代码如下:
class FbAuth { Future<UserCredential> signInWithFacebook() async { // Trigger the sign-in flow final LoginResult loginResult = await FacebookAuth.instance.login( permissions: ['email'], ); // Create a credential from the access token final OAuthCredential facebookAuthCredential = FacebookAuthProvider.credential(loginResult.accessToken!.token); // Once signed in, return the UserCredential return FirebaseAuth.instance.signInWithCredential(facebookAuthCredential); } }
根据Facebook官方文档,仅请求「public profile」和「email」权限无需提交审核:
Apps may ask for the following two permissions from any person without submitting for review by Facebook:
public profile
To ask for any other permission, your app will need to be reviewed by Facebook before these permission become visible in the Login Dialog to the public who're logging into your app with Facebook.
错误成因
- 应用处于开发模式:这是最常见的原因。Facebook应用默认处于开发模式,此时仅添加的测试用户、应用管理员、开发者账号能正常登录,普通用户会被拦截并提示「App not active」。即便权限无需审核,也需要将应用切换到上线模式才能对所有用户开放。
- 应用被临时限制或停用:如果应用违反了Facebook平台政策(比如滥用登录权限、虚假内容等),或者存在未解决的合规问题,Facebook会临时限制应用访问权限,导致普通用户无法登录。需要登录Facebook开发者后台查看是否有相关通知或违规记录。
- 平台配置信息不完整/错误:如果Android/iOS平台的包名、签名哈希值、Bundle ID等配置信息与应用实际信息不匹配,普通用户登录时会触发验证失败,也可能间接出现该错误提示。测试用户可能因权限较高绕过了部分验证,但普通用户无法通过。
内容的提问来源于stack exchange,提问作者kingOfEdibleLeaves

