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.
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))
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.
SDK 31 with react navigation v3. When the app is closed and open a link via mobile safari the app opens and navigates to the correct page. But once app is in background and I try to change the URL, nothing is happening. I have linked the RTCLink library via Pods and added the necessary code to AppDelegate.m but I am completely out of ideas and tried everything I could find.
Still experiencing this issue in expo SDK 34 with Android. I can only detect the opening of a deep link when app is closed. When using addEventListener when the app is in background, as the documentation says, nothing happens.
Tracing it through the code, the function gets called with the correct url, but it seems to just never reach the event listener…
I’ve tried linking and unlinking RCTLinkingIOS via the Podfile, but no luck so far…
I found the solution.
change this: Linking.addEventListener(‘url’, this.handleEvent)
to: Linking.addEventListener(‘url’, (data) => this.handleEvent(data))
It works for me.
@ chiu1028 Unfortunately this didn’t resolve the issue for me.
It’s Nov 2021, EXPO SDK 43 and the issue is still not resolved. The eventHandler works fine on android, but with iOS it doesn’t detect the re-entry back into the app.
Or perhaps there’s alternative auth flows I don’t know about? I’m trying to open a browser in order to get third-party permission and then redirect back into the expo app, where the eventHandler takes care of the incoming data. Any help?
EDIT: @chiu1028 Never-mind, sorry your solution did work for normal Linking.
I was unable to read the response because, I was using the “AuthSession.useAuthRequest” hook, and trying to listen to the response with “Linking.addEventListener”. Instead, I needed to to listen for the response with “response”, which was one of the methods returned on the useAuthRequest hook.