Firebase dynamic links based on mobile's OS - android

I want to create a dynamic link which will redirect to different places base on mobile's OS is Android or iOS, here is my code:
const link = await firebase.dynamicLinks().buildShortLink({
link: `https://play.google.com/store/apps/details?id=me.finan.app`,
domainUriPrefix: 'https://finandev.page.link/',
android: {
fallbackUrl: 'https://play.google.com/store/apps/details?id=me.finan.app',
packageName: 'me.finan.app',
},
ios: {
fallbackUrl: 'https://apps.apple.com/vn/app/s%E1%BB%95-b%C3%A1n-h%C3%A0ng/id1560099589',
bundleId: 'me.finan.app',
},
})
It always goes to CH Play, how can I make it go to Play Store if the current mobile opening the link is iPhone?

Related

not able to pass ofl parameter in request body in REST api of firebase dynamic link?

I am using firebase dynamic links where i used their REST api to create dynamic link. I am able to create the short link by using REST api and created link is working fine on android and ios app as well as on mobile browser. But i used same link on desktop browser it is not redirecting to play store page. Firebase provided "ofl" as a parameter to provide my intended functionality but there is no documentation to how i can pass that parameter in request body. Can anyone help me out ?
{
"dynamicLinkInfo": {
"domainUriPrefix": "my_custome_domain_name",
"link": "my_dynamic_link",
"androidInfo": {
"androidPackageName": "my_package_name",
"androidFallbackLink": "https://play.google.com/store/apps/details?id=my_package_name",
"androidMinPackageVersionCode": "2"
}
"navigationInfo": {
"enableForcedRedirect": true,
}
},
"suffix": {
"option":"UNGUESSABLE"
}
}
As far as I know, ofl is used to specify a different behavior on desktop, Like to display your webpage which gives brief info about your app or to display a link which can redirect to play store.... In your case you directly want to redirect to play store, so for that you can use desktopFallbackLink and provide your play store link of app
eg:
{
"dynamicLinkInfo":{
"domainUriPrefix":"my_custome_domain_name",
"link":"my_dynamic_link",
"androidInfo":{
"androidPackageName":"my_package_name",
"androidFallbackLink":"https://play.google.com/store/apps/details?id=my_package_name",
"androidMinPackageVersionCode":"2"
},
"navigationInfo":{
"enableForcedRedirect":true,
}
},
"suffix":{
"option":"UNGUESSABLE"
},
"desktopInfo":{
"desktopFallbackLink":"https://www.other-example.com/"
}
}

How to use Web Share API on Website for web-view?

I already created a web-view android app from my website.
I added Web Share API code to my website to load share button on android browser (It works fine) but when I visit my website through the android app, share button doesn't work (Nothing happens when I press the button).
Any idea to solve the problem? Is it possible?
Web Share API Code
<button id="btn-share">Share</button>
<script>
window.addEventListener('load', function() {
if(!navigator.share) {
document.querySelector('.share-container').innerHTML = 'Web Share API not supported in this browser';
return;
}
document.getElementById('btn-share').addEventListener('click', function() {
navigator.share({
title: 'Check out this web share API demo',
text: 'Its really cool',
url: 'https://mobiforge.github.io/web-share-api.html',
});
});
});
</script>
Navigator.share API not supports in WebView. You can use it only in mobile browsers except Firefox.
Web share is not yet support for browser but you can use fall back method.
if (navigator.share) {
navigator.share({
title: 'harish tech',
text: 'Check out harishtech.com.',
url: 'https://harishtech.com', })
.then(() => console.log('Successful share'))
.catch((error) => console.log('Error sharing', error));
}else{
// Your fall back code here
}
For more info check out the link share like native app

React native app auth (android) shows two apps with same redirect scheme?

Click here to view screenshot here
I am using react native app auth with Azure active directory and in android after redirecting back to the app, two apps are shown (like in the above screenshot) , if i select the correct app the app works as expected, but if i select the other, the app crashes. How can i fix this issue and show only one app!
const config = {
issuer: 'https://login.microsoftonline.com/your-tenant-id',
clientId: 'your-client-id',
redirectUrl: 'urn:ietf:wg:oauth:2.0:oob',
scopes: [], // ignored by Azure AD
additionalParameters: {
resource: 'your-resource'
}
};
// Log in to get an authentication token
const authState = await authorize(config);
// Refresh token
const refreshedState = await refresh(config, {
refreshToken: authState.refreshToken,
});
Try not to put "scheme" option into app.json and use a redirectUrl like this.
<your.package.identifier>://oauthredirect
According to this AppAuth OAuthRedirect, AppAuth uses for scheme the android.package identifier. For example if your package.identifier is "your.company.app", use a redirectUrl like this: your.company.app://oauthredirect. It works for me.

How to redirect to the app store from a deep link if the app is not installed?

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
IOS https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html
Android
https://developer.android.com/training/app-links/
It might also require some extra server-side setup.
Not sure about native behavior.
We used third-party service like https://branch.io/deepviews/.
There is a bunch of similar services.
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

How to open Other app from ReactNative?

How to open other apps (Gmail, Camera) from ReactNative. How can I pass data from current scene to other app?
I found this npm library react-native-app-link which can open other apps. This is based on deep linking, if you have any deep links then this library can help. This doesn't open apps just by giving the android package name or ios app id.
https://github.com/FiberJW/react-native-app-link
you can mange opening other apps using Linking
Code sample for opening the dialer
const urlToOpen = 'tel:1234567890';
Linking.openURL(urlToOpen);
You can refer to the official doc here, it just predefines some applications, which can be opened.
However, if the question is about to open just about any application, I hope there is no solution till now.
react-native-app-link has some redundant config (e.g. appStoreLocale parameter), so I wrote my own realization using their code:
import { Alert, Platform, ToastAndroid } from 'react-native';
const isIos = Platform.OS === 'ios';
const showNotification = (text) => isIos
? Alert.alert(text)
: ToastAndroid.show(text, ToastAndroid.SHORT);
const openApp = ({ url, appStoreId, playMarketId, name }) => {
Linking.openURL(url).catch(err => {
if (err.code === 'EUNSPECIFIED') {
Linking.openURL(
isIos
? `https://apps.apple.com/app/id${appStoreId}`
: `https://play.google.com/store/apps/details?id=${playMarketId}`,
);
} else {
showNotification(`Can't open ${name} app`);
}
});
};
It tries to open the app by the specified link, and if the user doesn't have such one, it opens its page in AppStore or Play Market.

Categories

Resources