0

I need to make a call when I click on the button, or open mail in order to send a message, we usually use the a tag with the necessary mail: or tel: attributes for these purposes, but is it possible to do this using Linking.openURL like this?

onPress={() => Linking.openURL('+380775454545455')

If it possible, what should we add in order to do it?

Ksenia
  • 950
  • 6
  • 24
  • There is already same question and solution [here](https://stackoverflow.com/questions/50272908/cannot-open-phone-call-with-linking-openurl) – Alex Shtromberg Nov 22 '22 at 14:20

2 Answers2

2

Mail:

const subject = "Mail Subject";
const message = "Message Body";
Linking.openURL(`mailto:support@domain.com?subject=${subject}&body=${message}`)

Phone call:

const phone = "+380775454545455";
Linking.openURL(`tel:${phone}`)
P-A
  • 369
  • 1
  • 8
1

As referred to in the react-native's documentation you can open your mail or make a phone call using the Linking component.

Phone call:

const phoneNumber = "+123456789";
Linking.openURL(`tel:${phoneNumber}`);

Email:

const email = "support@expo.io";

// if you want to just open the mail app
Linking.openURL(`mailto:${email}`);

// if you want to open the mail app with subject and body
const subject = "Subject";
const body = "Body";

Linking.openURL(`mailto:${email}?subject=${subject}&body=${body}`);

You can also use the component to open a website, send an SMS, or even open other apps through Deep Linking. For further explanation please see the documentation

Luís Mestre
  • 1,851
  • 1
  • 11
  • 29