简体   繁体   中英

Can I launch the iPhone or Android SMS app from the browser with pre-filled body text?

I want to be able to launch the iPhone and/or Android SMS app with "body" or "message" field already having the correct text.

I came across this question however the top answer was only partially working for me and it didn't ask everything I was looking for.

From what I can tell, either of the following will launch the sms app on my iPhone and gives the correct number to send it to.

<a href="sms:1-234-567-8901">Send SMS</a>
<a href="sms:12345678901">Send SMS</a>

As soon as I ad something like ?body=hello or ?message=hello it fails to bring over the phone number and body text.

These fail:

<a href="sms:1-234-567-8901?body=hello">Send SMS</a>
<a href="sms:12345678901?message=hello">Send SMS</a>

Any help or insight would be greatly appreciated!

This will work on IOS to populate a message body:

without a number,

?body= will not work, must be &body=

<a href="sms://&body=your message here"> send a message </a>

or, with a number

<a href="sms://5555555555&body=your message here"> send a message </a>

I'm afraid the answer won't be what you're hoping for - currently neither Android nor iOS will let you launch an SMS from the browser with a pre-populated message body. You can only trigger a blank SMS from the browser to a specific number. This holds for all versions of iOS, and whilst I haven't tried it out on Android 4.0, I don't see anything pointing to a change. Sorry that it isn't better news!

Here's Apple's complete list of URL schemes that they support: Apple's URL Scheme Reference ,

The below worked fine on Android and blackberry devices

<a href="sms:12345678901">Send SMS</a>

<a href="sms:1-234-567-8901?body=hello">Send SMS</a>

<a href="sms:12345678901?message=hello">Send SMS</a>

On the other hand Iphone does not allow adding the pre-generated text message. it will only open with the recipient field filled.

This is working on Android:

eg,

<a href="sms://?body=Visit%20the%20best%20site%20at%20http://example.com">

or

<a href="smsto://?body=Visit%20the%20best%20site%20at%20http://example.com">

but not on iOS.

Try adding a semi-colon after the question mark in line of code.

This has been working for me until the recent upgrade to ios7. It should still work on the iPad. I'm not sure what the issue is with the current ios update, but the sms suddenly stopped working for my application. I did create separate buttons for pre-populated body content. One for Droid and one for iPhone. That may be a another option to try.

It is possible to have iphone apps send messages to the compose sms screen and insert the body content, i have personally seen it working and tried it from a developer who wrote the functionality in Object C

I there are also a number of phone gap / cordova plugins that can also achieve it but i am having trouble getting the write version of cordoval to match with the plugins that have been written

so in short YES in iphone app sms creation is possible

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM