Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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?

— asked May 20th 2010 by Matthew Lieder
  • call
  • dial
0 Comments

9 Answers

  • Accepted Answer

    Hi,

    It's pretty simple - use:

    var the_number = '0123456789';
    Ti.Platform.openURL('tel:+the_number');
    

    :)

    — answered May 20th 2010 by Kosso
    permalink
    1 Comment
    • Hi, Kosso

      Silly Mistake,

      var the_number = '0123456789';
      Ti.Platform.openURL('tel:'+the_number); // Correct Line
      

      Thanx :)

      — commented March 30th 2013 by Dharmik Patel
  • 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>
    
    — answered February 7th 2013 by Akshay Taru
    permalink
    3 Comments
    • Thanks Akshay - this is just what I needed

      — commented March 29th 2013 by Brendan McGinn
    • thank you , its working on android.

      — commented October 9th 2013 by Ravi kumar
    • CALL_PHONE permission may be discouraged for some user, so I would suggest this method:

      "You can use Intent.ACTION_DIAL instead of Intent.ACTION_CALL. This shows the dialer with the number already entered, but allows the user to decide wether to actually make the call or not. ACTION_DIAL does not require the CALL_PHONE permission."

      http://stackoverflow.com/questions/4275678/how-to-make-phone-call-using-intent-in-android

      — commented January 29th 2015 by Danny Pham
  • Quick note, if you run that in the stimulator, nohing would happen, use a real device to test it!

    — answered May 20th 2010 by Sj Singh
    permalink
    0 Comments
  • Now in the new SDK 3.2.2 like this

    Ti.Platform.openURL('tel:0046737551861');
    
    — answered April 8th 2014 by Mohammed Abunada
    permalink
    0 Comments
  • Hi,

    It's pretty simple - use:

    var the_number = '0123456789';
    Ti.Platform.openURL('tel:+the_number');
    

    :)

    — answered May 20th 2010 by Kosso
    permalink
    0 Comments
  • this not works with android phones ?!

    — answered February 3rd 2012 by Sebastian Erb
    permalink
    2 Comments
    • yes ;)

      — commented June 29th 2012 by Felipe Alvarado
    • Is there any accepted workaround for android yet?

      — commented August 8th 2012 by Jakob Lehner
  • 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);
    

    });

    — answered March 3rd 2014 by Ishara Amarasekera
    permalink
    0 Comments
  • 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);
    
    });
    
    — answered March 3rd 2014 by Ishara Amarasekera
    permalink
    0 Comments
  • 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

    — answered November 5th 2014 by andres guerrero
    permalink
    1 Comment
    • of course it's not possible to dial both the "base number( 042344711 )" and the "extension( 133) " using any native code. ^_^

      — commented March 5th 2015 by Siwei Shen
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.