How to get mobile text messaging working

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Hendricus
Posts: 7
Joined: Tue Aug 18, 2020 6:03 pm

How to get mobile text messaging working

Post by Hendricus » Wed Dec 14, 2022 11:02 am

Dear LiveCoders,

I have been trying to get my app to trigger preparing a text message (SMS) on an android device. At first I tried with:

Code: Select all

put "This is a test text" into tMessage
put URLEncode(tMessage) into tMessage
launch url "sms:" & tMobile & "&body=" & tMessage
This starts the text messaging app on the android phone, selecting the name for the phone number in the tMobile variable, but it leaves the message empty. I have tried variations with the body parameter, to have a ';' instead of the '&' and other combinations. They didn't work. Then I came across the specific functions for this in the LiveCode Dictionary (mobileCanComposeTextMessage(), and mobileComposeTextMessage tMobile, tMessage). But these seem to fail too. With the following code I get the answer "Cannot send text messages" on my android phone when I press the button.

Code: Select all

on mouseUp
   if mobileCanComposeTextMessage() then 
      answer "Text Messages can be sent"
   else 
      answer "Cannot send text messages"
   end if
end mouseUp
Are there some settings for the standalone or elsewhere that are needed to get this to work?

AndyP
Posts: 615
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Re: How to get mobile text messaging working

Post by AndyP » Wed Dec 14, 2022 11:35 am

Try changing this line

Code: Select all

launch url "sms:" & tMobile & "&body=" & tMessage
To

Code: Select all

launch url "sms:" & tMobile & "?body=" & tMessage
Notice the & was replaced with ?

I've not tested but I think this is the problem?
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to get mobile text messaging working

Post by Klaus » Wed Dec 14, 2022 11:38 am

In any case you should add parentheses!

Code: Select all

launch url("sms:" & tMobile & "/body=" & tMessage)

Hendricus
Posts: 7
Joined: Tue Aug 18, 2020 6:03 pm

Re: How to get mobile text messaging working

Post by Hendricus » Wed Dec 14, 2022 12:35 pm

Awesome. The code works perfectly like this:

Code: Select all

launch url("sms:" & tMobile & "?body=" & tMessage)
Thanks for the feedback. I still wonder why the mobileCanComposeTextMessage() doesn't work though. Anyone used this before?

Post Reply

Return to “Android Deployment”