ios - InAppBrowser 无法在 iOS 10.2 (Xcode 8) 中正确打开
<p><p>我已经使用 cordova-plugin-inappbrowser 插件很长时间了,当我在我的苹果测试设备上将软件更新到 10.2.1 时,插件不再正常工作。当我尝试打开 inappbrowser 链接时,除非我单击主页按钮并返回应用程序,否则不会发生任何事情。这发生在模拟器以及 ipad、iphone 5s、iphone 6 和 iphone 7 等真实设备上。它在 android 设备上运行良好,但不是最新的 iOS。 </p>
<p>这是我尝试过的所有内容的列表:</p>
<ul>
<li>将 inappbrowser 更新到最新版本 - 1.7.1</li>
<li>移除并重新安装插件和 ios 平台</li>
<li>尝试使用 inappbrowser 插件制作一个空白应用</li>
<li><p>尝试更改 index.html 元标记以包含间隙:</p>
<pre><code><meta http-equiv="Content-Security-Policy" content="default-src * &apos;self&apos; gap: ; script-src &apos;self&apos; &apos;unsafe-inline&apos; &apos;unsafe-eval&apos; *; style-src &apos;self&apos; &apos;unsafe-inline&apos; *; child-src &apos;self&apos; &apos;unsafe-inline&apos; *;">
</code></pre> </li>
</ul>
<p>我似乎找不到其他可以尝试的方法,因为我发现大多数有类似问题的帖子都没有得到答复。 </p>
<p>下面是inappbrowser插件如何安装和使用的相关代码:</p>
<p><strong>config.xml 结构</strong></p>
<pre><code><widget>
<content src="index.html"/>
<access origin="*"/>
<allow-navigation href="*"/>
<preference/>
...
<feature name="StatusBar">
...
</feature>
<platform name="ios">
... icons and splash ...
</platform>
<plugin name="cordova-plugin-inappbrowser" spec="~1.7.1"/>
</widget>
</code></pre>
<p><strong>在 Controller 中使用插件</strong></p>
<pre><code>$scope.showLink = function(url){
var options = {
location: 'yes'
}
$cordovaInAppBrowser.open(url, '_blank', options)
.then(function(event){
// success
console.log('inappbrowser', event);
})
.catch (function(event) {
// error
console.log('inappbrowser error', event);
});
};
$scope.openUrl = function(url) {
window.open(url, '_blank', 'location=no');
};
</code></pre>
<p>我正在使用 ionic v1.7.14 ,cordova: 6.2.0 和 xcode 8 </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>根据 CodeGems 的建议,在评论中,将 <code>gap://ready</code> 添加到您的 <code>Content-Security-Policy</code> 应该可以解决问题。 </p></p>
<p style="font-size: 20px;">关于ios - InAppBrowser 无法在 iOS 10.2 (Xcode 8) 中正确打开,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/44025250/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/44025250/
</a>
</p>
页:
[1]