Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opneUrl react-native linking call, mailto

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))
  }
like image 233
AleXzpm Avatar asked Jun 26 '17 22:06

AleXzpm


People also ask

How do I open mailto In react native?

import { Linking } from 'react-native' React Native Open Mail <TouchableOpacity onPress={() => Linking. openURL('mailto:[email protected]')}> <Text>[email protected]</Text> </TouchableOpacity> React Native Open Mail With Subject & Body <TouchableOpacity onPress={() => Linking.

How do I send an email in react native?

Send Emails in a React App Using Mailto It's the simplest way to send an email from a frontend app. Put the email address that you want to receive the email after mailto: That's all it takes to open the user's default email client on their machine and populate the “recipient” field with the intended email.

How do you deep link in react native?

There are two ways to handle Deep Linking in a React Native app: Without navigation: by invoking React Native's core library via JavaScript and directly calling Linking . You can learn more about this in React Native's official documentation. With navigation: by configuring React Navigation library.


1 Answers

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

like image 58
AleXzpm Avatar answered Oct 13 '22 00:10

AleXzpm