ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

Unity 欧盟UMP用户隐私协议Android接入指南

2026/9/14 16:37:50 拓冰建站 浏览量
Unity 欧盟UMP用户隐私协议Android接入指南

Unity 欧盟UMP用户协议Android接入指南

    • 官方文档链接
    • 开始接入
      • mainTemplate.gradle 中引入
      • CustomUnityPlayerActivity 导入UMP相关的包
        • java类中新增字段
        • 初始化UMPSDK方法
        • 调用![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/d882171b068c46a1b956e80425f3a9cf.png)
        • 测试
        • 获取测试设备ID
        • 需要和发行沟通一下 开启UMP测试
        • 真机端测试配置环境
        • 接通成功应展示的界面

在这里插入图片描述

官方文档链接

Google 欧盟地区用户意见征求政策 UMPSDK接入文档

开始接入

mainTemplate.gradle 中引入

项目路径下 Assets/Plugins/Android/mainTemplate.gradle
在这里插入图片描述

implementation 'com.google.android.ump:user-messaging-platform:2.1.0'

CustomUnityPlayerActivity 导入UMP相关的包

import com.google.android.ump.ConsentInformation;
import com.google.android.ump.ConsentRequestParameters;
import com.google.android.ump.FormError;
import com.google.android.ump.UserMessagingPlatform;
import com.google.android.ump.ConsentForm;
import com.google.android.ump.ConsentDebugSettings;
java类中新增字段
   private ConsentInformation consentInformation;boolean isUseEEA = false;boolean isUseTestDeivce = false;boolean isResetUMP = false;
初始化UMPSDK方法

在下面代码注释 “加载广告”的地方处理你的开屏广告

 private  void InitUMPSDK(){if(isUseTestDeivce && isUseEEA){   ConsentDebugSettings debugSettings = new ConsentDebugSettings.Builder(this).setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA).addTestDeviceHashedId("TEST-DEVICE-HASHED-ID").build();}// Set tag for under age of consent. false means users are not under age// of consent.ConsentRequestParameters params = new ConsentRequestParameters.Builder().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.Log.w(TAG, String.format("%s: %s",loadAndShowError.getErrorCode(),loadAndShowError.getMessage()));}// Consent has been gathered.if (consentInformation.canRequestAds()) {// 在此处加载广告/// tpSplash.showAd();}});},(ConsentInformation.OnConsentInfoUpdateFailureListener) requestConsentError -> {// Consent gathering failed.Log.w(TAG, String.format("%s: %s",requestConsentError.getErrorCode(),requestConsentError.getMessage()));});// Check if you can initialize the Google Mobile Ads SDK in parallel// while checking for new consent information. Consent obtained in// the previous session can be used to request ads.if (consentInformation.canRequestAds()) {// 在此处加载广告/// tpSplash.showAd();}if(isResetUMP){consentInformation.reset();}//记录有没有授权SharedPreferences.Editor editor = sharedPreferences.edit();editor.putBoolean("authorization", true); //editor.apply();}
调用在这里插入图片描述
测试

TEST-DEVICE-HASHED-ID 为你的设备测试ID
在这里插入图片描述

获取测试设备ID

当isUseEEA,isUseTestDeivce,isResetUMP都为true时运行后搜setTestDeviceIds在这里插入图片描述

在这里插入图片描述

需要和发行沟通一下 开启UMP测试

在这里插入图片描述

真机端测试配置环境

开启VPN -选德国节点

接通成功应展示的界面

在这里插入图片描述