OGeek|极客世界-中国程序员成长平台

标题: ios - ios10中的phonegap应用程序卡住 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 18:19
标题: ios - ios10中的phonegap应用程序卡住

我有一个 phonegap 应用程序,该应用程序一直正常工作,直到上周五,它在苹果商店中不再被接受,并显示以下消息:

This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.

This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSBluetoothPeripheralUsageDescription key with a string value explaining to the user how the app uses this data.

This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSMicrophoneUsageDescription key with a string value explaining to the user how the app uses this data.

为了纠正这个问题,经过一番研究,我得出以下解决方案,在我的 config.xml 文件中添加一些cordova插件:

<plugin name="cordova-plugin-media-capture" source="npm" spec="1.4.0">
    <variable name="MICROPHONE_USAGE_DESCRIPTION" value="App would like to access your microphone." />
    <variable name="CAMERA_USAGE_DESCRIPTION" value="App would like to access the camera." />
    <variable name="HOTOLIBRARY_USAGE_DESCRIPTION" value="App would like to access the library." />
</plugin>
<plugin name="cordova-plugin-ios-ble-permissions" source="npm" spec="*">
    <variable name="BLUETOOTH_USAGE_DESCRIPTION" value="App would like to access your bluetooth." />
</plugin>

这解决了苹果商店的问题,我确认 Info.plist 文件中包含所有这些变量。

但现在应用程序卡住/崩溃,并且仅在 iOs10 设备中。

我正在寻求一些指导/帮助,以确定问题的根源。

提前谢谢大家。


编辑:

Finnaly 能够远程调试应用程序并找出一些类似这样的错误:

[Error] 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

我当前的元标记具有以下值:

<meta http-equiv="Content-Security-Policy" content="default-src gap://ready file://* *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src 'self' 'unsafe-inline' *; img-src 'self' data: blob: *; media-src 'self' mediastream: blob:; connect-src * blob:">

和白名单配置:

<plugin name="cordova-plugin-whitelist" spec="1.3.1"/>
<access origin="*"/>
<allow-navigation href="*"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<allow-intent href="tel:*"/>
<allow-intent href="sms:*"/>
<allow-intent href="mailto:*"/>
<allow-intent href="geo:*"/>

任何提示我做错了什么?



Best Answer-推荐答案


可能是由Content-Security-Policy引起的。

尝试在<meta>标签中添加default-src gap:

例如:

<head>
  <meta http-equiv="Content-Security-Policy" content="default-src * 'self' gap: wss: ws:; font-src * data:; img-src * data:; style-src 'self' https: 'unsafe-inline'; script-src 'self' https: 'unsafe-inline' 'unsafe-eval'">
</head>

引用: "No Content-Security-Policy meta tag found." error in my phonegap application

关于ios - ios10中的phonegap应用程序卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41141225/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4