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 - 删除和重新安装应用程序不会取消对用户的身份验证
基础教程推荐
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01