Search code examples
htmlextjssencha-touchsencha-touch-2

How to implement email,call functionality in sencha touch


I have a sample sencha touch application trying to implement E-Mail, Call and SMS functionality, but when run the application it's not opening E-Mail window or Call window. Please can I know the right syntax to make it work?

Sample code:

Ext.define('Sample.view.ContactsView', {
  extend:'Ext.Panel',
  requires:[
    'Ext.form.FieldSet',
    'Ext.field.Text'
  ],

  alias:"widget.contactpage",
  initialize:function () {
    this.callParent(arguments);
  },

  config:{
    items:[
      {
        xtype:'titlebar',
        title:'Contact Us'
      },
      {
        xtype:'panel',
        layout:'hbox',

        items:[
          {
            xtype:'button',
            flex:1,
            id:'smsButton',
            handler:function(){
              document.location.href = 'sms:464646'
            }
          },
          {
            xtype:'spacer'
          },
          {
            xtype:'button',
            text: 'Phone',
            id:'callMeButton',
            flex:1,
            handler:function(){
              document.location.href = 'tel:+1-800-555-1234'
            }
          }
        ]
      },
      {
        xtype:'button',
        text:'Email',
        id: 'emailButton',
        handler:function(){
          document.location.href = 'mailto:webmaster@example.com'
        }
      }
    ]
  },
});

Solution

  • Use window.open() method.

    window.open('tel:+1-800-555-1234');
    window.open('mailto:webmaster@example.com');