首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ionic2邮件:和短信:?

Ionic2邮件:和短信:?
EN

Stack Overflow用户
提问于 2016-10-13 17:37:43
回答 2查看 2.3K关注 0票数 0

你好,我正在使用ionic2,尝试用mailto打开sms和邮件应用程序:和sms:但是在android中出现了错误net::ERR_UNKNOWN_URL_SCHEME,但在ios中运行良好。

我已经添加了允许-意图,访问-来源和允许-导航。这在我的config.xml里

代码语言:javascript
复制
<access origin="*" />
<access origin="mailto:*" launch-external="true" />
<access origin="tel:*" launch-external="true" />
<access origin="sms:*" launch-external="true" />
<access origin="geo:*" launch-external="true" />
<access origin="maps:*" launch-external="true" />

<allow-intent href="http://*/*" launch-external="true" />
<allow-intent href="https://*/*" launch-external="true" />
<allow-intent href="tel:*" launch-external="true" />
<allow-intent href="sms:*" launch-external="true" />
<allow-intent href="mailto:*" launch-external="true" />
<allow-intent href="geo:*" launch-external="true" />

<allow-navigation href="sms:*" launch-external="true" />
<allow-navigation href="mailto:*" launch-external="true" />

这是我的离子信息

代码语言:javascript
复制
Cordova CLI: 6.3.1
Gulp version:  CLI version 3.9.0
Gulp local:   Local version 3.9.1
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.0.0-beta.20
ios-deploy version: 1.9.0 
ios-sim version: 5.0.8 
OS: Mac OS X El Capitan
Node Version: v6.6.0
Xcode version: Xcode 8.0 Build version 8A218a

我在代码window.location.href = 'mailto:name@domain.com';中将此称为

谢谢你的忠告

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-10-14 12:14:41

正如我在对您的问题的评论中提到的,仅仅使用access origin解决了您的问题,但是了解每个问题都做了什么很重要。

  1. 访问:允许(通过cordova本机钩子)发出哪些网络请求(图像、XHR等)。
  2. 允许-意图:控制应用程序允许打开哪个URL。默认情况下,不允许任何外部URL。
  3. 允许导航: WebView本身可以导航到哪个URL的控件。仅适用于顶级导航。

在这里阅读更多关于这些信息的内容:科多瓦-插件-白名单。以及CSP。

很高兴我能帮忙。

票数 0
EN

Stack Overflow用户

发布于 2016-10-14 02:46:45

在我的应用程序中我使用

代码语言:javascript
复制
<a [href]="sanitize('sms:' + item.sms)"><button ion-button outline><ion-icon name="ios-chatbubbles"></ion-icon></button></a>
<a href="mailto:{{item.email}}"><button ion-button outline><ion-icon name="ios-mail"></ion-icon></button></a>

注意,我必须对sms进行消毒,使其在设备上正常工作,直到最后两次发布时,它就变得不安全了。

代码语言:javascript
复制
import { DomSanitizer } from '@angular/platform-browser';

constructor(public public navCtrl: NavController, public sanitizer: DomSanitizer) {}

sanitize(url: string) {
return this.sanitizer.bypassSecurityTrustUrl(url);
}

config.xml

代码语言:javascript
复制
<access origin="*"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<allow-intent href="tel:*"/>
<allow-intent href="sms:*"/>
<allow-intent href="mailto:*"/>
<allow-intent href="geo:*"/>
<platform name="android">
  <allow-intent href="market:*"/>
</platform>
<platform name="ios">
  <allow-intent href="itms:*"/>
  <allow-intent href="itms-apps:*"/>
</platform>

而不是window.open,我使用这样的东西来打开URL

代码语言:javascript
复制
<button (click)="launch('https://www.somewhere.com')">Launch URL</button>

launch(url) {
    this.platform.ready().then(() => {
        open(url, "_blank", "location=no");
    });
}

到目前为止,它既适用于iOS,也适用于我的应用程序android。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40027549

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档