你好,我正在使用ionic2,尝试用mailto打开sms和邮件应用程序:和sms:但是在android中出现了错误net::ERR_UNKNOWN_URL_SCHEME,但在ios中运行良好。
我已经添加了允许-意图,访问-来源和允许-导航。这在我的config.xml里
<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" />这是我的离子信息
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';中将此称为
谢谢你的忠告
发布于 2016-10-14 12:14:41
正如我在对您的问题的评论中提到的,仅仅使用access origin解决了您的问题,但是了解每个问题都做了什么很重要。
在这里阅读更多关于这些信息的内容:科多瓦-插件-白名单。以及CSP。
很高兴我能帮忙。
发布于 2016-10-14 02:46:45
在我的应用程序中我使用
<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进行消毒,使其在设备上正常工作,直到最后两次发布时,它就变得不安全了。
import { DomSanitizer } from '@angular/platform-browser';
constructor(public public navCtrl: NavController, public sanitizer: DomSanitizer) {}
sanitize(url: string) {
return this.sanitizer.bypassSecurityTrustUrl(url);
}config.xml
<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
<button (click)="launch('https://www.somewhere.com')">Launch URL</button>
launch(url) {
this.platform.ready().then(() => {
open(url, "_blank", "location=no");
});
}到目前为止,它既适用于iOS,也适用于我的应用程序android。
https://stackoverflow.com/questions/40027549
复制相似问题