-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added UMP SDK integration to Rewarded sample (#1071)
* Added UMP SDK integration to Rewarded sample * Only resume if paused * app bar widget * 5.1.0 --------- Co-authored-by: Justin Malandruccolo <[email protected]>
- Loading branch information
Showing
4 changed files
with
185 additions
and
11 deletions.
There are no files selected for viewing
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,51 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:google_mobile_ads/google_mobile_ads.dart'; | ||
|
||
typedef OnConsentGatheringCompleteListener = void Function(FormError? error); | ||
|
||
/// The Google Mobile Ads SDK provides the User Messaging Platform (Google's IAB | ||
/// Certified consent management platform) as one solution to capture consent for | ||
/// users in GDPR impacted countries. This is an example and you can choose | ||
/// another consent management platform to capture consent. | ||
class ConsentManager { | ||
/// Helper variable to determine if the app can request ads. | ||
Future<bool> canRequestAds() async { | ||
return await ConsentInformation.instance.canRequestAds(); | ||
} | ||
|
||
/// Helper variable to determine if the privacy options form is required. | ||
Future<bool> isPrivacyOptionsRequired() async { | ||
return await ConsentInformation.instance | ||
.getPrivacyOptionsRequirementStatus() == | ||
PrivacyOptionsRequirementStatus.required; | ||
} | ||
|
||
/// Helper method to call the Mobile Ads SDK to request consent information | ||
/// and load/show a consent form if necessary. | ||
void gatherConsent( | ||
OnConsentGatheringCompleteListener onConsentGatheringCompleteListener) { | ||
// For testing purposes, you can force a DebugGeography of Eea or NotEea. | ||
ConsentDebugSettings debugSettings = ConsentDebugSettings( | ||
debugGeography: DebugGeography.debugGeographyEea, | ||
); | ||
ConsentRequestParameters params = | ||
ConsentRequestParameters(consentDebugSettings: debugSettings); | ||
|
||
// Requesting an update to consent information should be called on every app launch. | ||
ConsentInformation.instance.requestConsentInfoUpdate(params, () async { | ||
ConsentForm.loadAndShowConsentFormIfRequired((loadAndShowError) { | ||
// Consent has been gathered. | ||
onConsentGatheringCompleteListener(loadAndShowError); | ||
}); | ||
}, (FormError formError) { | ||
onConsentGatheringCompleteListener(formError); | ||
}); | ||
} | ||
|
||
/// Helper method to call the Mobile Ads SDK method to show the privacy options form. | ||
void showPrivacyOptionsForm( | ||
OnConsentFormDismissedListener onConsentFormDismissedListener) { | ||
ConsentForm.showPrivacyOptionsForm(onConsentFormDismissedListener); | ||
} | ||
} |
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