ExzileGames.AndroidConsentBridge
1.0.25
dotnet add package ExzileGames.AndroidConsentBridge --version 1.0.25
NuGet\Install-Package ExzileGames.AndroidConsentBridge -Version 1.0.25
<PackageReference Include="ExzileGames.AndroidConsentBridge" Version="1.0.25" />
<PackageVersion Include="ExzileGames.AndroidConsentBridge" Version="1.0.25" />
<PackageReference Include="ExzileGames.AndroidConsentBridge" />
paket add ExzileGames.AndroidConsentBridge --version 1.0.25
#r "nuget: ExzileGames.AndroidConsentBridge, 1.0.25"
#:package ExzileGames.AndroidConsentBridge@1.0.25
#addin nuget:?package=ExzileGames.AndroidConsentBridge&version=1.0.25
#tool nuget:?package=ExzileGames.AndroidConsentBridge&version=1.0.25
AndroidConsentBridge
A Java bridge + C# interop library for Google's User Messaging Platform (UMP) v3 on .NET Android. Collects GDPR and CCPA consent before any ads are shown. Must be called at app startup — before initializing AndroidAdsBridge or requesting any ad.
Problem
The Xamarin.Google.UserMessagingPlatform NuGet binding exposes the UMP SDK but requires wiring up Java ConsentInformation and form callbacks manually from C#. The binding's async surface returns Task<Java.Lang.Object> in several places, and errors from the UMP SDK (network errors, form load failures) are surfaced as raw Java exceptions that are hard to handle gracefully.
Solution
A compiled Java bridge class manages the ConsentInformation.requestConsentInfoUpdate → form load → form show lifecycle. It returns structured results to C# with error codes and messages, all without requiring any Java callback wiring in your application code.
APIs Exposed
| Method | Description |
|---|---|
RequestConsentInfoUpdateAsync(bool underAgeOfConsent, bool debugReset) |
Fetches current consent status from UMP servers. Pass debugReset: true during testing to force the form to appear. |
LoadAndShowConsentFormIfRequiredAsync() |
Shows the consent form if consent is required. No-op when not in a regulated region. |
CanRequestAds |
true when it is safe to initialize AdMob and request ads. |
GetConsentStatus() |
Returns Unknown, Required, NotRequired, or Obtained. |
Reset() |
Resets consent state. Debug/testing only — do not call in production. |
Setup
1. Add NuGet package
dotnet add package ExzileGames.AndroidConsentBridge
2. Initialize in your Activity
using AndroidConsentBridge.Interop;
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);
ConsentBridgeManager.SetImplementation(new AndroidConsentBridgeImpl(this));
}
3. Collect consent before showing ads
using AndroidConsentBridge.Interop;
// Request consent status from UMP servers
var update = await ConsentBridgeManager.RequestConsentInfoUpdateAsync(
tagForUnderAgeOfConsent: false,
debugReset: false);
if (update.Success)
{
// Show the form if required (no-op outside regulated regions)
var form = await ConsentBridgeManager.LoadAndShowConsentFormIfRequiredAsync();
if (form.CanRequestAds)
{
// Safe to initialize and load ads now
AdsBridgeManager.SetImplementation(new AndroidAdsBridgeImpl(this));
AdsBridgeManager.LoadRewardedAd(adUnitId);
}
}
Notes
- Always call
RequestConsentInfoUpdateAsyncandLoadAndShowConsentFormIfRequiredAsyncbefore initializingAndroidAdsBridge. Showing ads without collecting consent in regulated regions violates Google's policies. - Use
debugReset: trueduring development to force the consent form to appear regardless of region. CanRequestAdsreturnstrueboth when consent has been obtained and when the user is not in a regulated region.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-android36.0 is compatible. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
-
net10.0-android36.0
- Xamarin.Google.UserMessagingPlatform (>= 4.0.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.