I'd like for users to be able to share a link (e.g. app.com/SKFLA - this is primarily because deep links on their own aren't clickable) via Facebook etc. When clicked, this redirects to a deep link app://SKFLA. If the app is installed, this opens the app - this is all working fine so far. But if the app isn't installed, I'd like to open the app store on the relevant page. Is this achievable? Thanks!
You need UNIVERSAL LINKS
Please check
Android
https://developer.android.com/training/app-links/
It might also require some extra server-side setup.
If someone is still stuck in this issue and needs easiest solution, you will love node-deeplink
1.) If app is installed: Calling an app through deep linking will always call componentDidMount of root component. So you can attach a listener there. Like:
Linking.getInitialURL()
.then(url => {
if (url) {
this.handleOpenURL({ url });
}
})
.catch(console.error);
Linking.addEventListener('url', this.handleOpenURL);
handleOpenURL(event) {
if (event) {
console.log('event = ', event);
const url = event.url;
const route = url.replace(/.*?:\/\//g, '');
console.log('route = ', route);
if(route.match(/\/([^\/]+)\/?$/)) {
const id = route.match(/\/([^\/]+)\/?$/)[1];
const routeName = route.split('/')[0];
if (routeName === 'privatealbum') {
Actions.privateAlbum({ albumId: id });
}
}
}
}
2.) If app is not installed: Just set up a route in your server and node-deeplink package will handle the bridging between web browser to app store when a app is not installed in your mobile.
By this, both the cases will be handled without any struggle
Not sure about native behavior. We used third-party service like https://branch.io/deepviews/. There is a bunch of similar services.
The easiest way I've found is to define a universal link, and if the app can't be open (is not installed) redirect them via mod_rewrite
to the app store.
Let's say you have an app where you want to join a group and your universal link is somethign like www.yourdomain.com/joingroup?name=whatever
having this add a rule in your server for the users that reach that link from an iPhone or ipad that don't have the app installed redirect them user the app store.
# Enable mod_rewrite module
server.modules += ( "mod_rewrite" )
# Redirect iOS users from /joingroup to App Store URL
$HTTP["useragent"] =~ "iPhone|iPad|iPod" {
$HTTP["host"] =~ "^(www\.)?mydomain\.com$" {
url.redirect = ( "^/joingroup(.*)" => "https://apps.apple.com/theidoftheappstore" )
}
}
© 2022 - 2024 — McMap. All rights reserved.