diff --git a/app/build.gradle b/app/build.gradle index 80e5d9245..2eaee1631 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -227,6 +227,10 @@ dependencies { implementation "com.google.android.gms:play-services-ads:$rootProject.ext.playServicesAdsVersion" implementation "com.google.android.ump:user-messaging-platform:$rootProject.ext.userMessagingPlatformVersion" + // Liftoff Monetize mediation via AdMob + implementation "com.google.ads.mediation:vungle:$rootProject.ext.liftoffMediationAdapterVersion" + implementation "com.vungle:vungle-ads:$rootProject.ext.vungleAdsVersion" + // Play In-App Updates implementation "com.google.android.play:app-update:$rootProject.ext.playAppUpdateVersion" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index af2465ba7..89d181383 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,7 +3,7 @@ xmlns:tools="http://schemas.android.com/tools" android:installLocation="auto"> - + = 23; on pre-M this is null and all methods become no-ops. + private val consentInformation: ConsentInformation? = + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) + UserMessagingPlatform.getConsentInformation(context) + else null fun gatherConsent(activity: Activity): Completable { + val info = consentInformation ?: return Completable.complete() + return Completable.create { emitter -> if (activity.isFinishing || activity.isDestroyed) { if (!emitter.isDisposed) { @@ -57,7 +64,7 @@ class ConsentManager private constructor(context: Context) { val params = ConsentRequestParameters.Builder() .build() - consentInformation.requestConsentInfoUpdate( + info.requestConsentInfoUpdate( activity, params, { @@ -92,6 +99,8 @@ class ConsentManager private constructor(context: Context) { } fun showPrivacyOptionsForm(activity: Activity): Completable { + consentInformation ?: return Completable.complete() + return Completable.create { emitter -> if (activity.isFinishing || activity.isDestroyed) { if (!emitter.isDisposed) { @@ -114,10 +123,10 @@ class ConsentManager private constructor(context: Context) { } } - fun canRequestAds(): Boolean = consentInformation.canRequestAds() + fun canRequestAds(): Boolean = consentInformation?.canRequestAds() ?: false fun isPrivacyOptionsRequired(): Boolean { - return consentInformation.privacyOptionsRequirementStatus == + return consentInformation?.privacyOptionsRequirementStatus == ConsentInformation.PrivacyOptionsRequirementStatus.REQUIRED } -} \ No newline at end of file +} diff --git a/build.gradle b/build.gradle index 463257878..fb1db9dd4 100644 --- a/build.gradle +++ b/build.gradle @@ -52,8 +52,10 @@ ext { pagingVersion = '2.1.2' locationServicesVersion = '21.0.1' geoHashVersion = '0.22' - playServicesAdsVersion = '24.6.0' - userMessagingPlatformVersion = '3.1.0' + playServicesAdsVersion = '24.9.0' + userMessagingPlatformVersion = '4.0.0' + liftoffMediationAdapterVersion = '7.7.0.1' + vungleAdsVersion = '7.7.0' coreKtxVersion = '1.16.0' playAppUpdateVersion = '2.1.0' }