4

enter image description here

Code:
Linking.openURL('sms:'+number+'?body=Hi');

I try to open message app with mobile no and content.but mobile no and content combine together in to section.How to fix this issue?any help will be appricated.thanks in advance

arun rajesh
  • 181
  • 3
  • 16

5 Answers5

8

The working syntax on iOS (as at 11.2) appears to be sms:123&body=mybody, note the & as a separator rather than ?.

Be warned though this & separator is contrary to RFC5724 (and Android), so somewhat likely to change in future iOS versions.

Also, interestingly Apple has this to say (emphasis added):

The format for URLs of this type is sms:<phone>, where <phone> is an optional parameter that specifies the target phone number of the SMS message. This parameter can contain the digits 0 through 9 and the plus (+), hyphen (-), and period (.) characters. The URL string must not include any message text or other information.

Community
  • 1
  • 1
Rob Hogan
  • 2,442
  • 19
  • 23
8

If you want the user to select from contacts, you can pass null as follows:

Linking.openURL(`sms:&addresses=null&body=My sms text`);

Otherwise, in order to have multiple numbers already selected in iOS:

Linking.openURL(`sms:&addresses=replace_with_comma_seperated_numbers&body=My sms text`);
Gabcvit
  • 1,468
  • 1
  • 15
  • 32
Akshay Soam
  • 1,580
  • 3
  • 21
  • 39
0

this is working for me on ios. you can provide comma separated numbers.

Linking.openURL(`sms:/open?addresses=923335251661,9231213341&body=My sms text`);

gamingumar
  • 979
  • 8
  • 14
0

Here is what i do....

Linking.openURL(`sms:${phone}?body=${msg}`)

give it a try!!!

STA
  • 30,729
  • 8
  • 45
  • 59
-1
 For opening message box 

Linking.openURL(`sms:${"9210457731"}?body= `)


For opening message box  with text
Linking.openURL(`sms:${"9210457731"}?body= 'Hi ram ji' `)

 const onPressMobileNumberClick = (number) => {
    let phoneNumber = '';
    if (Platform.OS === 'android') {
      phoneNumber = `tel:${number}`;
    } else {
      phoneNumber = `telprompt:${number}`;
    }

    Linking.openURL(phoneNumber);
 }

 const onPressEmailClick = (email) => {
    Linking.openURL('mailto:'+email)
  //  Linking.openURL('mailto:Care@amazon.com')
 }
     
 const onPressMessageClick = (email) => {
    Linking.openURL(`sms:${"9210457731"}?body= `)
 }
Sourabh Gera
  • 862
  • 7
  • 7
  • 1
    While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. You can find more information on how to write good answers in the help center: https://stackoverflow.com/help/how-to-answer . Good luck – nima Oct 08 '21 at 11:30