Erik Andershed
Erik Andershed

Reputation: 383

Pre-populate the sms body text with an https url

I am trying to pre-populate an sms with text and an url. But the iOS is removing the whole url and only the text "https" is left in the text.

Code:

<a href="sms:&body=Look at this awesome link: https://nat5.com/workout">Send SMS</a>

In SMS:

Look at this awesome link: https

Upvotes: 0

Views: 338

Answers (1)

Filnor
Filnor

Reputation: 1288

As you are already in a link, you need to encode the URL (the : and slashes / to be specific).

As example, https://example.com would become https%3A%2F%2Fexample.com

In your case, you'd need to change your URL to https%3A%2F%2Fnat5.com%2Fworkout. Full link:

<a href="sms:&body=Look at this awesome link: https%3A%2F%2Fnat5.com%2Fworkout">Send SMS</a>

Reference to URL encoding: https://www.w3schools.com/tags/ref_urlencode.asp

And just as a side note: Both ways are looking to work on Android (At least on Android 7.0)

Upvotes: 2

Related Questions