mahesh
mahesh

Reputation: 3217

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:[email protected]'
        }
      }
    ]
  },
});

Upvotes: 3

Views: 4214

Answers (2)

Ram G Athreya
Ram G Athreya

Reputation: 4952

You can do this by just using the <a> tag

For phone number

<a href="tel:+1-800-555-1234">+1-800-555-1234</a>

For E-Mail

<a href="mailto:[email protected]">[email protected]</a>

Tapping on the link will automatically summon the phone app or e-mail app in both android and iOS.

Upvotes: 0

Swar
Swar

Reputation: 5503

Use window.open() method.

window.open('tel:+1-800-555-1234');
window.open('mailto:[email protected]');

Upvotes: 7

Related Questions