skip to Main Content

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?

2

Answers


  1. Mail:

    const subject = "Mail Subject";
    const message = "Message Body";
    Linking.openURL(`mailto:[email protected]?subject=${subject}&body=${message}`)
    

    Phone call:

    const phone = "+380775454545455";
    Linking.openURL(`tel:${phone}`)
    
    Login or Signup to reply.
  2. 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 = "[email protected]";
    
    // 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search