如何在Sencha Touch中实现电子邮件和电话功能

3

我有一个样例 Sencha Touch 应用程序,试图实现电子邮件、电话和短信功能,但运行应用程序时它没有打开电子邮件窗口或电话窗口。请问正确的语法是什么以使其正常工作?

示例代码:

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'
        }
      }
    ]
  },
});
2个回答

7
使用 window.open() 方法。
window.open('tel:+1-800-555-1234');
window.open('mailto:webmaster@example.com');

1
谢谢回复,即使这个也可以工作:{ xtype: 'button', flex: 1, text: '电话', id: 'phoneButton', handler: function() { window.location = 'tel:999999'; } } - mahesh
@Swar 有没有办法在通话结束后获取回调?这样我就可以捕获通话持续时间并将其保存到我的数据库中。 - Dibish
如果我想准备电子邮件内容怎么办?是否有类似的东西:window.open('mailto:frna@exm.com content: here is the content') - Franva

0

你可以通过使用<a>标签来完成这个操作

对于电话号码

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

关于电子邮件

<a href="mailto:webmaster@example.com">webmaster@example.com</a>

点击链接将自动在Android和iOS中召唤电话应用程序或电子邮件应用程序。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接