LiveCode LessonsHow To - LiveCode Mobile Tasks iOS TasksHow do I make a phone call on the iPhone?

How do I make a phone call on the iPhone?

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

2) Set its width to 320 and its height to 460

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

4) 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 rev has been extended to interface directly with the iPhone. To start a telephone call on the iPhone we simply pass the following string to the 'launch URL' command:

tel: [Phone number]

So, to make a call to the RunRev 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

The simulator does not have the ability to place a phone call so you will get the "no association" 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)

2 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

Add your comment

E-Mail me when someone replies to this comment