Make a Call on Icenium using PhoneGap

In this post we will take a look on making a call using PhoneGap in a Hybrid application creating using Icenium. Let us create a view like following to make a call,

image

Above view can be created using following code snippet,


<div data-role="view" id="callview" data-title="Make a Call">
<h1>Call this number!</h1>
<div id='Div1'>
<label for="txtName" style="display: inline-block;">Enter Phone Number to Call:</label>
<input type="text" id="Text1" value="" />
</div>
<div>
<a id="A1" data-role="button" data-click="callfunction" data-icon="action">Make A Call</a>
</div>
</div>

On click of Make a Call button a call can be done as following,


function callfunction() {

var phntocall = document.getElementById('txtPhoneNumber1').value;
window.location.href = "tel:" + phntocall;

}

In above code snippet we are reading phone number. After that using tel: to make a call. It will open native Call application with configured phone number to make a call.

I hope you find this post useful. Thanks for reading.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s