官方文檔鏈接
Google 歐盟地區(qū)用戶意見征求政策 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
需要和發(fā)行溝通一下 開啟UMP測試
真機端測試配置環(huán)境
開啟VPN -選德國節(jié)點文章來源:http://www.zghlxwxcb.cn/news/detail-778757.html
接通成功應展示的界面
文章來源地址http://www.zghlxwxcb.cn/news/detail-778757.html
到了這里,關于Unity 歐盟UMP用戶隱私協(xié)議Android接入指南的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!