Expo deeplinking issue with addEventListener


#1

Using create-react-native-app with expo. The app is not ejected.

I use the following event handlers on a componentDidMount() on the entry file of the application.

    Linking.addEventListener('url', this.handleEvent)
    Linking.getInitialURL().then(url => this.handleUrl(url))

The expo URL structure i’m testing in development is - exp://mb-6uw.EXPO_ACCOUNT.PROJECT_NAME.exp.direct/+/QUERY_STRING

The initial URL handler works correctly and the query string can be processed. However the addEventListener call is not being called at all when the app is already open and a deep link is used.

https://docs.expo.io/versions/latest/guides/linking.html - There is no setup requirements in the linking page so the event listener should be working.

Are there any setup requirements or approaches to resolve this issue?


#2

Hi @georgelovegrove - could you possibly share a minimal example that repros this?


#3

Additionally, it’s worth noting that the callback for Linking.addEventListener('url', this.handleEvent) receives an event and not a url string directly. To get the url from that you will need to do event.url. So, instead you can do Linking.addEventListener('url', ({ url }) => this.handleEvent(url))


#4

Hey Brent,

Yeh expecting an event like in the docs. I’ve made a repo updating the graphcool example using expo, I have an auth component like this - https://github.com/georgelovegrove/graphcool-expo-auth0/blob/master/src/auth/auth.js

I have an entry file in the application i’m building that has the same event handlers.

The auth0 example part works - if I open a link with the web browser in expo then the redirect back from auth0 can be returned with the token.

However what i’m trying to do now is either open from the clipboard in expo or enter the URL into a browser and it opens the app with that information whilst the app is already open rather than a redirect from an expo browser thats been opened in-app. Only works when the app is closed and the app is then opened with the initialUrl.

Great work on expo btw!


#5

Have you found any solution? I’m deling with the same problem. Android is working fine but on iOS it the listener never fires…


#6

sdk version, @fedealconada ?


#7

@notbrent
React Native: https://github.com/expo/react-native/archive/sdk-26.0.0.tar.gz
React: ^16.0.0
Expo: ^26.0.0


#8

I also have problem with AddEventListener, callback is not fired on IOS, but on Android it works as expected

Does somebody have a solution ?