DCloud_App_Array
DCloud_App_Array
  • 发布:2019-07-04 16:54
  • 更新:2022-05-11 12:09
  • 阅读:123570

iOS平台配置应用使用广告标识(IDFA)

分类:HTML5+

此文档将不再维护,请参考新文档:https://uniapp.dcloud.io/tutorial/app-ios-idfa

HBuilderX 3.2.9+ 版本已适配 iOS15 请更新

  • 将 HX 升级到 3.2.9 及以上版本,建议使用最新的版本;
  • 如果项目是通过 cli 创建的需要将依赖也升级到新版本;

概述

12年9月份iOS6发布,IDFA面世,主要用于给开发者跟踪应用中广告的投放效果,但很多应用(或三方SDK)会获取IDFA作为设备唯一标识使用。
iOS14.5 发布之后,苹果要求应用获取 IDFA 时,需弹出用户许可收集跟踪数据的授权框,如果没有弹出授权框则可能会被App Store审核拒绝,提示违反5.1.2规则:

Guideline 5.1.2 - Legal - Privacy - Data Use and Sharing  
  
  
We noticed you do not use App Tracking Transparency to request the user's permission before tracking their activity across apps and websites. The app privacy information you provided in App Store Connect indicates you collect data in order to track the user, including Device ID and Precise Location.  
  
Starting with iOS 14.5, apps on the App Store need to receive the user’s permission through the AppTrackingTransparency framework before collecting data used to track them. This requirement protects the privacy of App Store users.  
  
Next Steps  
  
Here are two ways to resolve this issue:  
  
- You can remove the tracking functionality from your app and update your app privacy information in App Store Connect.  
- If you decide to continue tracking users, you must implement App Tracking Transparency and request permission before collecting data used to track the user or device.  
  
Resources  
  
- See Frequently Asked Questions about the new requirements for apps that track users.  
- Learn more about designing appropriate permission requests.

