Reputation: 1
I have one web app app.events6.com and React native app as well, I want to implement deeplink but its not working when from third party app clicking this link app.events.com/services/view/33 it is opnenig from browser evrytime instead of app.
I tried everyhing like modifying the android's manifest.xml file hosting assetlink.json file but still not working
here is the code manifest
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:theme="@style/AppTheme"
android:exported="true">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:autoVerify="true">
<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" />
<data android:host="app.events6.com" />
<data android:pathPrefix="/services/view/" />
</intent-filter>
</activity>
here is the code for deeplink
import dynamicLinks from '@react-native-firebase/dynamic-links';
import { Linking } from 'react-native';
const ANDROID_PACKAGE_NAME = 'com.biz.event6';
const IOS_BUNDLE_ID = 'com.biz.event6';
const APPLE_STORE_ID = '15232262224';
const config = {
screens: {
splashScreen: 'splash',
home: 'home',
packageDetail: 'packages/details/:packageId',
eventServiceDetail: 'services/view/:serviceId',
// MessagesScreen: 'MessagesScreen',
},
};
const linking = {
prefixes: ['app.events6.com/','events6'],
async getInitialURL() {
try {
const url = await Linking.getInitialURL();
const dynamicLinkUrl = await dynamicLinks().getInitialLink();
if (dynamicLinkUrl) {
return dynamicLinkUrl.url;
}
if (url != null) {
return url;
}
return 'events6://splash';
} catch (error) {
console.error('Error getting initial URL:', error);
}
},
subscribe(listener) {
const onReceiveURL = ({ url }) => {
listener(url);
};
Linking.addEventListener('url', onReceiveURL);
const handleDynamicLink = (dynamicLink) => {
listener(dynamicLink.url);
};
const unsubscribeToDynamicLinks = dynamicLinks().onLink(handleDynamicLink);
return () => {
unsubscribeToDynamicLinks();
Linking.removeEventListener('url', onReceiveURL);
};
},
config,
};
async function fireBuildLink(url, param = null) {
let link;
if (param) {
link = await dynamicLinks().buildShortLink({
domainUriPrefix: 'https://events.page.link',
link: `https://www.events6.com/share/${url}/${param}`,
android: { packageName: ANDROID_PACKAGE_NAME },
ios: {
bundleId: IOS_BUNDLE_ID,
appStoreId: APPLE_STORE_ID,
},
navigation: {
forcedRedirectEnabled: true,
},
});
} else {
link = await dynamicLinks().buildShortLink({
domainUriPrefix: 'https://events.page.link',
link: `https://www.events6.com/share/${url}`,
android: { packageName: ANDROID_PACKAGE_NAME },
ios: {
bundleId: IOS_BUNDLE_ID,
appStoreId: APPLE_STORE_ID,
},
navigation: {
forcedRedirectEnabled: true,
},
});
}
return link;
}
export { fireBuildLink, linking };
Tried:- Modifying the manifest.xml file various way Hostel assetlinks file at .wellknwon folder tried to change code in deeplink.js file
Expected:- App should be open when user clicking a link from third party app
Upvotes: 0
Views: 25