菜鸟教程小白 发表于 2022-12-11 18:19:38

ios - ios10中的phonegap应用程序卡住


                                            <p><p>我有一个 <strong>phonegap</strong> 应用程序,该应用程序一直正常工作,直到上周五,它在苹果商店中不再被接受,并显示以下消息:</p>
<blockquote>
<p>This app attempts to access privacy-sensitive data without a usage description. The app&#39;s Info.plist must contain an <strong>NSPhotoLibraryUsageDescription</strong> key with a string value explaining to the user how the app uses this data.</p>
<p>This app attempts to access privacy-sensitive data without a usage description. The app&#39;s Info.plist must contain an <strong>NSBluetoothPeripheralUsageDescription</strong> key with a string value explaining to the user how the app uses this data.</p>
<p>This app attempts to access privacy-sensitive data without a usage description. The app&#39;s Info.plist must contain an <strong>NSMicrophoneUsageDescription</strong> key with a string value explaining to the user how the app uses this data.</p>
</blockquote>
<p>为了纠正这个问题,经过一番研究,我得出以下解决方案,在我的 config.xml 文件中添加一些cordova插件:</p>
<pre><code>&lt;plugin name=&#34;cordova-plugin-media-capture&#34; source=&#34;npm&#34; spec=&#34;1.4.0&#34;&gt;
    &lt;variable name=&#34;MICROPHONE_USAGE_DESCRIPTION&#34; value=&#34;App would like to access your microphone.&#34; /&gt;
    &lt;variable name=&#34;CAMERA_USAGE_DESCRIPTION&#34; value=&#34;App would like to access the camera.&#34; /&gt;
    &lt;variable name=&#34;PHOTOLIBRARY_USAGE_DESCRIPTION&#34; value=&#34;App would like to access the library.&#34; /&gt;
&lt;/plugin&gt;
&lt;plugin name=&#34;cordova-plugin-ios-ble-permissions&#34; source=&#34;npm&#34; spec=&#34;*&#34;&gt;
    &lt;variable name=&#34;BLUETOOTH_USAGE_DESCRIPTION&#34; value=&#34;App would like to access your bluetooth.&#34; /&gt;
&lt;/plugin&gt;
</code></pre>
<p>这解决了苹果商店的问题,我确认 Info.plist 文件中包含所有这些变量。</p>
<p>但现在应用程序卡住/崩溃,并且仅在 iOs10 设备中。</p>
<p>我正在寻求一些指导/帮助,以确定问题的根源。</p>
<p>提前谢谢大家。</p>
<hr/>
<p>编辑:</p>
<p>Finnaly 能够远程调试应用程序并找出一些类似这样的错误:</p>
<blockquote>
<p> Refused to load data:text/javascript;charset=utf-(...)-app-shell.html-170.js%0A because it does not appear in the script-src directive of the Content Security Policy</p>
</blockquote>
<p>我当前的元标记具有以下值:</p>
<pre><code>&lt;meta http-equiv=&#34;Content-Security-Policy&#34; content=&#34;default-src gap://ready file://* *; script-src &#39;self&#39; &#39;unsafe-inline&#39; &#39;unsafe-eval&#39; *; style-src &#39;self&#39; &#39;unsafe-inline&#39; *; img-src &#39;self&#39; data: blob: *; media-src &#39;self&#39; mediastream: blob:; connect-src * blob:&#34;&gt;
</code></pre>
<p>和白名单配置:</p>
<pre><code>&lt;plugin name=&#34;cordova-plugin-whitelist&#34; spec=&#34;1.3.1&#34;/&gt;
&lt;access origin=&#34;*&#34;/&gt;
&lt;allow-navigation href=&#34;*&#34;/&gt;
&lt;allow-intent href=&#34;http://*/*&#34;/&gt;
&lt;allow-intent href=&#34;https://*/*&#34;/&gt;
&lt;allow-intent href=&#34;tel:*&#34;/&gt;
&lt;allow-intent href=&#34;sms:*&#34;/&gt;
&lt;allow-intent href=&#34;mailto:*&#34;/&gt;
&lt;allow-intent href=&#34;geo:*&#34;/&gt;
</code></pre>
<p>任何提示我做错了什么?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>可能是由<code>Content-Security-Policy</code>引起的。</p>

<p>尝试在<code>&lt;meta&gt;</code>标签中添加<code>default-src gap:</code>。</p>

<p>例如:</p>

<pre><code>&lt;head&gt;
&lt;meta http-equiv=&#34;Content-Security-Policy&#34; content=&#34;default-src * &#39;self&#39; gap: wss: ws:; font-src * data:; img-src * data:; style-src &#39;self&#39; https: &#39;unsafe-inline&#39;; script-src &#39;self&#39; https: &#39;unsafe-inline&#39; &#39;unsafe-eval&#39;&#34;&gt;
&lt;/head&gt;
</code></pre>

<p>引用:
<a href="https://stackoverflow.com/questions/30212306/no-content-security-policy-meta-tag-found-error-in-my-phonegap-application" rel="noreferrer noopener nofollow">&#34;No Content-Security-Policy meta tag found.&#34; error in my phonegap application</a> </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - ios10中的phonegap应用程序卡住,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/41141225/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/41141225/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - ios10中的phonegap应用程序卡住