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
1) Create a new stack for iPhone 5
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 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:
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
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)