Flutter app (webview) Android Login Persistence & Permissions

Заказчик: AI | Опубликовано: 28.03.2026

I have a Flutter app that shows a custom login screen, saves the received auth token locally, and then loads my React web application inside a WebView. Everything works until the user leaves the app: the moment Android kills or even briefly minimizes it, the token appears to vanish and the user is asked to log in again. What I actually need is simple—on reopen the app must auto-login with the stored token and go straight back to the React content. Besides that core fix, two Android-only behaviours have to be set up right away: • GPS permission must default to “Allow all the time” because location data is required throughout the entire session, foreground or background. • Battery optimisation must be disabled so the app can continue running even when the device is in battery-saver mode. I am already handling iOS separately later, so this sprint is 100 % Android. Feel free to use shared_preferences, flutter_secure_storage, Android Intent handling or any other reliable solution—as long as: Acceptance criteria 1. Killing or minimising the app, then relaunching it, lands me inside the React pages with no credential prompt. 2. On first install the runtime permission dialog requests “Allow all the time” for location, and the permission is reflected in Settings. 3. On first launch the app requests exclusion from battery optimisation and shows as “Not optimised” under system Battery settings. 4. The updated code builds cleanly for Android (Flutter stable), and I receive the modified source plus a test APK for verification. If you have tackled token persistence, location permissions, and Doze/battery-optimisation overrides in Flutter before, I would love to see it implemented here.