There is the our application which should be available on company://upload. I created the itent-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="company"
android:host="upload" />
</intent-filter>
It is opening the application, but inside the react-native I couldn't catch the url. My implementation:
componentWillMount() {
Linking
.getInitialURL()
.then(event => this.handleOpenURL(event))
.catch(console.error);
Linking.addEventListener('url', this.handleOpenURL);
this.props.loadCredentials();
}
handleOpenURL(event) {
console.log(event);
switch (event.url) {
case `${Config.APP_SCHEMA}upload`:
Actions.Upload();
break;
default:
Actions.Home();
}
}
router.js
and this is the first React component. Versions:
"react-native": "0.42.0",
Android SDK 23
I wrote a script for testing the deep-linking:
adb shell am start -W -a android.intent.action.VIEW -d "company://$1" com.companyapps/.MainActivity
The deep-linking is right, the problem was with the Java part of my application.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.