On an iPhone 14 Pro, I have no issues. On an LG V30 (as well as a Pixel 5 emulator), this issue occurs. What’s happening is on Android, I tap login (which is just a Pressable that triggers the login func below), I am prompted to enter creds, I get a successful login in the Auth0 console, but I do not redirect because user
is still null from the useAuth0
hook. I click login again (sometimes twice more) and eventually I am redirected and a successful exchange log appears in the Auth0 console.
react-native: 0.71.8
react-native-auth0: 2.17.4
Here is my code:
const { authorize, user, isLoading, error } = useAuth0();
useEffect(() => { // this doesn't fire until login (below) fires at least once more
if (user !== undefined && user !== null) {
setIsLoadingAuth(true);
const userType = user["https://mysite.com/userType"];
const userId = user["https://mysite.com/internalUserId"];
userStore.setUserId(userId);
userStore.setUserType(userType);
userStore.createUser();
userStore.user.setEmail(user["email"]);
setIsLoadingAuth(false);
}
}, [user]);
const login = async () => {
setIsLoadingAuth(true);
try {
await authorize({
scope: "offline_access",
audience: "https://mysite.com/",
});
// error gets populated here: {"error": "a0.session.user_cancelled", "error_description": "User cancelled the Auth"}
} catch (e) {
console.log(e); // no error here
}
setIsLoadingAuth(false);
};