1

I have a working universal link it my website and I can read the link to fetch some data with getInitialUrl function but same universal link doesn't trigger addEventListener function.

  useEffect(() => {

dispatch(setLoaderScreen({}));
Linking.addEventListener('url', event => {
  console.log('event listener');
  if (event !== null) {
    if (String(event.url).includes('reset-page')) {
      props.navigation.navigate('Password');
      dispatch(setDeepLinkUrl({url: event.url}));
    }
  }
});

Linking.getInitialURL().then(url => {
  console.log('intial');
  if (url !== null) {
    if (String(url).includes('reset-page')) {
      props.navigation.navigate('Password');
      dispatch(setDeepLinkUrl({url: url}));
    }
  }
});


return () => {
  dispatch(closeLoader({}));
};}, []);
3
  • My functions also works with casual deeplinks.
    – nodabasi
    Commented May 24, 2022 at 8:09
  • Do you try open deep link from the app? Commented Nov 11, 2022 at 7:59
  • url event not fire either on my side :(
    – Lev
    Commented Dec 21, 2022 at 15:35

1 Answer 1

0

When I had this issue I realized I was missing this in my AppDelegate. It was part of the Linking documentation earlier, but I think React Native adds it automatically when creating your project now.

- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
{
return [RCTLinkingManager application:application
                 continueUserActivity:userActivity
                   restorationHandler:restorationHandler];
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.