简体   繁体   中英

React-Navigation Android deep linking not working

I'm using react-navigation@3.0.0 in my react-native app, I've followed the deep linking guide https://reactnavigation.org/docs/en/deep-linking.html .

iOS works as expected but I'm getting funny results for android.

When I run:

adb shell am start -W -a android.intent.action.VIEW -d "appscheme://apphost/some/path" com.app.bundle

I get following warning , Warning: Activity not started, its current task has been brought to the front. (AndroidManifest has android:launchMode="singleTask") Warning: Activity not started, its current task has been brought to the front. (AndroidManifest has android:launchMode="singleTask")

followed by:

Status: ok Activity: com.app.bundle/.MainActivity ThisTime: 203 TotalTime: 203 WaitTime: 207 Complete

But all that appears to happen is the app re-boots without actually navigating to the path.

Has anyone figured out how react-navigation 2.x/3.0.0 does android deep links?

Big thanks in advance!

I found that it is important to pass the prop uriPrefix:

<PrimaryNav uriPrefix={prefix} />

directly to the component that does createStackNavigator()

in my case I was doing it in the App.js but moved it to the navigations/index.js

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM