You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Handling Configuration Changes During Authentication
329
329
330
-
When the Activity is destroyed during authentication due to a configuration change (e.g. device rotation, locale change, dark mode toggle), the SDK caches the authentication result internally. Call `WebAuthProvider.attach()` in your `onResume()` to recover it. This single call handles both recovery scenarios:
330
+
When the Activity is destroyed during authentication due to a configuration change (e.g. device rotation, locale change, dark mode toggle), the SDK caches the authentication result internally. Call `WebAuthProvider.registerCallbacks()`once in your `onCreate()` to recover it. This single call handles both recovery scenarios:
331
331
332
-
-**Configuration change**: delivers any cached result immediately to the callback
332
+
-**Configuration change**: delivers any cached result on the next `onResume` to the callback
333
333
-**Process death**: registers `loginCallback` as a listener and auto-removes it when the Activity is destroyed
@@ -373,7 +373,7 @@ class LoginActivity : AppCompatActivity() {
373
373
```
374
374
375
375
> [!NOTE]
376
-
> If you use the `suspend fun await()` API from a ViewModel coroutine scope, the Activity is never captured in the callback chain, so you do not need `attach()` calls.
376
+
> If you use the `suspend fun await()` API from a ViewModel coroutine scope, the Activity is never captured in the callback chain, so you do not need `registerCallbacks()` calls.
@@ -337,17 +337,17 @@ class LoginActivity : AppCompatActivity() {
337
337
}
338
338
```
339
339
340
-
`attach()` covers both scenarios in one call:
340
+
`registerCallbacks()` covers both scenarios in one call:
341
341
342
342
| Scenario | How it's handled |
343
343
|----------|-----------------|
344
-
|**Configuration change** (rotation, locale, dark mode) | Any result cached while the Activity was recreating is delivered immediately to the callback|
344
+
|**Configuration change** (rotation, locale, dark mode) | Any result cached while the Activity was recreating is delivered on the next `onResume`|
345
345
|**Process death** (system killed the app while browser was open) |`loginCallback` is registered as a listener and auto-removed when `lifecycleOwner` is destroyed — no manual `addCallback`/`removeCallback` calls needed |
346
346
347
347
> **Note:**`logoutCallback` is optional — pass it only if your screen initiates logout flows.
348
348
349
349
> **Note:** If you use the `suspend fun await()` API from a ViewModel coroutine scope, the
350
-
> Activity is never captured in the callback chain, so you do not need `attach()` calls.
350
+
> Activity is never captured in the callback chain, so you do not need `registerCallbacks()` calls.
351
351
> See the sample app for a ViewModel-based example.
0 commit comments