Deep linking back to Expo app

#1

Hey :slight_smile:

I’m having an issue with deep linking back to my app when I’m running it in the Expo client - everything works fine in the binary builds.

In my login screen in componentDidMount, I set up a linking listener using

 Linking.addEventListener('url', this.handleDeepLink);

    const initialUrl = await Linking.getInitialURL();

    if (initialUrl) {
      this.handleDeepLink({ url: initialUrl });
    }

That is handled with

private handleDeepLink = (event: { url: string }) => {
    const { navigation } = this.props;

    const { path, queryParams } = Linking.parse(event.url);

    if (path === RouteNames.AuthStack.ResetPasswordScreen) {
      this.closeModal();
      navigation.replace(RouteNames.AuthStack.ResetPasswordScreen, queryParams);
    } else if (path === RouteNames.AuthStack.VerifyEmailScreen) {
      this.closeModal();
      navigation.replace(RouteNames.AuthStack.VerifyEmailScreen, queryParams);
    }
  };

The way I create the linking routes is using Linking.makeUrl, a la

Linking.makeUrl(RouteNames.AuthStack.ResetPasswordScreen,)

As a I said, this works fine on binary builds, but fails when testing the app using the Expo client on a release channel. I get the following error when returning to the app:

Do I need to change anything, or should this be a github issue? Thanks

#2

Have you tried deep linking to exp://exp.host/@brandheroes-shared/brandheroes and seeing if that works?

If that does work, then you might want to deep link into that url and everything else should be in the query string (maybe in a path variable).

#3

Pretty sure that works, but that’s not “deep” linking, that’s just opening the app :slight_smile: This is the way to do it according to the docs and examples.

I forgot to mention that I create the deep link using Linking.makeUrl('reset'), where I would expect the Expo SDK and client to be smart enough to handle the release channel in that link as well

1 Like
#4

Right, the difficulty here is that only one app can be associated with one url scheme. So expo is the app that has to have the intent filter matching the exp:// scheme, then it’s gotta know which app to fire, and then that intent is already handled so the other app that gets fired (yours) doesnt know what to do. Id suggest doing a bit more manual labor and forming a query string if you need deep links to work while in expo. Alternatively you could create different channels in testflight to accomplsih some of the same things that can be accomplished by having a company wide shared expo account.

closed #5

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.