请使用 HBuilderX 3.2.9+ 版本,按照下面步骤配置开启广告标识(IDFA),重新打包提交审核`

如何判断是否需要开启广告标识(IDFA)?

1.只要您的应用使用了uni-AD广告模块,就需要开启 IDFA;
2.使用的 HX 版本低于 3.2.15 版本并且应用使用了新浪微博登录和分享、一键登录、友盟统计 其中一个或多个功能模块,这些SDK内会触发获取IDFA,所以需要开启 IDFA (注:HX 3.2.15及以上版本更新了这些三方SDK,不在获取IDFA)

一些uni原生插件也可能会读取IDFA,因此碰到App Store审核不通过,提示违反5.1.2规则且内容中包含App Tracking Transparency都可以通过配置开启广告标识(IDFA)解决。

uni-AD中的广告基础功能并不会访问IDFA,没有勾选三方广告SDK时不需要访问开启广告标识(IDFA)
注:对于非广告类的三方SDK,我们会密切关注其官方的版本更新,待官方出了不包含IDFA的版本我们会尽快适配升级

配置开启广告标识(IDFA)

在 manifest.json 文件的 “App常用其它设置” 中可勾选开启(注意HBuilder X 2.4以上为默认勾选),需提交云端打包才会生效

** 配置 NSUserTrackingUsageDescription 隐私描述 **
开启广告标识(IDFA)后,云端打包默认隐私描述为“请放心,开启权限不会获取您在其他站点的隐私信息,该权限仅用于标识设备并保障服务安全与提示浏览体验”,也可以在 manifest.json 文件的 “App权限配置” 项的“iOS隐私信息访问的许可描述”下配置 NSUserTrackingUsageDescription 隐私描述:

注:使用低版本HBuilderX时可以切换到manifest.json的源码视图,手动在"privacyDescription"节点下添加 NSUserTrackingUsageDescription 字段配置隐私描述。

隐私描述是为了告诉用户,应用为什么要跟踪用户及访问设备的IDFA,配置的描述内容会展示在授权框上,参考以下建议描述说明:

  • 包含uni-AD功能时填写: 请放心,开启权限不会获取您在其他站点的隐私信息,该权限仅用于标识设备、第三方广告、并保障服务安全与提示浏览体验
  • 不包含uni-AD功能时填写:请放心,开启权限不会获取您在其他站点的隐私信息,该权限仅用于标识设备并保障服务安全与提示浏览体验

运行时弹出授权提示框显示效果如下:

配置 “App 隐私”

开启广告标识(IDFA)后,提交App Store审核之前,需要在App Store Connect 配置 “App 隐私”。
首先点击编辑“数据类型”,勾选 “是,我们会从此App收集数据” 选项;然后点下一步,


因为uni框架会收集崩溃数据,所以需要勾选列表中的“崩溃数据”选项,另外再勾选“设备 ID”选项;
如果您使用了uni-AD,则勾选“广告数据”选项,如果没有,则不勾选;
如下图所示,然后发布。

注意:编辑“数据类型”时,需根据自己应用使用到的数据,灵活勾选;比如使用了定位,则勾选定位相关的选项
再编辑“设备 ID” (如使用了uni-AD则再勾选“第三方广告”选项)

编辑“崩溃数据”

编辑“广告数据”(如果上一步勾选了)

完成界面

代码中如何获取IDFA标识

plus.device.getInfo({//需要勾选IDFA  
	success:function(e){  
		console.log('idfa =  '+JSON.stringify(e.idfa));  
	},  
	fail:function(e){  
		console.log('getDeviceInfo failed: '+JSON.stringify(e));  
	}  
});

也可通过native.js获取:

var idfa = '';  
var manager = plus.ios.invoke('ASIdentifierManager', 'sharedManager');  
if(plus.ios.invoke(manager, 'isAdvertisingTrackingEnabled')){  
	var identifier = plus.ios.invoke(manager, 'advertisingIdentifier');  
	idfa = plus.ios.invoke(identifier, 'UUIDString');  
	plus.ios.deleteObject(identifier);  
}  
plus.ios.deleteObject(manager);  
console.log('idfa = '+idfa);

参考Uni插件示例:https://ext.dcloud.net.cn/plugin?id=726

5+SDK离线打包

配置参考文档:https://nativesupport.dcloud.net.cn/AppDocs/usesdk/ios

注意事项

配置NSUserTrackingUsageDescription仍然审核不通过,提示违反5.1.1规则:

如果配置了开启广告标识(IDFA)并且也配置了 NSUserTrackingUsageDescription隐私描述,但是应用还是被App Stroe审核拒绝,且提示违反5.1.1规则:

Guideline 5.1.1 - Legal - Privacy - Data Collection and Storage    
  
We noticed that your app requests the user's consent to access the AppTrackingTransparency framework, but doesn't sufficiently explain the use of the AppTrackingTransparency framework in the purpose string.  
  
To help users make informed decisions about how their data is used, all permission request alerts need to specify how your app will use the requested information.    
  
Next Steps    
  
Please revise the relevant purpose string in your app's Info.plist file to specify why your app needs access to the user's AppTrackingTransparency framework.  
  
You can modify your app's Info.plist file using the property list editor in Xcode.  
  
Resources    
  
- See example of helpful, informative purpose strings.  
- Review a list of relevant property list keys.

则可能是描述内容过于简单,没有准确说明应用为什么要跟踪用户及访问设备的IDFA,可参考上文的建议更新NSUserTrackingUsageDescription描述内容

配置NSUserTrackingUsageDescription仍然审核不通过,提示违反2.1规则:

如果配置了开启广告标识(IDFA)并且也配置了 NSUserTrackingUsageDescription隐私描述,但是应用还是被App Stroe审核拒绝,且提示违反2.1规则:

Guideline 2.1 - Information Needed  
  
  
We're looking forward to completing the review of your app, but we need more information to continue. Specifically, we noticed that your app uses the AppTrackingTransparency framework, but we haven't been able to locate the App Tracking Transparency permission request.  
  
Next Steps  
  
Please indicate where in your app we can find the AppTrackingTransparency permission request. The request should appear before any data is collected that could be used to track the user.  
  
Apps that track user's activity must implement App Tracking Transparency and request permission before collecting data used to track.  
  
Resources  
  
See Frequently Asked Questions about the new requirements for apps that track users.  
  
Since your App Store Connect status is Metadata Rejected, we do NOT require a new binary. To revise the metadata, visit App Store Connect to select your app and revise the desired metadata values. Once you’ve completed all changes, reply to this message in Resolution Center and we will continue the review.

则可能是App Store Connect配置 “App 隐私”的选项不对,请参考上文重新 配置 “App 隐私”中的选项。

配置NSUserTrackingUsageDescription后真机运行不弹出授权提示框

如果按照上述描述勾选了IDFA 和配置了NSUserTrackingUsageDescription隐私描述,但是真机运行App启动时没有弹出授权提示框,可能的原因是,手机的系统版本是iOS14以下的,或者是iOS14.5的手机,但是手机“设置-隐私-跟踪”里,系统默认将“跟踪选项”关闭了且灰色不可设置;目前这种情况还不确定是iOS的bug,还是是针对地区特殊对待,解决办法:可以将账号切换成一个美区的,这时“跟踪选项”是可以操作的;或者将手机设置还原成默认设置,这时App启动时也能弹出授权提示框,但只会弹出一次。

4 关注 分享
x***@163.com 映月辉煌 阿龙攻城狮 1***@qq.com

要回复文章请先登录注册

华brilliant

华brilliant

回复 1***@qq.com :
请问怎么解决的
2022-02-07 10:17
1***@qq.com

1***@qq.com

回复 华brilliant :
解决了 上架好多天了
2022-02-06 23:35
华brilliant

华brilliant

回复 1***@qq.com :
请问你的问题解决了吗
2022-01-23 15:51
华brilliant

华brilliant

HTML5+ App项目中没任何广告模块,manifest.json也没勾选广告标识(IDFA),云打包成ipa,App Store审核不通过,反馈说项目中含有App Tracking Transparency.求解
2022-01-23 15:50
1***@qq.com

1***@qq.com

回复 machi的奶茶 :
我也是这个问题,解决完5.1.1现在又到5.1.2
2022-01-14 03:03
machi的奶茶

machi的奶茶

苹果IOS15.1未能弹出追踪授权框,过不了审核。

HBuilderX版本:3.3.5.20211229

测试设备:iPhone 13 Pro 15.1.1

测试流程:云打包成ipa->上传到transporter->构建testFlight版本->测试(无法弹出追踪授权框)


1.只使用了官方平台的统计,未使用到三方登录、广告类SDK。 mmanifest未开启广告标识(IDFA)

2.已配置NSUserTrackingUsageDescription隐私描述,描述内容为教程推荐描述

3.已配置“App 隐私”,崩溃数据(用于App 功能;用于追踪目的)


苹果审核提示:

Guideline 5.1.2 - Legal - Privacy - Data Use and Sharing


The app privacy information you provided in App Store Connect indicates you collect data in order to track the user, including Crash Data. However, you do not use App Tracking Transparency to request the user's permission before tracking their activity.

Starting with iOS 14.5, apps on the App Store need to receive the user’s permission through the AppTrackingTransparency framework before collecting data used to track them. This requirement protects the privacy of App Store users.

Next Steps

Here are two ways to resolve this issue:

- If you do not currently track, or decide to stop tracking, update your app privacy information in App Store Connect. You must have the Account Holder or Admin role to update app privacy information.

- If you track users, you must implement App Tracking Transparency and request permission before collecting data used to track. When you resubmit, indicate in the Review Notes where the permission request is located.
2022-01-13 01:17
DCloud_iOS_XHY

DCloud_iOS_XHY

回复 阿龙攻城狮 :
你好,更新使用 3.2.16 版本吧,升级时注意将所有依赖库及资源都更新了,3.2.16版本如果没用到 uniad 的话就不需要配置idfa了
2021-11-30 17:03
阿龙攻城狮

阿龙攻城狮

回复 DCloud_iOS_XHY :
我看了 App 离线打包SDK原生工程配置啊,我仔细看了该配置的都配置了。
苹果那边告诉我使用了 App Tracking Transparency,然而我在 info.plist 也按照文档添加了描述了。。
2021-11-26 20:11
DCloud_iOS_XHY

DCloud_iOS_XHY

回复 阿龙攻城狮 :
从你问题描述看你没有仔细阅读此文档,文档要求的配置并没有添加,苹果返回给你的问题是你使用了App Tracking Transparency,但是没有在 info.plist 中添加权限描述,文档已经给出云打包和离线打包分别配置的教程,请你在仔细阅读文档好好检查一下工程配置吧
2021-11-26 18:22
阿龙攻城狮

阿龙攻城狮

This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSUserTrackingUsageDescription key with a string value explaining to the user how the app uses this data. CoreSimulator 757.5 - Device: iPhone 11 Pro (F8014341-9F7C-4B04-9995-C1E4CD5C8BB8) - Runtime: iOS 14.5 (18E182) - DeviceType: iPhone 11 Pro

這是我沒有配置的時候,在模擬器 iOS 14.5 運行的崩潰日誌。
https://developer.apple.com/documentation/bundleresources/information_property_list/nsusertrackingusagedescription
這是蘋果的要求。
所以我現在不清楚 我是否需要 XH 中勾選 广告标识(IDFA)

Privacy - Tracking Usage Description 應該是必須配置的吧?
不勾選 广告标识(IDFA)是否也需要配置呢?
2021-11-26 17:26