I have setup my React Native app to use Deep Linking with expo-linking, but for some reason it just does not work on Android (yet to implement on iOS). Opening the link just opens it in the web browser, and doesn't open the app as it should. Any idea why?
app.json
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
},
"package": "com.example.myapp",
"intentFilters": [
{
"action": "VIEW",
"data": [
{
"scheme": "https",
"host": "testlink.com",
}
],
"category": [
"BROWSABLE",
"DEFAULT"
]
}
]
},
This did not update the AndroidManifest, so I manually edited it:
AndroidManifest.xml
<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="https" android:host="testlink.com"/>
</intent-filter>
App.js
const linking = {
prefixes: ["https://testlink.com"],
};
useEffect(() => {
Linking.addEventListener("url", handleDeepLink);
return () => {
Linking.removeEventListener("url", handleDeepLink);
};
}, []);
return (
<NavigationContainer /*linking={linking}*/>
....
</NavigationContainer>
);
This worked fine with just the normal expo links, but is not working now I want a custom URL so that it opens in web browser on a computer, or on the app if it is installed.
At the core, the iOS Safari browser has built-in deep linking which makes it possible to deep-link to custom app schema-
myapp:///link-to-resources
. Chromium-based browsers used mostly on android don't support custom app schema in URL input field.The work-around is a setup simple web page that can redirect your app custom schema using Browser DOM Window API.