苹果审核警告:ITMS-91053: Missing API declaration

本文讲述了苹果的新规,从2024年5月1日起,开发者需在App的隐私清单文件中为使用NSPrivacyAccessedAPICategory下的各类API提供原因,包括FileTimestamp、SystemBootTime、DiskSpace、ActiveKeyboards和UserDefaults。开发者需添加PrivacyInfo文件并详细列出API声明及其使用理由。
摘要由CSDN通过智能技术生成

背景

前段时间(2024年3月24号)提交了一个版本,appstore给我发了一个提醒的邮件,邮件内容如下:

Although submission for App Store review was successful, you may want to correct the following issues in your next submission for App Store review. Once you've corrected the issues, upload a new binary to App Store Connect.

ITMS-91053: Missing API declaration - Your app’s code in the “Owner” file references one or more APIs that require reasons, including the following API categories: NSPrivacyAccessedAPICategoryFileTimestamp. While no action is required at this time, starting May 1, 2024, when you upload a new app or app update, you must include a NSPrivacyAccessedAPITypes array in your app’s privacy manifest to provide approved reasons for these APIs used by your app’s code. For more details about this policy, including a list of required reason APIs and approved reasons for usage, visit: https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api.

ITMS-91053: Missing API declaration - Your app’s code in the “Owner” file references one or more APIs that require reasons, including the following API categories: NSPrivacyAccessedAPICategoryDiskSpace. While no action is required at this time, starting May 1, 2024, when you upload a new app or app update, you must include a NSPrivacyAccessedAPITypes array in your app’s privacy manifest to provide approved reasons for these APIs used by your app’s code. For more details about this policy, including a list of required reason APIs and approved reasons for usage, visit: https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api.

ITMS-91053: Missing API declaration - Your app’s code in the “Owner” file references one or more APIs that require reasons, including the following API categories: NSPrivacyAccessedAPICategoryUserDefaults. While no action is required at this time, starting May 1, 2024, when you upload a new app or app update, you must include a NSPrivacyAccessedAPITypes array in your app’s privacy manifest to provide approved reasons for these APIs used by your app’s code. For more details about this policy, including a list of required reason APIs and approved reasons for usage, visit: https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api.

ITMS-91053: Missing API declaration - Your app’s code in the “Owner” file references one or more APIs that require reasons, including the following API categories: NSPrivacyAccessedAPICategorySystemBootTime. While no action is required at this time, starting May 1, 2024, when you upload a new app or app update, you must include a NSPrivacyAccessedAPITypes array in your app’s privacy manifest to provide approved reasons for these APIs used by your app’s code. For more details about this policy, including a list of required reason APIs and approved reasons for usage, visit: https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api.

Apple Developer Relations

大概的意思是说,缺少了一些访问敏感数据的说明。2024年5月1号之前,只会发邮件提醒,到5月1号之后,必须添加上访问敏感数据的原因,否则审核不能通过。

新规详情

从今年(2023年)秋天开始,大概是 9 月中旬左右,如果 App 上传到 App Store Connect,应用程序使用到了需要声明原因的 API(也包括引入的第三方 SDK),但是没有在隐私清单文件中添加原因,那么 Apple 会给你发送一封警告性的邮件。

从 2024 年春季开始,大概是 5 月左右,没有在隐私清单文件中说明使用原因的 App 将会被拒审核。

解决方案

在项目中,添加一个PrivacyInfo的文件,在文件中,添加上需要声明隐私的key 和 原因即可。具体如下。
在这里插入图片描述

需要声明原因的 API

1、File timestamp APIs(获取文件时间戳相关的 API)

项目中用到以下接口的都要申明:

creationDate
modificationDate
fileModificationDate
contentModificationDateKey
creationDateKey
getattrlist(::::: )
getattrlistbulk(::::: )
fgetattrlist(::::: )
stat
fstat(:: )
fstatat(:::: )
lstat(:: )
getattrlistat(:::::: )

声明的key 和 reason:

  1. 声明的key:NSPrivacyAccessedAPICategoryFileTimestamp
  2. 对应的原因类型NSPrivacyAccessedAPITypeReasons 有三种,选择其中的一种或者多种:
  • DDA9.1: 声明此原因以向使用设备的个人显示文件时间戳。
  • C617.1: 声明此原因以访问应用容器、应用组容器或应用的CloudKit容器中的文件的时间戳。
  • 3B52.1:声明此原因以访问用户明确授权访问的文件或目录的时间戳,例如使用文档选择器视图控制器。
  • 0A2A.1: 如果您的第三方 SDK 提供文件时间戳 API 的包装函数供应用程序使用,并且您仅在应用程序调用您的包装函数时访问文件时间戳 API,请声明此原因。 此原因只能由第三方 SDK 声明。 如果您的第三方 SDK 主要是为了包装所需的原因 API 而创建的,则可能不会声明此原因。

2、System boot time APIs(获取文件时间戳相关的 API)

项目中用到以下接口的都要申明:

systemUptime
mach_absolute_time()

声明的key 和 reason:

  1. 声明的key:NSPrivacyAccessedAPICategorySystemBootTime
  2. 对应的原因类型NSPrivacyAccessedAPITypeReasons ,选择其中的一种或者多种:
  • 8FFB.1: 声明此原因以访问系统启动时间,以计算应用程序内发生的事件的绝对时间戳,例如与 UIKit 或 AVFAudio 框架相关的事件
  • 3D61.1: 声明此原因以在使用设备的人选择提交的可选错误报告中包含系统启动时间信息。 系统启动时间信息必须作为报告的一部分显着地向人员显示。
  • 35F9.1: 声明此原因以访问系统启动时间,以测量发生在应用内的事件之间经过的时间或执行启用定时器的计算。

