-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from amirisback/develop/ump-support
DEVELOP :: Adding show ad consent function
- Loading branch information
Showing
92 changed files
with
179 additions
and
108 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
79 changes: 79 additions & 0 deletions
79
ad-admob/src/main/java/com/frogobox/admob/core/FrogoAdConsent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.frogobox.admob.core | ||
|
||
import com.google.android.ump.ConsentDebugSettings | ||
import com.google.android.ump.ConsentInformation | ||
import com.google.android.ump.ConsentRequestParameters | ||
import com.google.android.ump.UserMessagingPlatform | ||
|
||
|
||
/** | ||
* Created by faisalamir on 26/03/22 | ||
* FrogoAdmob | ||
* ----------------------------------------- | ||
* Name : Muhammad Faisal Amir | ||
* E-mail : faisalamircs@gmail.com | ||
* Github : github.com/amirisback | ||
* ----------------------------------------- | ||
* Copyright (C) 2022 Frogobox Media Inc. | ||
* All rights reserved | ||
* | ||
*/ | ||
|
||
|
||
object FrogoAdConsent { | ||
|
||
fun showConsent(callback: IFrogoAdConsent) { | ||
|
||
val consentInformation: ConsentInformation = | ||
UserMessagingPlatform.getConsentInformation(callback.activity()) | ||
|
||
val debugSettings = ConsentDebugSettings.Builder(callback.activity()) | ||
.setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA) | ||
.addTestDeviceHashedId("TEST-DEVICE-HASHED-ID").setForceTesting(true).build() | ||
|
||
// Set tag for underage of consent. false means users are not underage. | ||
val params = if (callback.isDebug()) { | ||
ConsentRequestParameters.Builder() | ||
.setTagForUnderAgeOfConsent(callback.isUnderAgeAd()) | ||
.setConsentDebugSettings(debugSettings) | ||
.build() | ||
} else { | ||
ConsentRequestParameters.Builder() | ||
.setTagForUnderAgeOfConsent(callback.isUnderAgeAd()) | ||
.build() | ||
} | ||
|
||
consentInformation.requestConsentInfoUpdate(callback.activity(), params, | ||
{ // The consent information state was updated. | ||
// You are now ready to check if a form is available. | ||
if (consentInformation.isConsentFormAvailable) { | ||
loadForm(consentInformation, callback) | ||
} | ||
}, | ||
{ | ||
// Handle the error. | ||
callback.onConsentError(it) | ||
}) | ||
} | ||
|
||
private fun loadForm(consentInformation: ConsentInformation, callback: IFrogoAdConsent) { | ||
// Loads a consent form. Must be called on the main thread. | ||
UserMessagingPlatform.loadConsentForm(callback.activity(), { consentForm -> | ||
if (consentInformation.consentStatus == ConsentInformation.ConsentStatus.REQUIRED) { | ||
consentForm.show(callback.activity()) { formError -> | ||
if (consentInformation.consentStatus == ConsentInformation.ConsentStatus.OBTAINED) { | ||
// App can start requesting ads. | ||
callback.onConsentSuccess() | ||
} | ||
|
||
// Handle dismissal by reloading form. | ||
loadForm(consentInformation, callback) | ||
} | ||
} | ||
}, { formError -> | ||
// Handle the error. | ||
callback.onConsentError(formError) | ||
}) | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions
30
ad-admob/src/main/java/com/frogobox/admob/core/IFrogoAdConsent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.frogobox.admob.core | ||
|
||
import android.app.Activity | ||
import com.google.android.ump.FormError | ||
|
||
/** | ||
* Created by Amir on 06/18/23 | ||
* FrogoAdmob Source Code | ||
* ----------------------------------------- | ||
* Name : Muhammad Faisal Amir | ||
* E-mail : faisalamircs@gmail.com | ||
* Github : github.com/amirisback | ||
* ----------------------------------------- | ||
* Copyright (C) 2023 FrogoBox Inc. | ||
* All rights reserved | ||
* | ||
*/ | ||
interface IFrogoAdConsent { | ||
|
||
fun activity(): Activity | ||
|
||
fun isDebug(): Boolean | ||
|
||
fun isUnderAgeAd(): Boolean | ||
|
||
fun onConsentSuccess() | ||
|
||
fun onConsentError(formError: FormError) | ||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.