WebBrowser Module: Linking.addEventListener doesn't fire on URL change

#1

Hey guys,

I’ve been trying to implement a web-based OAuth flow using the WebBrowser module and I’ve been trying to implement Linking.addEventListener with it so I can know when a redirect happens.

The issue is the event listener that I assign, doesn’t fire at all. It doesn’t console.log or dismissBrowser or anything. Any help or pointers appreciated!

Made a snack: https://snack.expo.io/H1PPFXoiZ

I stumbled upon this example from Expo and I don’t see much of a difference between the approach there and in my code: https://github.com/expo/examples/blob/bf4b800f2515e6a03e6896cd7ddc8003ae627457/with-facebook-auth/app/App.js

#2

Hello @abhishek

I had similar problem. U can add a Listener like this one:

Linking.addEventListener('url', (url) => {this._handleUrl(url.url)});

and _hanedle url function:

    _handleUrl = (url) => {
        console.log("URL:",url)
    }

idk how but it worked for me :stuck_out_tongue:

#3

You just saved my life and I still don’t know how! But it works.