3、Disk space APIs(磁盘空间 API)

项目中用到以下接口的都要申明:

volumeAvailableCapacityKey
volumeAvailableCapacityForImportantUsageKey
volumeAvailableCapacityForOpportunisticUsageKey
volumeTotalCapacityKey
systemFreeSize
systemSize
statfs(: : )
statvfs(: : )
fstatfs( : : )
fstatvfs( : : )
getattrlist(: : : : : )
fgetattrlist(: : : : : )
getattrlistat(: : : : : : )

声明的key 和 reason:

  • 声明的key:NSPrivacyAccessedAPICategoryDiskSpace
  • 对应的原因类型NSPrivacyAccessedAPITypeReasons ,选择其中的一种或者多种:
  • 85F4.1: 声明此原因以向使用设备的个人显示磁盘空间信息。磁盘空间可以以信息单位(如字节)或时间单位(如高清视频分钟)显
  • E174.1: 声明此原因以检查是否有足够的磁盘空间来写入文件,或检查磁盘空间是否不足以使应用程序在磁盘空间不足时删除文件。应用程序必须根据磁盘空间的情况以一种用户可观察的方式进行不同的操作。
  • 7D9E.1: 声明此原因以在使用设备的人员选择提交的可选错误报告中包含磁盘空间信息。 磁盘空间信息必须作为报告的一部分突出地显示给相关人员。
  • B728.1: 如果您的应用程序是健康研究应用程序,并且您访问此 API 类别来检测并通知研究参与者磁盘空间不足影响研究数据收集,请声明此原因。

4、Active keyboard APIs(活动键盘 API)

项目中用到以下接口的都要申明:

activeInputModes

声明的key 和 reason:

  1. 声明的key:NSPrivacyAccessedAPICategoryActiveKeyboards
  2. 对应的原因类型NSPrivacyAccessedAPITypeReasons ,选择其中的一种或者多种:
  • 3EC4.1: 如果您的应用程序是自定义键盘应用程序,并且您访问此API类别以确定设备上处于活动状态的键盘,那么向用户提供系统范围的自定义键盘必须是应用程序的主要功能。
  • 54BD.1: 声明此原因以访问活动键盘信息,以向使用设备的个人呈现正确的自定义用户界面。应用程序必须具有用于输入或编辑文本的文本字段,并且必须根据活动键盘的不同行为以一种用户可观察的方式进行操作。

5、User defaults APIs(NSUserdefaults 相关 API)

项目中用到以下接口的都要申明:

UserDefaults

声明的key 和 reason:

  1. 声明的key:NSPrivacyAccessedAPICategoryUserDefaults
  2. 对应的原因类型NSPrivacyAccessedAPITypeReasons ,选择其中的一种或者多种:
  • CA92.1: 声明此原因以访问用户默认设置,以读取和写入仅对应用程序本身可访问的信息。这不允许读取其他应用程序或系统写入的信息,或写入其他应用程序可以访问的信息。
  • 1C8F.1: 声明此原因以访问用户默认值以读取和写入仅可由与应用程序本身属于同一应用程序组的成员的应用程序、应用程序扩展和应用程序剪辑访问的信息。
  • C56D.1: 如果您的第三方 SDK 围绕用户默认 API 提供包装函数供应用程序使用,并且您仅在应用程序调用您的包装函数时才访问用户默认 API,请声明此原因。 此原因只能由第三方 SDK 声明。 如果您的第三方 SDK 主要是为了包装所需的原因 API 而创建的,则可能不会声明此原因。
  • AC6B.1: 声明此原因以访问用户默认读取 com.apple.configuration.managed 密钥以检索 MDM 设置的托管应用程序配置,或设置 com.apple.feedback.managed 密钥以存储要通过 MDM 查询的反馈信息, 如 Apple 移动设备管理协议参考文档中所述。

添加隐私清单文件的步骤

打开项目后,按快捷键 Command + N 新建文件,在面板中搜索 privacy ,选择 App Pirvacy 点击下一步创建这个文件。
在这里插入图片描述

这个文件是个 plist 格式的面板,默认情况下长这样:
在这里插入图片描述

然后点击加号,创建一个 Privacy Accessed API Types 的 Key,这是一个数组,用来包含所有你 App 使用到需要申明原因的 API。在这里插入图片描述

点击加号后,会出现item0, 然后,点击 item0 后面的加号, 先选择 Privacy Accessed API Type
在这里插入图片描述
然后再后面输入对应的key:
在这里插入图片描述

其次,再点击item0的加号,选择 Privacy Accessed API Reasons, 类型选择【Array】:
在这里插入图片描述

点击加号,添加原因,点击右边的箭头,出现原因列表,选择需要声明的原因,即可:
在这里插入图片描述

根据项目,我最后添加的样式如下(文章的顶部,附上了我添加的privacyInfo的文件,需要的可以自行下载查看):
在这里插入图片描述

参考文档:

  1. https://zhuanlan.zhihu.com/p/649662474
  2. 官方文档:https://developer.apple.com/documentation/bundleresources/privacy_manifest_files
  3. API 列表对应的原因:https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api#4278393
  • 15
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值