Calling a phone number?
I want to have a button in my app that, when clicked, dials a number. I know that has to be possible at least in Objective-C, but how would I do so using Javascript and the Mobile API?
9 Answers
-
Accepted Answer
Hi,
It's pretty simple - use:
var the_number = '0123456789'; Ti.Platform.openURL('tel:+the_number');
:)
-
Dial a call in Android is possible through Intents'
var call = 'tel:' + number; var intent = Ti.Android.createIntent({ action : Ti.Android.ACTION_CALL, data : call }); Ti.Android.currentActivity.startActivity(intent);
You also need to add permission to tiapp.xml
Replace this:
<android xmlns:android="http://schemas.android.com/apk/res/android" />
with this:
<android xmlns:android="http://schemas.android.com/apk/res/android"> <manifest> <uses-permission android:name="android.permission.CALL_PHONE" /> </manifest> </android>
-
Quick note, if you run that in the stimulator, nohing would happen, use a real device to test it!
-
Now in the new SDK 3.2.2 like this
Ti.Platform.openURL('tel:0046737551861');
-
Hi,
It's pretty simple - use:
var the_number = '0123456789'; Ti.Platform.openURL('tel:+the_number');
:)
-
this not works with android phones ?!
-
Try this out for Android.
button.addEventListener('click', function(e) {
var intent = Ti.Android.createIntent({ action : Ti.Android.ACTION_CALL, data : 'tel:0123456789' }); Ti.Android.currentActivity.startActivity(intent);
});
-
Try this out for Android.
button.addEventListener('click', function(e) { var intent = Ti.Android.createIntent({ action : Ti.Android.ACTION_CALL, data : 'tel:0123456789' }); Ti.Android.currentActivity.startActivity(intent); });
-
im having a little troubles cuz im trying to dial with a extension
Ti.Platform.openURL('tel:042344711,133');
but its not working the extension
only recognize me before comma