Firebase - Deleting and reinstalling app does not un-authenticate a user(Firebase - 删除和重新安装应用程序不会取消对用户的身份验证)
问题描述
使用以下代码验证用户身份后(以下是我的代码的修剪版本,因此仅显示成功登录逻辑)...
After authenticating a user with the following code (below is a trimmed version of my code, so only the successful login logic is shown)...
let firebaseReference = Firebase(url: "https://MY-FIREBASE.firebaseio.com")
FBSession.openActiveSessionWithReadPermissions(["public_profile", "user_friends"], allowLoginUI: true,
completionHandler: { session, state, error in
if state == FBSessionState.Open {
let accessToken = session.accessTokenData.accessToken
firebaseReference.authWithOAuthProvider("facebook", token: accessToken,
withCompletionBlock: { error, authData in
if error != nil {
// Login failed.
} else {
// Logged in!
println("Logged in! (authData)")
}
})
}
})
}
(即启动并运行应用,登录成功).
(I.e. Launching and running the app, logging in successfully).
如果您随后删除该应用并在同一设备上重新安装它,则此调用(我在应用委托中用于确定用户是否已登录)将始终返回他们已登录.
If you then delete the app and reinstall it on the same device, this call - which I am using in the app delegate to determine if a user is logged in - will always return that they are logged in.
if firebaseReference.authData == nil {
// Not logged in
} else {
// Logged in
}
这是为什么呢?我原以为删除该应用并重新安装它应该会清除所有数据.
Why is that? I would have thought deleting the app and reinstalling it should wipe all data.
如果您在 iOS 模拟器中重置内容和设置,然后安装应用程序,则 firebaseReference.authData 属性将再次为 nil.
If you reset the Content and Settings in the iOS simulator, and the install the app, the firebaseReference.authData property will once again be nil.
推荐答案
Firebase 身份验证会话在 iOS 钥匙串中保留在用户设备上.卸载应用程序时,应用程序的钥匙串数据不会删除.
The Firebase authentication session is persisted on the user's device in the iOS keychain. The keychain data for the application is not removed when the application is uninstalled.
如果您希望手动清除数据,您可以将一些额外的元数据与您的应用程序一起存储并手动调用 FirebaseRef.unauth() 以清除持久会话.请参阅#4747404:卸载应用程序时删除钥匙串项供其他参考.
If you're looking to manually clear the data, you can store some additional metadata along with your application and manually call FirebaseRef.unauth() to clear the persisted session. See #4747404: Delete keychain items when an app is uninstalled for an additional reference.
这篇关于Firebase - 删除和重新安装应用程序不会取消对用户的身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Firebase - 删除和重新安装应用程序不会取消对用户的身份验证
基础教程推荐
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
