Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 697616850
  • Loading branch information
Justin Malandruccolo authored and copybara-github committed Nov 18, 2024
1 parent d5b16e0 commit 21c95a7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,34 @@ public void gatherConsent(
ConsentRequestParameters params =
new ConsentRequestParameters.Builder().setConsentDebugSettings(debugSettings).build();

// [START gather_consent]
// [START request_consent_info_update]
// Requesting an update to consent information should be called on every app launch.
consentInformation.requestConsentInfoUpdate(
activity,
params,
() ->
UserMessagingPlatform.loadAndShowConsentFormIfRequired(
activity,
formError -> {
// Consent has been gathered.
onConsentGatheringCompleteListener.consentGatheringComplete(formError);
}),
requestConsentError ->
() -> // Called when consent information is successfully updated.
// [START_EXCLUDE silent]
loadAndShowConsentFormIfRequired(activity, onConsentGatheringCompleteListener),
// [END_EXCLUDE]
requestConsentError -> // Called when there's an error updating consent information.
// [START_EXCLUDE silent]
onConsentGatheringCompleteListener.consentGatheringComplete(requestConsentError));
// [END gather_consent]
// [END_EXCLUDE]
// [END request_consent_info_update]
}

private void loadAndShowConsentFormIfRequired(
Activity activity, OnConsentGatheringCompleteListener onConsentGatheringCompleteListener) {
// [START load_and_show_consent_form]
UserMessagingPlatform.loadAndShowConsentFormIfRequired(
activity,
formError -> {
// Consent gathering process is complete.
// [START_EXCLUDE silent]
onConsentGatheringCompleteListener.consentGatheringComplete(formError);
// [END_EXCLUDE]
});
// [END load_and_show_consent_form]
}

/** Helper method to call the UMP SDK method to present the privacy options form. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,39 @@ class GoogleMobileAdsConsentManager private constructor(context: Context) {

val params = ConsentRequestParameters.Builder().setConsentDebugSettings(debugSettings).build()

// [START gather_consent]
// [START request_consent_info_update]
// Requesting an update to consent information should be called on every app launch.
consentInformation.requestConsentInfoUpdate(
activity,
params,
{
UserMessagingPlatform.loadAndShowConsentFormIfRequired(activity) { formError ->
// Consent has been gathered.
onConsentGatheringCompleteListener.consentGatheringComplete(formError)
}
// Called when consent information is successfully updated.
// [START_EXCLUDE silent]
loadAndShowConsentFormIfRequired(activity, onConsentGatheringCompleteListener)
// [END_EXCLUDE]
},
{ requestConsentError ->
// Called when there's an error updating consent information.
// [START_EXCLUDE silent]
onConsentGatheringCompleteListener.consentGatheringComplete(requestConsentError)
// [END_EXCLUDE]
},
)
// [END gather_consent]
// [END request_consent_info_update]
}

private fun loadAndShowConsentFormIfRequired(
activity: Activity,
onConsentGatheringCompleteListener: OnConsentGatheringCompleteListener,
) {
// [START load_and_show_consent_form]
UserMessagingPlatform.loadAndShowConsentFormIfRequired(activity) { formError ->
// Consent gathering process is complete.
// [START_EXCLUDE silent]
onConsentGatheringCompleteListener.consentGatheringComplete(formError)
// [END_EXCLUDE]
}
// [END load_and_show_consent_form]
}

/** Helper method to call the UMP SDK method to show the privacy options form. */
Expand Down

0 comments on commit 21c95a7

Please sign in to comment.