Google 欧盟地区用户意见征求政策 UMPSDK接入文档
项目路径下 Assets/Plugins/Android/mainTemplate.gradle
implementation 'com.google.android.ump:user-messaging-platform:2.1.0'
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;
private ConsentInformation consentInformation;
boolean isUseEEA = false;
boolean isUseTestDeivce = false;
boolean isResetUMP = false;
在下面代码注释 “加载广告”的地方处理你的开屏广告
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
当isUseEEA,isUseTestDeivce,isResetUMP都为true时运行后搜setTestDeviceIds
开启VPN -选德国节点