clearOnInstall method

void clearOnInstall()

Wipes stored credentials on the first launch after a (re)install.

iOS keeps keychain items across an uninstall, so a reinstalled app could otherwise start "logged in" with a stale session. Call it once at startup, before the first request; it does nothing after the first run, and — unlike deleteToken — never notifies listeners.

Implementation

void clearOnInstall() async {
  final _hasRunBefore = await _prefs.getBool(_hasRunBeforeKey) ?? false;
  if (!_hasRunBefore) {
    _storage.deleteAll();
    await _prefs.setBool(_hasRunBeforeKey, true);
  }
}