Google UMP 使用指南
一、集成 UMP
Google UMP集成官方文档
implementation 'com.google.android.ump:user-messaging-platform:2.1.0'
示例代码
- TradPlus SDK进入APP只需要初始化一次
ConsentRequestParameters params = new ConsentRequestParameters
.Builder()
// 指示用户是否低于同意年龄; true 低于同意年龄
// 未满同意年龄的用户不会收到 GDPR 消息表单
.setTagForUnderAgeOfConsent(false)
.build();
consentInformation = UserMessagingPlatform.getConsentInformation(this);
consentInformation.requestConsentInfoUpdate(
this, params, (ConsentInformation.OnConsentInfoUpdateSuccessListener) () -> {
UserMessagingPlatform.loadAndShowConsentFormIfRequired(this,
(ConsentForm.OnConsentFormDismissedListener) loadAndShowError -> {
if (loadAndShowError != null) {
// Consent gathering failed.
// 授权失败,初始化SDK
}
// Consent has been gathered.
if (consentInformation.canRequestAds()) {
// 授权完成,初始化SDK
}
});
},(ConsentInformation.OnConsentInfoUpdateFailureListener) requestConsentError -> {
// Consent gathering failed.
// 授权失败,初始化SDK
});
if (consentInformation.canRequestAds()) {
// 授权完成,初始化SDK
}
二、在Admob后台开启UMP
1.访问Admob后台登录Admob账号,在 AdMob 中添加你的应用(如果您尚未添加应用)
2.点击“隐私权和消息”
3.点击“欧洲法规-管理”
4.点击“创建消息”,等待GDPR消息页面打开
5.在GDPR消息页面中点击右上角“选择应用”,选择您想要显示GDPR信息的应用
6.选择您想要显示消息的语言
7.在“定位”栏目中选择“须遵守 GDPR 的国家/地区(EEA 和 UK)”选项tips:推荐以下样式配置可以提高用户同意GDPR概率:
Tips:推荐以下样式配置可以提高用户同意GDPR概率:


三、指定的广告合作伙伴
默认情况下,Google 可能不会在您的 GDPR 消息中显示您项目中集成的所有广告平台。如果您未能包含这些广告平台,可能会对您的广告收入产生不利影响。请按照本部分中的步骤操作,确保您项目中集成的所有广告平台都出现在 GDPR 消息中。
1.在Admob后台“隐私权和消息”中点击“GDPR设置”,打开GDPR设置
2.点击“检查您的广告合作伙伴”部分下的编辑图标
3.选择“自行指定的广告合作伙伴“按钮
4.参考下方表格,勾选您项目中集成的所有广告平台
TradPlus Network | Google Name |
---|---|
Meta | |
AppLovin | AppLovin Corp |
IronSource | ironSource Mobile |
Chartboost | Chartboost |
UnityAds | Unity Ads |
Ogury | Ogury Ltd |
AdColony | AdColony |
Start.io | StartApp 或 Start.io Inc |
Verve | Verve Group |
LiftOff | Liftoff |
Fyber | Fyber |
Mintegral | Mobvista/Mintegral |
Amazon | Amazon |
InMobi | InMobi Choice |
Smaato | Smaato |
Yandex | Yandex |
Bigo | BIGOAds |
5.点击“确认”
6.点击GDPR设置页面最底部的“保存”按钮
注意:如果有弹出“重新向所有符合条件的用户征求意见?”弹窗时需要选择“重新提示”
四、TradPlus 相关设置
1.V10.9.0之前版本
开发者需要在UMP授权完成后调用GDRP设置API,相关代码如下:
// 正常集成UMP,授权完成后执行
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
// 同意
String purposeConsents = sharedPref.getString("IABTCF_PurposeConsents", "");
// 是否接受监管
int gdprApplies = sharedPref.getInt("IABTCF_gdprApplies", 0);
// 当前地区适用GDPR
if(gdprApplies == 1) {
if (!purposeConsents.isEmpty()) {
//授权完成后,开发者需根据授权结果,向TradPlusSDK设置GDPR状态
//参考代码如下
String purposeOneString = String.valueOf(purposeConsents.charAt(0));
boolean hasConsentForPurposeOne = purposeOneString.equals("1");
TradPlusSdk.setGDPRDataCollection(this,hasConsentForPurposeOne ? 0 : 1);
}
}
2.V10.9.0之后版本
大部份支持TCF2.0的三方广告源,TradPlus SDK 会根据平台情况自动进行适配处理
1.三方广告源自行获取的,则不进行任何设置操作 三方源:AppLovin、MTG、AlgoriX、Amazon、AdColony、Criteo、InMobi、Smaato 、Verve、Yandex Google Admob、Google GAM 、Google IMA和Helium
2.通过三方SDK API 传入 TCF v2 consent strings 三方源:DT Exchange, Ogury
3.根据Global Vendor List (GVL),TCF v2 string 授权情况后向三方SDK设置授权状态 三方源:Liftoff, Start.io
4.通过UMP Additional Consent (AC) Mode 来判断授权情况后向三方SDK设置授权状态 三方源: Chartboost、IronSource 、Unity 、Start.io
5.根据三方规则判断后向三方SDK设置授权状态 三方源:Pangle, Bigo
备注:其余不在列表中的Appnext、MyTarget、Tapjoy等,TradPlus会根据TradPlus弹窗的结果上报等级
3.Meta
- Meta明确要求开发者自行设置,广告合作伙伴中勾选Meta;
- 参考Meta文档 Data Processing Options for US Users 进行设置
// 集成UMP,授权完成后执行
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
// UMP Additional Consent (AC) Mode
String addtlConsent = sharedPref.getString("IABTCF_AddtlConsent", "");
// 是否接受监管
int gdprApplies = sharedPref.getInt("IABTCF_gdprApplies", 0);
if (gdprApplies == 1 && !TextUtils.isEmpty(addtlConsent)) {
if(addtlConsent.contains("89")) {
// 根据 Meta文档进行设置
}
}