Titanium Community Questions & Answer Archive

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

cant get Ti.Platform.openURL('tel: to work

I have problem using the Ti.Platform.openURL('tel:123456');

My code goes as follow:

var b_call = Ti.UI.createButton({
    title:'Call',
    width:150,
    top: 100,
    height:50
});
b_call.addEventListener('click',function() {
    //Ti.Platform.openURL('http://www.google.com');  <-- This works fine
    Ti.Platform.openURL('tel:1234567');  //This does not work?!
});
w.add(b_call);

The commented line works fine and opens up the browser but the telephone line doesn't work.

Any ideas?!?! It looks like I've done things correct, I just want to make a simple call

Big thx!
//Pingo

— asked November 1st 2010 by Stefan Jakobsson
  • mobile
2 Comments
  • OK, just want to add that it doesn't work when I have deployed the app to my iPhone4 either.
    So it's not just working in the simulator.
    Thx
    /Pingo

    — commented November 1st 2010 by Stefan Jakobsson
  • This works for me on iphone.
    Ti.Platform.openURL("tel:6035551212");
    Remember that it won't work on the simulator though; you need to put it on a phone.

    — commented September 3rd 2011 by Patty Mapes

2 Answers

  • Try Ti.Platform.openURL('tel://5555555555')

    — answered November 1st 2010 by John Welch
    permalink
    1 Comment
    • Hi,
      I tried that as well but unfortunately with the same result.
      //Pingo

      — commented November 2nd 2010 by Stefan Jakobsson
  • Are you sure the entered telephone number is valid? Your code looks good.

    — answered November 2nd 2010 by Peter Griffin
    permalink
    2 Comments
    • What do you mean by valid?
      Do I need country code etc? Or shouldn't I be able to have which ever number I want?? Just like the example?
      For example ('tel:+4631650000') and ('tel:4631650000') does not work.
      When I on the same line do ('http://www.google.com') it works so it seams that there is nothing wrong with the button.
      Same goes for ('sms:4631650000') does not trigger the SMS function.

      Very strange…??

      //Pingo

      — commented November 2nd 2010 by Stefan Jakobsson
    • Following is the complete code for my contact.js

      //Pingo

      // create table view data object
      var data = [];
      
      var xhr = Ti.Network.createHTTPClient();
      xhr.open("GET","http://dearsupport.se/contacts.xml");
      
      xhr.onload = function()
      {
          try
          {
              var doc = this.responseXML.documentElement;
              var items = doc.getElementsByTagName("item");
              var x = 0;
              var doctitle = doc.evaluate("//channel/title/text()").item(0).nodeValue;
      
              for (var c=0;c<items.length;c++)
              {
                  var item = items.item(c);
      
                  var title = item.getElementsByTagName("title").item(0).text;
                  var phone = item.getElementsByTagName("phone").item(0).text;
                  var email = item.getElementsByTagName("email").item(0).text;
                  var row = Ti.UI.createTableViewRow({title:''+title,height:40,hasChild:true});
                  row.phone = phone; //item.getElementsByTagName("description").item(0).text;
                  row.email = email; 
      
                  data[x++] = row;
              }
      
              var tableview = Titanium.UI.createTableView({data:data});
              Titanium.UI.currentWindow.add(tableview);
              tableview.addEventListener('click',function(e)
              {
                  var w = Ti.UI.createWindow({
                      backgroundColor:'#fff'
                  });
      
                  // Create CALL button and action
                  var l_number = Ti.UI.createLabel({
                      text:e.row.phone,
                      width:'auto',
                      top: 30,
                      height:'auto',
                      textAlign:'center',
                      font:{fontSize:34, fontStyle:'bold'}
                  });
                  w.add(l_number);
                  var b_call = Ti.UI.createButton({
                      title:'Call',
                      width:150,
                      top: 100,
                      height:50
                  });
                  b_call.addEventListener('click',function()
                  {
                      //Ti.Platform.openURL('tel:'+e.row.phone);
                      Ti.Platform.openURL('tel:4631650000');
                  });
                  w.add(b_call);
      
                  // Create SMS button and action
                  var b_sms = Ti.UI.createButton({
                      title:'Send SMS',
                      width:150,
                      top: 170,
                      height:50
                  });
                  b_sms.addEventListener('click',function()
                  {
                      Ti.Platform.openURL('sms:'+e.row.phone);
                  });
                  w.add(b_sms);
      
                  // Create Email button and action
                  var b_email = Ti.UI.createButton({
                      title:'Send E-mail',
                      width:150,
                      top: 240,
                      height:50
                  });
                  b_email.addEventListener('click',function()
                  {
                      var emailDialog = Ti.UI.createEmailDialog();
                      emailDialog.toRecipients = [e.row.email];
                      emailDialog.open();
                  });
                  w.add(b_email);
      
                  var b_close = Ti.UI.createButton({
                      title:'Close',
                      width:150,
                      top: 310,
                      height:50
                  });
                  b_close.addEventListener('click',function()
                  {
                      w.close();
                  });
                  w.add(b_close);
      
                  w.open({
                         modal:true,
                         modalTransitionStyle:Ti.UI.iPhone.MODAL_TRANSITION_STYLE_COVER_VERTICAL,
                         modalStyle:Ti.UI.iPhone.MODAL_PRESENTATION_FULLSCREEN,
                         navBarHidden:true});
                  });
      
          }
          catch(E)
          {
              alert(E);
          }
      };
      xhr.send();
      

      — commented November 2nd 2010 by Stefan Jakobsson
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.