0

I want to send a whatsapp message using this code below, but I don't know how to add line breaks in the message. I tried using \n but it still appears as 1 line.

the function

export function sendWhatsApp(phone='', msg='') {
  let phoneWithCountryCode = `62${ltrim(phone, '0')}`; // 628123456789
  let mobile = `+${phoneWithCountryCode}`;
  let url = `whatsapp://send?phone=${mobile}&text=${msg}`;

  Linking.openURL(url).then((data) => {
    console.log('WhatsApp Opened');
  }).catch(() => {
    alert('Please make sure WhatsApp installed on your device');
  });
}
// end export function sendWhatsApp

how I call the function

let msg = `Hello \n
This is first line of message \n
this is the second line`
;
sendWhatsApp('8123456789', msg);
0

1 Answer 1

0

Use "\r\n", it will work.

Sign up to request clarification or add additional context in comments.

1 Comment

sorry, not working.. I still get one line of string instead of multiple lines

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.