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);
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
dapidmini
  • 1,490
  • 2
  • 23
  • 46

1 Answers1

0

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