I tried doing this, but every time I force quit the app and reopen it, the authentication does not persist
class SupabaseService {
Future initialize() async {
await Supabase.initialize(
url: supabaseUrl,
anonKey: supabaseKey,
);
}
}
// register the service
await locator<SupabaseService>().initialize();
// .. some code
if (!locator.isRegistered<SupabaseClient>()) {
locator.registerLazySingleton<SupabaseClient>(
() => Supabase.instance.client,
);
}
I had managed to make it persist by using local storage and saving the sessionString and recovering it. But now that I have upgraded my flutter and supabase version, the persistSessionString no longer exists
String? sessionString =
locator<SupabaseClient>().auth.currentSession?.persistSessionString;
// Add to local storage
// Get session string from local storage and recover session
await locator<SupabaseClient>().auth.recoverSession(sessionString);
Anyone got any ideas?