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

1

5 Answers 5

9

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.

1
  • possible to pop back into the previous app .?
    – Aman Deep
    Commented May 12, 2022 at 11:18
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`);
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`);

0

Here is what i do....

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

give it a try!!!

-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:[email protected]')
 }
     
 const onPressMessageClick = (email) => {
    Linking.openURL(`sms:${"9210457731"}?body= `)
 }
1
  • 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: stackoverflow.com/help/how-to-answer . Good luck 🙂
    – nima
    Commented Oct 8, 2021 at 11:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.