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))
}
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.
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.
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.
The code works perfectly the problem was the iOS simulator, it needs to be tested on a device.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With