【问题标题】:Filter apps of Cordova's Email Composer过滤 Cordova 电子邮件编辑器的应用程序
【发布时间】:2016-02-10 10:32:11
【问题描述】:

我用这个插件:http://ngcordova.com/docs/plugins/emailComposer/

这是我的角码:

$scope.report = function(){
    var CEO_EMAIL_ADDRESS = 'support@example.com';

    $cordovaEmailComposer.isAvailable().then(function() {
        $cordovaEmailComposer.open({
            to: CEO_EMAIL_ADDRESS,
            subject:  langTranslateService.getData('REPORT_A_PROBLEM'),
            body: '',
            isHtml: false
        });
    });
};

我只需要打开电话电子邮件或仅从电子邮件应用程序中进行选择的选项。

为什么选项里有“蓝牙、Dropbox...”?

我可以改变它吗..?

【问题讨论】:

    标签: javascript angularjs cordova ionic-framework


    【解决方案1】:

    根据找到的插件规范here,您应该能够为open 方法提供app 选项,以针对特定应用程序打开电子邮件草稿(仅在编写Android 时)。

    首先应该为所需的应用创建一个别名,如下所示:

    cordova.plugins.email.addAlias('outlook', 'com.microsoft.android.outlook');
    

    本示例为 Outlook 应用创建别名 outlook。第二个参数是应用的包名,我可以通过安装Package Name Viewer之类的插件找到。

    您可以通过isAvailable 函数的以下重载来验证应用程序是否可用:

    cordova.plugins.email.isAvailable(
        'outlook', function (isAvailable, withScheme) {
            // isAvailable indicates if sending emails is available at all
            // withScheme is true if the desired app/scheme is available. When false the fallback of choosing an approriate app is applied
        }
    );
    

    然后您可以将此别名提供给 open 方法,如下例所示:

    $cordovaEmailComposer.open({
        app: 'outlook',
        to: CEO_EMAIL_ADDRESS,
        subject:  langTranslateService.getData('REPORT_A_PROBLEM'),
        body: '',
        isHtml: false
    });
    

    现在草稿应在可用时在 Outlook 中打开。试试看!

    【讨论】:

      猜你喜欢
      • 2023-03-19
      • 2016-07-07
      • 2019-10-26
      • 2019-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-25
      • 2017-12-02
      相关资源
      最近更新 更多