Duplicate App prompted on Android
Checklist
- [x] The issue can be reproduced in the react-native-auth0 sample app (or N/A).
- [x] I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- [x] I have looked into the API documentation and have not found a suitable solution or answer.
- [x] I have searched the issues and have not found a suitable solution or answer.
- [x] I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- [x] I agree to the terms within the Auth0 Code of Conduct.
Description
When users on Android for an application built on expo React Native, attempt to login or logout, they are prompted the same application twice, being asked which one to open. Please see the attached screenshots.
I attempted multiple solutions I found in different issues already posted and closed but the most I was able to do was preven the dupplication bug from occuring in Development mode but in production the application would crash on being opened with an error message about malformed intents.
I have been able to determine that the origin most likley comes from duplicate intents created in the android/app/src/main/AndroidManifest.xml where we have one from expo deep linking and or expo router and another from react-native-auth0 package hence when the user logs in or logs out because they are two duplicate intents, the OS prompts the user to pick between the two.
Here are the duplicate intents I identified in the AndroidManifest.xml
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="zurigardens"/>
<data android:scheme="exp+zuri-gardens"/>
</intent-filter>
<intent-filter android:autoVerify="true" data-generated="true">
<action android:name="android.intent.action.VIEW"/>
<data android:scheme="blackvalleycomicsplatform" android:pathPrefix="/android/dev.siziba.black_valley_comics/callback"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
<activity android:name="com.auth0.android.provider.RedirectActivity" tools:node="replace" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="blackvalleycomicsplatform" android:pathPrefix="/android/dev.siziba.black_valley_comics/callback" android:host="dev-vttkdxzvui4y8a11.us.auth0.com"/>
</intent-filter>
</activity>
The behaviour was duplicated in a seperated project as well, please see the screenshot below
Here is the android block from the relevent app.json
"android": {
"edgeToEdgeEnabled": true,
"predictiveBackGestureEnabled": false,
"versionCode": 1,
"package": "package_name",
"intentFilters": [
{
"action": "VIEW",
"autoVerify": true,
"category": [
"DEFAULT",
"BROWSABLE"
],
"data": {
"scheme": "Auth0 scheme",
"pathPrefix": "/path/prefix"
}
}
]
},
Reproduction
- Create an expo app, can use npx create-expo-app@latest
- Follow the steps provided on Auth0 guide for Expo React Native app Expo Auth0 guide
- Add the react-native-auth0 plugin with the needed relevant values adding the domain and a custom scheme
- To the android block in app.json add the intent filters with a scheme and path prefix
- Run development build on android and attempt to login
Additional context
No response
react-native-auth0 version
5.2.1
React Native version
0.81.5
Expo version
54.0.29
Platform
Android
Platform version(s)
Gradle 8.14.3 , Android SDK API level 36
Hi @MockAirplane700,
It looks like you might have two versions of the app installed on your device. This can happen if the package name’s letter casing was changed, resulting in the system treating them as separate apps. We recommend using a fully lowercase package name, as the callback URL is generated internally in lowercase.
To resolve this, please uninstall both apps from your device and then reinstall the app using the current (lowercase) package name.
@subhankarmaiti
There is only one version of the app installed.
The package name for the app is already in lower case, it looks something like "com.package.package_name".
We had to use a custom schema because the package name was written with underscores. The use of the custom schema seems to trigger the creation of dual intents in the application, as we end up with two intents that route to the same application triggering the duplicate application prompt.
It seems for some reason duplicate intents are created somewhere in the app such with one version of the app installed, the same still occurs, hence there is only one application.
Hi @MockAirplane700
Instead of creating a new intent-filter, you can take advantage of customScheme by updating app.json.
"plugins": [
[
"react-native-auth0",
{
"domain": "AUTH0-DOMAIN",
"customScheme": "YOUR_CUSTOM_SCHEME"
}
],
If you do so, our sdk will take care of converting the intent filter to the format
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="YOUR_CUSTOM_SCHEME" android:pathPrefix="/android/YOUR_APPLICATION_ID/callback" android:host="AUTH0-DOMAIN"/>
</intent-filter>
so your redirect url would be ${YOUR_CUSTOM_SCHEME}://${AUTH0-DOMAIN}/android/${YOUR_APPLICATION_ID}/callback
and you have to pass the same during authorize and clearSession call.