BYU Home pageBRIGHAM YOUNG UNIVERSITY
  Office of Digital Humanities
Back     BYU LiveCode Lessons Gateway

Using Various Mobile Communications Capabilities:
Phone Calls, Email, and Text Messaging

LiveCode provides simple-to-use langauge for accessing the basic communications capabilities of iOS and Android mobile devices. Let's examine how to access the email, telephone, text messaging capabilities of your device.

Email

Composing and sending an email in your mobile app is straightforward. There are several commands and a function that you may use to access your device's email capabilities:

The mobileCanSendMail() function - determines whether a device can be used to send emails.

Example:

if mobileCanSendMail() then
  # do the send mail stuff
else
  # notify the user that the device doesn't support mail
end if

The mobileComposeMail command - creates the email message structure from elements that you feed it, then opens the email message in the device's email app, ready to send.

mobileComposeMail uses
the device's email app

Syntax:

mobileComposeMail subject, recipients, ccs, bccs, body, attachments

All of the parameters are optional. However, you must preserve the proper order and number of the parameters by including empty parameters to make sure each parameter is properly interpreted for what it is.

Example:

mobileComposeMail "Email Test","someone@email.net",,,"Hello World"

This command simply composes the email and sends it to the email app on the device. From there the user can edit it or even cancel it. Once the email is sent or canceled, control is returned to the app that created the email message.

There are two other variants of the mobileComposeMail command. Both function identically to the basic command, but allow you to include styled text or non-Latin characters.

mobileComposeHtmlMail - Use to send HTML-formatted text.

mobileComposeUnicodeMail - Use to send email that contains non-ascii text or special characters.

That's all there is to creating a simple email composition form in your app. But you can do much more with mobileComposeMail. For instance, you can also create an email message with attachments. Here is an online tutorial on how to send an email with attachments in mobile.


Telephone Calls

It is dead simple to initiate a phone call from within your LiveCode mobile app. Just use the launch url command, followed by the phone number:

on mouseUp
  launch url "tel:" && field "number"
  put the result into field "number"
end mouseUp

If your device has telephone capabilities it will launch the phone app and dial the call. If the device does not have telephone capability the string "no association" will be returned to the result.

See this online tutorial for more information. Remember that even though this older tutorial refers to iPhones, this applies equally to iOS and Android devices.

Text Messages

Sending a text message in your mobile app is also straightforward. There is a function and a command that you may use when building text messaging functionality into an app:

The mobileCanComposeTextMessage() function - determines whether a device can compose text messages.

Example:

if mobileCanComposeTextMessage() then
  # do the text message stuff
else
  # notify the user that the device doesn't support text messages
end if
The Messages app on the iphone 5

mobileComposeTexMessage uses
the device's messaging app

The mobileComposeTextMessage command - creates the creates a text message then opens it in the device's text messaging app, ready to send.

Syntax:

mobileComposeTextMessage recipients, body

Example:

mobileComposeTextMessage "123-456-7890","Hello World"

Just as with emails and phone calls, mobileComposeTextMessage simply uses the device's default text messaging app to allow the user to send out the composed message. Once that is done control is returned to your app.



Back     BYU LiveCode Lessons Gateway
Maintained by Devin Asay.
Copyright © 2005 Brigham Young University