0

I'm currently working on ao oauth implementation. So I've got a button which opens the browser and asks for the login information. Then this page redirects to the app using DeepLinking. The problem is that I cannot get the passed data from the website using the event listener.

    componentDidMount() {
        Linking.addEventListener('url', this.handleUrl);
    }

    componentWillUnmount() {
        Linking.removeEventListener('url', this.handleUrl);
    }

    handleUrl(event) {
        console.log(event); //I just dont get any console output
    }

    openAuth() {
        Linking.openURL('https://dribbble.com/oauth/authorize?client_id=MY_ID&redirect_uri=Trippple://Login&state=MY_PW')
    }
Alwaysblue
  • 9,948
  • 38
  • 121
  • 210
Ludwig Bossle
  • 367
  • 2
  • 3
  • 18
  • 1
    Is handleUrl being called? Do you see it output undefined or something in XCode or Chrome? I did a similar setup using Linking on iOS, and i was able to check for a passed URL, and parse out token information from it. – agmcleod Jul 06 '16 at 13:44
  • I don't think so sice nothing is being logged to the console. – Ludwig Bossle Jul 06 '16 at 14:37
  • Now, after I added this.handleUrl() it returns undefined after I reload the app but nothing after the app ist opened again by the link. – Ludwig Bossle Jul 06 '16 at 15:38
  • Well if you call the function directly, no doubt it would do just that :). Double check your plist file that you added the scheme url correctly http://stackoverflow.com/questions/8201724/how-to-register-a-custom-app-opening-url-scheme-with-xcode-4. Also that you added the methods in the AppDelegate as documented: https://facebook.github.io/react-native/docs/linking.html. – agmcleod Jul 06 '16 at 15:56
  • I'm on android :) forgot to metion that ^^ – Ludwig Bossle Jul 06 '16 at 18:53
  • 1
    Ah my bad. I think last i looked it wasnt added to android yet. but yeah i think checking the react-native docs over, and the android steps on setting up a linkable activity/intent would be key :) – agmcleod Jul 06 '16 at 20:22

1 Answers1

0

Okay I fixed my issue:

I just did this:

If you wish to receive the intent in an existing instance of MainActivity, you may set the launchMode of MainActivity to singleTask in AndroidManifest.xml.RN Docs

Ludwig Bossle
  • 367
  • 2
  • 3
  • 18