@@ -58,24 +58,26 @@ class SupabaseAuth with WidgetsBindingObserver {
58
58
final persistedSession = await _localStorage.accessToken ();
59
59
if (persistedSession != null ) {
60
60
try {
61
- Supabase .instance.client.auth.setInitialSession (persistedSession);
61
+ await Supabase .instance.client.auth
62
+ .setInitialSession (persistedSession);
63
+ shouldEmitInitialSession = false ;
62
64
} catch (error, stackTrace) {
63
65
Supabase .instance.log (error.toString (), stackTrace);
64
66
}
65
67
}
66
68
}
69
+ if (shouldEmitInitialSession) {
70
+ Supabase .instance.client.auth
71
+ // ignore: invalid_use_of_internal_member
72
+ .notifyAllSubscribers (AuthChangeEvent .initialSession);
73
+ }
67
74
_widgetsBindingInstance? .addObserver (this );
68
75
69
76
if (options.detectSessionInUri) {
70
77
await _startDeeplinkObserver ();
71
78
}
72
79
73
80
// Emit a null session if the user did not have persisted session
74
- if (shouldEmitInitialSession) {
75
- Supabase .instance.client.auth
76
- // ignore: invalid_use_of_internal_member
77
- .notifyAllSubscribers (AuthChangeEvent .initialSession);
78
- }
79
81
}
80
82
81
83
/// Recovers the session from local storage.
@@ -194,12 +196,10 @@ class SupabaseAuth with WidgetsBindingObserver {
194
196
// before app_links 6.0.0
195
197
uri = await (_appLinks as dynamic ).getInitialAppLink ();
196
198
} on NoSuchMethodError catch (_) {
197
- // The AppLinks package contains the initial link in the uriLinkStream
198
- // starting from version 6.0.0. Before this version, getting the
199
- // initial link was done with getInitialAppLink. Being in this catch
200
- // handler means we are in at least version 6.0.0, meaning we do not
201
- // need to handle the initial link manually.
199
+ // Needed to keep compatible with 5.0.0 and 6.0.0
202
200
// https://pub.dev/packages/app_links/changelog
201
+ // after app_links 6.0.0
202
+ uri = await (_appLinks as dynamic ).getInitialUri ();
203
203
}
204
204
if (uri != null ) {
205
205
await _handleDeeplink (uri);
0 commit comments