Could not open URL... No Activity found to handle Intent

Viewed 493

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 }"

1 Answers

Instead of using Linking.openURL I used linkTo, as in the example below:

import { useLinkTo } from '@react-navigation/native';
...
const linkTo = useLinkTo();

useEffect(() => {
  linkTo('/notifications');
}, []);
Related