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

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

要回复文章请先登录注册

Chuilee

Chuilee

回复 橘子桔子 :
确实,自己真机测试是有弹框,只是审核反馈说是没有,通过邮箱回复已经审核通过了
2022-05-11 12:09
橘子桔子

橘子桔子

回复 Chuilee :
应该是默认注册通知权限,然后15.4上面,如果有权限弹框开着,就不会打开第二个弹框, 即不会同时出现多个权限弹框。 导致的第一次进入APP没有看到追踪用户信息的弹框,。
2022-05-11 10:32
Chuilee

Chuilee

回复 枫雨 :
你好 你那边有解决了吗
2022-05-05 11:39
Chuilee

Chuilee

我有的也是3.3.13云打包的,苹果审核反馈在ios 15.4.1上是没有显示的
2022-05-05 11:35
枫雨

枫雨

3.3.13版本 没有弹窗,使用的vue2
2022-04-20 19:26
n***@qq.com

n***@qq.com

➜ SDK git:(FJXSxPRD) ✗ grep -r advertisingIdentifier .
Binary file ./Libs/GoogleAppMeasurementIdentitySupport.xcframework/ios-arm64_i386_x86_64-simulator/GoogleAppMeasurementIdentitySupport.framework/GoogleAppMeasurementIdentitySupport matches
Binary file ./Libs/GoogleAppMeasurementIdentitySupport.xcframework/ios-arm64_armv7/GoogleAppMeasurementIdentitySupport.framework/GoogleAppMeasurementIdentitySupport matches
Binary file ./Libs/libWeiboSDK.a matches
Binary file ./Libs/liblibAdSupport.a matches
Binary file ./Libs/Compatibles/KSAdSDK.framework/KSAdSDK matches
Binary file ./Libs/BUCNAuxiliary.framework/Versions/A/BUCNAuxiliary matches
Binary file ./Libs/BUCNAuxiliary.framework/Versions/Current/BUCNAuxiliary matches
Binary file ./Libs/BUCNAuxiliary.framework/BUCNAuxiliary matches
Binary file ./Libs/WindSDK.framework/WindSDK matches
Binary file ./Libs/KSAdSDK.framework/KSAdSDK matches
Binary file ./Libs/UMCommon.framework/UMCommon matches
Binary file ./Libs/GTSDK.framework/GTSDK matches
Binary file ./Libs/FBSDKCoreKit.framework/FBSDKCoreKit matches
Binary file ./Libs/BaiduMobAdSDK.framework/BaiduMobAdSDK matches
Binary file ./Libs/libGDTMobSDK.a matches

没有用到广告相关的东西, 但是用到GTSDK.framework, 是否需要配置 IDFA? 毕竟有 Binary file ./Libs/GTSDK.framework/GTSDK matches 这个提示
2022-03-18 10:55
w***@xinboxinmo.com

w***@xinboxinmo.com

回复 为什么不百度 :
可能是ios开发者网站上没有按照配置需求进行配置吧
2022-02-11 17:25
为什么不百度

为什么不百度

获取的idfa 为000-00000 -0000 都是 0 咋回事啊
2022-02-11 16:36
machi的奶茶

machi的奶茶

解决了,distribute-ios设置 "idfa" : true 就行了
2022-02-09 15:31
1***@qq.com

1***@qq.com

回复 华brilliant :
勾上 然后 选择 第三方 就可以了 应该是你用了第三方的sdk之类的 也算是ad
2022-02-08 12:21