表題の通り、iOSでFirebase Authを使っていると、
アンインストールしてもログイン状態のままになってしまった。。
- 🐛 [FirebaseAuth] Still logged in after app uninstallation · Issue #4661 · firebase/flutterfire
- docs(firebase-auth,apple): uninstallation warning for logged in users by dackers86 · Pull Request #4671 · firebase/flutterfire
いくつかのissueにあがっているとおり、
iOSではkyechainに保存されていることに起因しているよう。
対処方法
対処方法としては、SharedPreferencesなどを使って、
初回起動フラグ(hasRunBefore
)などを用意しておき、
フラグに応じて、サインアウトさせるようにするっぽい。
if (!userDefaults.bool(forKey: "hasRunBefore")) { print("The app is launching for the first time. Setting UserDefaults...") do { try FIRAuth.auth()?.signOut() } catch { } // Update the flag indicator userDefaults.set(true, forkey: "hasRunBefore") userDefaults.synchronize() // This forces the app to update userDefaults // Run code here for the first launch } else { print("The app has been launched before. Loading UserDefaults...") // Run code here for every other launch but the first }
- shared_preferences | Flutter Package
- docs(firebase-auth,apple): uninstallation warning for logged in users by dackers86 · Pull Request #4671 · firebase/flutterfire
以上!! Androidと挙動が違ってちょっとハマった。。
参考にしたサイトさま
- Using Firebase Authentication | FlutterFire
- 🐛 [FirebaseAuth] Still logged in after app uninstallation · Issue #4661 · firebase/flutterfire
- ios - Delete keychain items when an app is uninstalled - Stack Overflow
- docs(firebase-auth,apple): uninstallation warning for logged in users by dackers86 · Pull Request #4671 · firebase/flutterfire