opneUrl react-native linking call, mailto
Asked Answered
A

1

23

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))
  }
Apostrophe answered 26/6, 2017 at 22:43 Comment(0)
A
59

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

Apostrophe answered 26/6, 2017 at 23:15 Comment(2)
Is this 'no-soluion' valid even for the 'tel:xxx' links? I'm not able to start dialer on ios simulatorHeader
yeah, you can not start the dialer on a simulator from what I have seen. Try using it on a device.Apostrophe

© 2022 - 2024 — McMap. All rights reserved.