【问题标题】:How do I add the NSPhotoLibraryUsageDescription to the plist file via the config.xml?如何通过 config.xml 将 NSPhotoLibraryUsageDescription 添加到 plist 文件中?
【发布时间】:2018-10-16 12:47:14
【问题描述】:

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

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

Info.plist 文件中缺少用途字符串 - 您的应用代码引用了一个或多个访问敏感用户数据的 API。应用的 Info.plist 文件应该包含一个 NSPhotoLibraryUsageDescription 键和一个面向用户的目的字符串,清楚而完整地解释为什么你的应用需要数据。从 2019 年春季开始,所有提交到 App Store 并访问用户数据的应用都需要包含目的字符串。如果您使用的是外部库或 SDK,它们可能会引用需要目的字符串的 API。虽然您的应用可能不使用这些 API,但仍需要使用目的字符串。您可以联系库或 SDK 的开发人员,并要求他们发布不包含 API 的代码版本。了解更多信息 (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 文件中的正确行是什么。

【问题讨论】:

    标签: ios cordova-plugins phonegap


    【解决方案1】:

    想通了。 phonegap 构建服务默认使用 cli-6.5.0,这意味着您需要将以下内容添加到小部件标签内的 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/

    【讨论】:

      【解决方案2】:

      您还必须在 config-file 元素中提及您的目标才能使其正常工作:

      <config-file platform="ios" parent="NSCameraUsageDescription" mode="replace" target="*-Info.plist">
          <string>Paypal maybe access the camera</string>
      </config-file>
      
      <config-file platform="ios" parent="NSPhotoLibraryUsageDescription" mode="replace" target="*-Info.plist">
          <string>Paypal maybe access the photo library</string>
      </config-file>
      

      【讨论】:

        猜你喜欢
        • 2014-05-11
        • 2013-01-26
        • 1970-01-01
        • 2015-10-25
        • 2012-07-17
        • 1970-01-01
        • 1970-01-01
        • 2012-08-25
        • 2011-12-25
        相关资源
        最近更新 更多