Hassan Habbak
Hassan Habbak

Reputation: 55

Formatting SMS sent from android phonegap

I have a relatively easy problem but its causing me a headache. I want to send an sms from a phonegap app running in android.

I am using this code snippet

window.location.href = "sms:12345?body=message \nMessage line 2";

Now this works fine except for one thing. I cant create a new line in the message body. \n has no effect and doesnt even show. I need to have new lines in the message format but unable to do so.

My Regards, Hassan

Upvotes: 0

Views: 967

Answers (2)

Žiga
Žiga

Reputation: 198

I used "%0D%0A" for new line in sms body

Upvotes: 1

Heinrich Lee Yu
Heinrich Lee Yu

Reputation: 1472

Since you are passing the message as a URL parameter, you need to URL encode it.

window.location.href = "sms:12345?body=message+%0AMessage+line+2";

Here is a reference on URL encoding.

Upvotes: 3

Related Questions