2015年6月12日金曜日

外部サイトをブラウザで開く(Android)

Cordova5(Cordova Android4)からは外部サイトを他のブラウザ開くだけでもプラグインwhitelistが必要になりました。

手順


1 プラグインインストール
cordova plugin add cordova-plugin-whitelist

2 config.xmlに以下を追加
http://www.sample.comを許可する場合
<allow-intent href="http://www.sample.com" />

http,https全部許可する場合
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />

上記で動くようになりました。許可されていないリンクをクリックした場合は何もアクションは出されません。
これでリンク自体は開けるようになったのですがCSP(Content Security Policy)タグを追加していない場合は以下の警告がコンソールに出されました。
No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.

0 件のコメント:

コメントを投稿