[Android] User session between the app and a service #714
-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
By default, the session gets loaded in when the app starts (and automatic session refresh gets started) and gets cleared when the app switches to the background. This is done to prevent expired sessions being still loaded in when coming back from background. You could disable this behavior via |
Beta Was this translation helpful? Give feedback.
-
If anyone else has a similar issue: The problem was not in the refreshing session mechanism, but in the fact that the NotificationService can be run in a separate process than the main application. This means that load from storage will not access stored session information as SharedPrefferences are specific per process. To solve this, the Supabase logic need to be moved to WorkManager (called from the service). Work Manager is started within the Application process so it can access the session information. |
Beta Was this translation helpful? Give feedback.
Maybe just using
Auth#loadFromStorage()
could also work