Git Product home page Git Product logo

Comments (4)

luisfcofv avatar luisfcofv commented on June 9, 2024

Hi @esutton, did you add the getInitialURL() method to your app?
This method is called when a deep link launches the app.

componentDidMount() {
  Linking.getInitialURL().then((url) => {
    if (url) {
      Linking.openURL(url);
    }
  }).catch(err => console.error('An error occurred', err));
}

If yes, is componentDidMount being called?
This might also be a misconfiguration in your AppDelegate.m

I'm updating the example to handle this case.

from react-native-deep-linking.

esutton avatar esutton commented on June 9, 2024

Hi @luisfcofv, no I did not use getInitialURL()

All I had was.

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

I will try getInitialURL()

I can see openURL being called in AppDelegate.m. I can copy email attachments to iOS app if app had been launched previously.

Thanks again!

from react-native-deep-linking.

esutton avatar esutton commented on June 9, 2024

Works great! Thank you @luisfcofv

  componentDidMount() {
    Linking.getInitialURL()
      .then(url => {
        if (url) {
            const event = {};
            event.url = url;
            this._handleOpenURL(event);
        }
      })
      .catch(err => console.error('An error occurred', err));

    Linking.addEventListener('url', this._handleOpenURL);
  },

from react-native-deep-linking.

luisfcofv avatar luisfcofv commented on June 9, 2024

I don't think your timeout is necessary.

One tip, no need to call this._handleOpenURL inside getInitialURL()
You can have your function as:

import { Linking } from 'react-native'
...
componentDidMount() {
  Linking.addEventListener('url', this._handleOpenURL);
  Linking.getInitialURL()
    .then(url => {
      if (url) {
        Linking.openURL(url);
      }
    })
    .catch(err => console.error('An error occurred', err));
}

Closing this issue :)

from react-native-deep-linking.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.