菜鸟教程小白 发表于 2022-12-11 19:41:35

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>&lt;meta http-equiv=&#34;Content-Security-Policy&#34; content=&#34;default-src * &amp;apos;self&amp;apos; gap: ; script-src &amp;apos;self&amp;apos; &amp;apos;unsafe-inline&amp;apos; &amp;apos;unsafe-eval&amp;apos; *; style-src &amp;apos;self&amp;apos; &amp;apos;unsafe-inline&amp;apos; *; child-src &amp;apos;self&amp;apos; &amp;apos;unsafe-inline&amp;apos; *;&#34;&gt;
</code></pre> </li>
</ul>

<p>我似乎找不到其他可以尝试的方法,因为我发现大多数有类似问题的帖子都没有得到答复。 </p>

<p>下面是inappbrowser插件如何安装和使用的相关代码:</p>

<p><strong>config.xml 结构</strong></p>

<pre><code>&lt;widget&gt;
&lt;content src=&#34;index.html&#34;/&gt;
&lt;access origin=&#34;*&#34;/&gt;
&lt;allow-navigation href=&#34;*&#34;/&gt;
&lt;preference/&gt;
...
&lt;feature name=&#34;StatusBar&#34;&gt;
...
&lt;/feature&gt;
&lt;platform name=&#34;ios&#34;&gt;
... icons and splash ...
&lt;/platform&gt;
&lt;plugin name=&#34;cordova-plugin-inappbrowser&#34; spec=&#34;~1.7.1&#34;/&gt;
&lt;/widget&gt;
</code></pre>

<p><strong>在 Controller 中使用插件</strong></p>

<pre><code>$scope.showLink = function(url){
var options = {
   location: &#39;yes&#39;
}
$cordovaInAppBrowser.open(url, &#39;_blank&#39;, options)
.then(function(event){
    // success
    console.log(&#39;inappbrowser&#39;, event);
})
.catch (function(event) {
   // error
   console.log(&#39;inappbrowser error&#39;, event);
});
};

$scope.openUrl = function(url) {
window.open(url, &#39;_blank&#39;, &#39;location=no&#39;);
};
</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]
查看完整版本: ios - InAppBrowser 无法在 iOS 10.2 (Xcode 8) 中正确打开