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

在这里插入图片描述

官方文档链接

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 -选德国节点

接通成功应展示的界面

在这里插入图片描述

  • 30
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

极客柒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值