requestConsent method
Requests consent information and shows the consent form if needed.
This is called automatically during AdManager.initialize. Call manually to re-show the consent dialog from a settings screen.
Returns ConsentResult.obtained if consent was given or not required, ConsentResult.denied if the user declined, or ConsentResult.error if the request failed.
In production, this calls:
ConsentInformation.instance.requestConsentInfoUpdate()ConsentForm.loadAndShowConsentFormIfRequired()
Implementation
Future<ConsentResult> requestConsent() async {
try {
// In production, this would:
// 1. Call ConsentInformation.instance.requestConsentInfoUpdate()
// 2. Check if a consent form is required
// 3. If required, call ConsentForm.loadAndShowConsentFormIfRequired()
// 4. Map the resulting consent status
// For non-GDPR regions, consent is not required.
// The SDK handles this automatically.
_status = ConsentStatus.obtained;
return ConsentResult.obtained;
} catch (_) {
// On any error, fall back to non-personalized ads.
_status = ConsentStatus.unknown;
return ConsentResult.error;
}
}