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
Copy file name to clipboardExpand all lines: FAQ.md
+68Lines changed: 68 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,7 @@
18
18
16.[What happens if I disable DPoP after enabling it?](#16-what-happens-if-i-disable-dpop-after-enabling-it)
19
19
17.[Why does the app hang or freeze during Social Login (Google, Facebook, etc.)?](#17-why-does-the-app-hang-or-freeze-during-social-login-google-facebook-etc)
20
20
18.[How do I refresh the user profile (e.g. `emailVerified`) after it changes on the server?](#18-how-do-i-refresh-the-user-profile-eg-emailverified-after-it-changes-on-the-server)
21
+
19.[Why does login fail after the Android system kills my app during the browser step?](#19-why-does-login-fail-after-the-android-system-kills-my-app-during-the-browser-step)
21
22
22
23
## 1. How can I have separate Auth0 domains for each environment on Android?
23
24
@@ -1021,3 +1022,70 @@ function VerifyEmailScreen() {
1021
1022
|`getCredentials` promise never resolves | Missing refresh token or network issue | Ensure `offline_access` is included during login, and check network connectivity. |
1022
1023
1023
1024
>**Note**: This behavior differs from the web SDK (`@auth0/auth0-spa-js`), where token refresh is handled automatically via silent authentication using iframes. On native platforms (iOS/Android), a refresh token is explicitly required.
1025
+
1026
+
## 19. Why does login fail after the Android system kills my app during the browser step?
1027
+
1028
+
### The problem
1029
+
1030
+
On Android, while the user is in the Auth0 login browser (Chrome Custom Tabs), the OS may kill your app's process to reclaim memory. This is common on low-memory devices, and it happens **every time** when the developer option **Settings → Developer options → Don't keep activities** is enabled.
1031
+
1032
+
When the user finishes logging in, the deep link cold-starts your app. TheSDK recovers the login automatically and the user ends up logged in — but only if your `MainActivity` is set up to survive the restart. If it is not, the app can crash on restore (`java.lang.IllegalStateException: Screen fragments should never be restored`) before recovery can run, and the user is left logged out.
1033
+
1034
+
### The solution
1035
+
1036
+
If your app uses `react-native-screens` (which React Navigation does by default), your `MainActivity` must discard the saved view state by passing `null` to `super.onCreate`. This is a general requirement of`react-native-screens`, which cannot restore its fragment hierarchy after process death — it is not specific to Auth0. Apps that do not use `react-native-screens` are unaffected.
1037
+
1038
+
This applies to **both bare React Native and Expo** (for Expo, edit the generated file after `expo prebuild`). Edit`android/app/src/main/java/.../MainActivity.kt` (or `.java`) so `onCreate` passes `null`:
1039
+
1040
+
```diff
1041
+
+ import android.os.Bundle
1042
+
1043
+
class MainActivity : ReactActivity() {
1044
+
override fun getMainComponentName(): String = "YourApp"
1045
+
1046
+
+ override fun onCreate(savedInstanceState: Bundle?) {
### How the login continues after the app restarts
1066
+
1067
+
When the process was killed mid-login, the original `authorize()` promise no longer exists — the app has cold-started. The recovered credentials are cached natively and handed back to your app on the next launch through `resumeSession()`. How you consume them depends on which API you use:
1068
+
1069
+
**Hooks API (`Auth0Provider`/`useAuth0`):** Nothing to do. `Auth0Provider` automatically calls `resumeSession()`while it initializes, stores the recovered credentials, and populates `user`. After the restart the user simply appears logged in:
1070
+
1071
+
```jsx
1072
+
const { user, isLoading } = useAuth0();
1073
+
// After process-death recovery, `user` is populated once `isLoading` becomes false —
1074
+
// exactly as if a normal login had completed.
1075
+
```
1076
+
1077
+
**Imperative API (`new Auth0(...)`):** Call `resumeSession()` yourself once on app launch, before deciding whether the user is logged in. It resolves the recovered credentials, or `null` when there is nothing to recover (the normal case on every other launch and on iOS/web):
1078
+
1079
+
```js
1080
+
const auth0 = new Auth0({ domain, clientId });
1081
+
1082
+
// On app launch, before routing to your logged-in/logged-out screens:
>**Note:** This recovery also relies on a fix in the underlying `Auth0.Android`SDK. Ensure you are on a version that includes it (see the changelog). On iOS and web `resumeSession()` always resolves `null`, since they do not have thisclassof failure.
0 commit comments