添加ump

This commit is contained in:
ocean 2024-07-18 17:38:19 +08:00
parent b49547cb9b
commit 3328827ab6
3 changed files with 15 additions and 7 deletions

View File

@ -101,6 +101,8 @@ dependencies {
implementation("io.github.scwang90:refresh-footer-ball:2.1.0")
implementation("com.google.code.gson:gson:2.10.1")
implementation("com.google.android.ump:user-messaging-platform:3.0.0")
//fb
implementation("com.facebook.android:facebook-android-sdk:latest.release")
//google

View File

@ -12,6 +12,8 @@ import melody.offline.music.fragment.MoMeFragment
import melody.offline.music.fragment.SearchFragment
import kotlinx.coroutines.isActive
import kotlinx.coroutines.selects.select
import melody.offline.music.ads.GoogleMobileAdsConsentManager
import melody.offline.music.util.LogTag
class PrimaryActivity : MoBaseActivity(), SearchFragment.SearchFragmentCancelClickListener ,MoHomeFragment.MoHomeFragmentToSearchClickListener{
/**
@ -42,6 +44,7 @@ class PrimaryActivity : MoBaseActivity(), SearchFragment.SearchFragmentCancelCli
private fun initView() {
initFragment()
initClick()
GoogleMobileAdsConsentManager.getInstance(this).gatherConsent(this)
}
private fun initClick() {

View File

@ -1,4 +1,4 @@
package pkg.com.master.ae.safevpn.ads
package melody.offline.music.ads
import android.app.Activity
import android.content.Context
@ -23,7 +23,7 @@ class GoogleMobileAdsConsentManager private constructor(context: Context) {
fun consentGatheringComplete(error: FormError?)
}
fun reset(){
fun reset() {
consentInformation.reset()
}
@ -43,7 +43,7 @@ class GoogleMobileAdsConsentManager private constructor(context: Context) {
*/
fun gatherConsent(
activity: Activity,
onConsentGatheringCompleteListener: OnConsentGatheringCompleteListener
onConsentGatheringCompleteListener: OnConsentGatheringCompleteListener? = null
) {
// For testing purposes, you can force a DebugGeography of EEA or NOT_EEA.
val debugSettings =
@ -57,7 +57,9 @@ class GoogleMobileAdsConsentManager private constructor(context: Context) {
.build()
val params = ConsentRequestParameters.Builder().setConsentDebugSettings(debugSettings).build()
val params = ConsentRequestParameters.Builder()
// .setConsentDebugSettings(debugSettings)
.build()
// Requesting an update to consent information should be called on every app launch.
consentInformation.requestConsentInfoUpdate(
activity,
@ -65,11 +67,11 @@ class GoogleMobileAdsConsentManager private constructor(context: Context) {
{
UserMessagingPlatform.loadAndShowConsentFormIfRequired(activity) { formError ->
// Consent has been gathered.
onConsentGatheringCompleteListener.consentGatheringComplete(formError)
onConsentGatheringCompleteListener?.consentGatheringComplete(formError)
}
},
{ requestConsentError ->
onConsentGatheringCompleteListener.consentGatheringComplete(requestConsentError)
onConsentGatheringCompleteListener?.consentGatheringComplete(requestConsentError)
}
)
}
@ -83,7 +85,8 @@ class GoogleMobileAdsConsentManager private constructor(context: Context) {
}
companion object {
@Volatile private var instance: GoogleMobileAdsConsentManager? = null
@Volatile
private var instance: GoogleMobileAdsConsentManager? = null
fun getInstance(context: Context) =
instance