无法打开URL ...没有发现要处理意图的活动
我正在尝试在我的React Native应用程序中应用深层链接。我遵循文档,尝试进行第一次测试时,我遇到了一些问题,我相信这是因为使用了堆栈导航器和抽屉菜单。
堆栈:
const SignedInStack = () => (
<Stack.Navigator>
<Stack.Screen name='Confluence' component={Confluence} />
<Stack.Screen name='QRCode' component={Main} />
<Stack.Screen name='Notifications' component={Notifications} />
</Stack.Navigator>
)
drawermenu:
const DrawerMenu = () => (
<Drawer.Navigator
screenOptions={{ headerShown: false }}
drawerContent={(props) => <CustomDrawerContent {...props} />}
>
<Drawer.Screen
name="SignedInStack"
component={SignedInStack}
/>
<Drawer.Navigator/>
);
app.js:
const App = () => (
<NavigationContainer linking={{
prefixes: ['example://'],
config: {
screens: {
Notifications: 'notifications',
},
},
}}>
<DrawerMenu />
</NavigationContainer>
);
我在堆栈的初始屏幕上的第一次使用:
useEffect(() => {
Linking.openURL('example://app/notifications');
}, []);
尝试重定向到通知屏幕后,我会收到以下错误消息: “错误:无法打开URL'示例:// app/notifications':找不到可以处理意图的活动{act = android.intent.intent.action.view dat = example = example:// app/notifications flg = 0x10000000}”
I'm trying to apply deep linking in my react native app. I followed the documentation and when trying to do the first test I had some problems, I believe it's because of using stack navigator and drawer menu.
Stack:
const SignedInStack = () => (
<Stack.Navigator>
<Stack.Screen name='Confluence' component={Confluence} />
<Stack.Screen name='QRCode' component={Main} />
<Stack.Screen name='Notifications' component={Notifications} />
</Stack.Navigator>
)
DrawerMenu:
const DrawerMenu = () => (
<Drawer.Navigator
screenOptions={{ headerShown: false }}
drawerContent={(props) => <CustomDrawerContent {...props} />}
>
<Drawer.Screen
name="SignedInStack"
component={SignedInStack}
/>
<Drawer.Navigator/>
);
App.js:
const App = () => (
<NavigationContainer linking={{
prefixes: ['example://'],
config: {
screens: {
Notifications: 'notifications',
},
},
}}>
<DrawerMenu />
</NavigationContainer>
);
My first useEffect on initial screen of my stack:
useEffect(() => {
Linking.openURL('example://app/notifications');
}, []);
Right after trying to redirect to the notifications screen I get the following error message:
"Error: Could not open URL 'example://app/notifications': No Activity found to handle Intent { act=android.intent.action.VIEW dat=example://app/notifications flg=0x10000000 }"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
而不是使用
linking.openurl
我使用Instead of using
Linking.openURL
I used linkTo, as in the example below: