ios - 如何通过 config.xml 将 NSPhotoLibraryUsageDescription 添加到 plist 文件?

标签 ios cordova-plugins phonegap

我正在开发一个新应用程序,并尝试通过应用程序加载器首次提交到 iTunes。 ipa 文件由 phonegap 构建在线服务构建,该应用程序使用 cordova 相机插件等。

当我使用应用程序加载器上传 ipa 文件时,一切似乎都成功了,但几分钟后我收到一封电子邮件,内容如下:

Missing Purpose String in Info.plist File - Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSPhotoLibraryUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data will be required to include a purpose string.If you're using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn't contain the APIs. Learn more (https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).

以及与 NSCameraUsageDescription 相关的类似段落

我已经尝试了很多在网上找到的修复方法,包括将以下任何和所有内容添加到 config.xml 中:

 <platform name="ios">
.....
<edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
    <string>need camera access to take pictures</string>
</edit-config>
<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
<string>need location access to find things nearby</string>
</edit-config>

</platform>
<gap:config-file platform="ios" parent="NSCameraUsageDescription">
    <string>For taking pictures</string>
</gap:config-file>
<gap:config-file platform="ios" parent="NSPhotoLibraryUsageDescription">
    <string>For uploading images</string>
</gap:config-file>
    <plugin name="cordova-plugin-camera" spec="^4.0.3" >  
    <variable name="NSCameraUsageDescription" value="Take pictures of stuff" />
    <variable name="NSPhotoLibraryAddUsageDescription" value="App would like to access the library." />
</plugin>

取自官方插件文档以及 stackoverflow 上的其他几个问题,但每次提交都会返回相同的电子邮件。我似乎无法弄清楚要添加到 config.xml 文件的正确行是什么。

最佳答案

想通了。 phonegap 构建服务默认使用 cli-6.5.0,这意味着您需要将以下内容添加到 widget 标签内的 config.xml 而不是平台标签内。

<config-file platform="ios" parent="NSCameraUsageDescription" mode="replace">
<string>App would like to access the camera.</string>
</config-file>

<config-file platform="ios" parent="NSPhotoLibraryUsageDescription" mode="replace">
  <string>App would like to access the camera.</string>
</config-file>

取自http://docs.phonegap.com/phonegap-build/configuring/config-file-element/

关于ios - 如何通过 config.xml 将 NSPhotoLibraryUsageDescription 添加到 plist 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52835814/

相关文章:

ios - 在 viewController 上添加默认导航栏

ios - 使用位于另一个 View 中的 UISwitch 修改 UITableView 外观

android - 用于繁重计算的 WebAssembly + WebView + Javascript 接口(interface)?

javascript - PluginManager 中的 NullPointer 异常 - 创建自定义 Apache Cordova 插件 Echo.java

android - 在 Flutter 应用程序的源代码管理中 stash Google Maps API key

android - 如何获取 PhoneGap 将看到的 android 目录中的文档

javascript - 如何在 phoneGap 中保持 session

javascript - Phonegap + jQuery Mobile,真实示例或教程

javascript - 无法在我的 Android 应用中显示 Google map

android - Cordova 在显示启动画面期间隐藏状态栏