opneUrl react-native linking call, mailto

AleXzpm picture AleXzpm · Jun 27, 2017 · Viewed 11.2k times · Source

I am trying to open a url ( "tel:061245124" or "mailto:[email protected]") and it says that i can handle url, also tried without the tel: or mail to but it crashes with a red screen. Urls like "http://test.com" work. What am I doing wrong?

    handlePress(url) {
    console.tron.log('Trying to access url')
    console.tron.log(url)
    Linking.canOpenURL(url).then(supported => {
      if (!supported) {
        console.tron.log('Can\'t handle url: ' + url)
      } else {
        return Linking.openURL(url)

      }
    }).catch(err => console.error('An error occurred', err))
  }

Answer

AleXzpm picture AleXzpm · Jun 27, 2017

The code works perfectly the problem was the iOS simulator, it needs to be tested on a device.