How do I make a phone call on a mobile device?

In this lesson we will look at how to place a call from a LiveCode app that is running on a network enabled device.

Create a basic stack with a field for the phone number and a button to send

Create a basic stack with a field for the phone number and a button to send

1) Create a new stack at your chosen mobile device size

2) Drag on a button and call it "Call"

3) Drag on a field and call it "number"

Add the following code to the 'call' button

Add this code to the call button

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

The launch URL functionality found in LiveCode has been extended to interface directly with mobile devices. To start a telephone call we simply pass the following string to the launch URL command:

tel: [Phone number]

So, to make a call to the LiveCode support line you would use the following:

tel:+448452198923

Our final line of code would look like this:

launch url "tel:+448452198923"

In this example we are letting the user enter the phone number into the field we dragged onto our stack. We build the call string and pass it to the launch command. The second line of code simply puts the result of our call into the same field. If the string passed to launch command is incorrect you will see a "no association" message appear in the field.

Test our application

Test our application

Simulators do not have the ability to place a phone call so you will get result string as message described above. You will need to build the app and deploy it to your phone to test.

The screenshots above are taken in the simulator (left) and from my iPhone (right)

On Android you will need to check the Internet permission in the Standalone Application Settings.

4 Comments

Jen Civ

Is it easy to put a layout of a picture image in the background?

If so how would that be done?

Many thanks in advance for any insight you provide. I look forward to creating with this suite!

Jen Civ

Ben Beaumont

Hi Jen,

The image you see there is controlled by iOS. If you have assigned an image to the your contact, it will be displayed as above. Unfortunately, that is something that iOS controls so it is not posible to customise it.

Warm regards,

Ben

Wes

How do I do the same thing for an android app?

Elanor Buchanan

Hi Wes

You can use the same method on Android.

I'll get this lesson updated and moved to a more appropriate place.

Elanor

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.