-
-
Notifications
You must be signed in to change notification settings - Fork 0
Desktop Fallbacks
Google Mobile Ads and UMP are not available on Windows or Mac Catalyst in this library. MAUICross still supports those targets so one shared UI and DI graph can run safely.
<TargetFrameworks>net10.0-android;net10.0-ios;net10.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">
$(TargetFrameworks);net10.0-windows10.0.26100.0
</TargetFrameworks>Supported minimums are Mac Catalyst 15.0 and Windows 10 version 1809.
IAdMobConsentService is always registered, including desktop targets.
if (!consentService.IsSupported)
{
logger.LogInformation("UMP is unavailable; continuing without ads.");
return;
}The Windows/Mac Catalyst implementation reports:
| Member | Result |
|---|---|
IsSupported |
false |
CanRequestAds |
true |
IsInitialized |
true |
| consent status | NotRequired |
| privacy-options requirement | NotRequired |
GatherConsentAsync |
(CanRequestAds: true, PrivacyOptionsRequired: false) |
All operations complete without throwing and ignore cancellation because no
native work is started. The neutral CanRequestAds value prevents generic
startup code from being blocked, but it does not mean native ads exist on the
desktop platform. Use IsSupported for that distinction.
Define FallbackTemplate on the MAUI banner:
<admob:BannerAd AdUnitId="unused-on-desktop">
<admob:BannerAd.FallbackTemplate>
<DataTemplate>
<Border Padding="12" BackgroundColor="#EEEEEE">
<Label Text="Advertising is not available on this platform." />
</Border>
</DataTemplate>
</admob:BannerAd.FallbackTemplate>
</admob:BannerAd>The content is created lazily by the Windows or Mac Catalyst handler. Binding
context is propagated to the fallback content. If no template is supplied, the
default creates an empty ContentView.
Android and iOS never instantiate the fallback template; they render the native banner view.
The DI interfaces are registered so constructors remain cross-platform, but
calling load or show on Windows/Mac Catalyst throws
PlatformNotSupportedException.
Hide or disable mobile-only commands:
bool supportsNativeAds = OperatingSystem.IsAndroid() || OperatingSystem.IsIOS();
if (!supportsNativeAds)
return;
await interstitialService.LoadAndShowAsync(adUnitId);In XAML:
<Button
Text="Show interstitial"
IsVisible="{OnPlatform True, WinUI=False, MacCatalyst=False}" />- Resolve the same services on every target.
- Check
IAdMobConsentService.IsSupportedbefore UMP. - Let the application continue when consent is unavailable.
- Show
FallbackTemplateor remove the ad slot on desktop. - Never call full-screen ad methods on desktop.
- Keep platform-unavailable messages in debug/information logs rather than treating them as consent failures.