Search code examples
htmlsencha-touchextjssencha-touch-2

Dynamically setting call,sms, email functionality in sencha touch


I have an application where i have implemented call,sms,email functionality as shown below, i wanted to know how do i make the phone number:99999999 and mailto:example@gmail.com dynamic , so that i will replace the phone number and email field from some variable.

SMS functionality {

                        xtype: 'button',
                        flex: 1,
                        ui: 'action',
                        text: 'SMS',
                        id: 'smsButton',
                        handler: function () {
                            window.location = 'sms:**99999999**';
                        }

                    }

Call Functionality

{
                             xtype: 'img',
                             text: 'Phone',
                             src: 'http://src.sencha.io/x30/x30/https://support.skype.com/assets/20120601134928/images/categories64/call.png',
                             id: 'callMeButton',
                             flex: 3,
                             tap: function () {
                                 window.location = 'tel:**999999999**';

                             }

                         }

Email Functionality:

{
                         xtype: 'button',
                         text: 'Email',
                         ui: 'action',
                         flex: 1,
                         id: 'emailButton',
                         handler: function () {
                                 `window.location = 'mailto:`**example@gmail.com**';


}
                     }

Solution

  • Store your values of sms number, email address and call number in some address like shown below ..

    var contactNo = "**9999999**";  
    var emailId = "example@gmail.com";  
    var smsNo = "**99999999**";
    

    and then make call as shown below,

     window.location.href = "sms:"+smsNo;
     window.location.href = "mailto:"+emailId;
     window.location.href = "tel:"+contactNo;