I’m developing a Flutter mobile app for both Android and iOS. When I uninstall and reinstall the app, it directly navigates into the app without asking for authentication details. I expect it to prompt for login on each fresh installation, but it seems to remember the previous session details somehow.
I am using mobile number and OTP for authentication. When a user login into the app, their data is stored in local storage using flutter_secure_storage. If the user uninstalls and then reinstalls the app, it will not prompt them to login again instead, it will take them directly to the home screen
this because Secure Storage save the data on the phone storage it self not the app which cause the issue you have now , you need to create another flag which help you to determine whether it's first run or not , this example using shared_preferences
the below is how you need to configure it
void main() async {
WidgetsFlutterBinding.ensureInitialized();
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
var isFirstRun = sharedPreferences.getBool("isFirstRun") ?? true;
if (isFirstRun) {
const storage = FlutterSecureStorage();
await storage.deleteAll();
sharedPreferences.setBool("isFirstRun", false);
}
runApp(const MyApp());
}