Jac*_*cob 6 android deep-linking react-native
按照以下指南尝试为我的项目设置深度链接:https : //reactnavigation.org/docs/en/next/deep-linking.html
但是,在尝试实施时,我总是看到主屏幕而不是帐户屏幕。
运行这样的示例:
adb shell am start -W -a android.intent.action.VIEW -d "hdsmobileapp://main/account/" com.digithurst.hdsapp
Run Code Online (Sandbox Code Playgroud)
我有一个嵌套的导航,可以在下面看到:
import {createDrawerNavigator, createStackNavigator} from "react-navigation";
import {NavigationOptions} from "./components/NavigationOptions";
import {SideMenu} from "./components/SideMenu";
import LoginScreen from "./containers/LoginScreen";
import MainScreen from "./containers/MainScreen";
import MyAccountScreen from "./containers/MyAccountScreen";
import SplashScreen from "./containers/SplashScreen";
import { createAppContainer} from "react-navigation";
const AppContainer = createAppContainer(
{
Splash: {
screen: SplashScreen,
navigationOptions: {
header: null,
},
},
Login: {
screen: createStackNavigator(
{
Login: {
screen: LoginScreen,
navigationOptions: {
header: null,
},
},
},
)
},
Main: {
screen: createDrawerNavigator(
{
Main: {
screen: createStackNavigator(
{
Main: {
screen: MainScreen,
navigationOptions: NavigationOptions.getSearchFilterHeader("title.main"),
},
MyAccount: { screen: MyAccountScreen, path: 'account',},
},
),
},
}, {
drawerWidth: 300,
initialRouteName: "Main",
contentComponent: SideMenu,
},
),
},
},
);
Run Code Online (Sandbox Code Playgroud)
然后在App.tsx中包含以下内容:
import React, {Component} from "react";
import SplashScreen from "react-native-splash-screen";
import {Provider} from "react-redux";
import RootStack from "./navigation";
import AppContainer from "./navigation";
import store from "./store/store";
import {createAppContainer} from 'react-navigation'
import { AppRegistry } from 'react-native';
class App extends Component {
public componentDidMount() {
SplashScreen.hide();
}
public render() {
return (
<Provider store={store}>
<RootStack uriPrefix={prefix} />
</Provider>
);
}
}
const prefix = 'hdsmobileapp://hdsmobileapp';
const MainApp = () => <AppContainer uriPrefix={prefix} />;
AppRegistry.registerComponent('App', () => MainApp);
export default App;
Run Code Online (Sandbox Code Playgroud)
有什么明显的我想念的地方吗?
小智 0
main您提供的 URL 部分 ( )hdsmobileapp://main/account/未在您的导航声明中指定。
您应该将其添加到uriPrefix道具中,或者在尝试到达该/account位置时避免它经过它。
adb shell am start -W -a android.intent.action.VIEW -d "hdsmobileapp://account/" com.digithurst.hdsapp
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
165 次 |
| 最近记录: |