Skip to content

iOS Usage

Alessandro Morvillo edited this page Aug 2, 2026 · 1 revision

iOS Usage

The iOS binding packages the Swift XCFramework built with Google's official Mobile Ads Swift package.

Packages and namespaces

For callbacks only:

<PackageReference Include="AMDevIT.Admob.Wrapper.iOSNative" Version="0.1.10" />

For async and shared UMP models:

<PackageReference Include="AMDevIT.Admob.Wrapper" Version="0.1.10" />
using AMDevIT.Admob.Wrapper.Extensions.iOSNative;
using AMDevIT.Admob.Wrapper.iOSNative;

Info.plist

<key>GADApplicationIdentifier</key>
<string>ca-app-pub-XXXXXXXXXXXXXXXX~YYYYYYYYYY</string>

UMP is supplied transitively by Google's Mobile Ads Swift package. Do not add a separate UMP Swift package to the native framework project.

Consent and initialization

Present UMP from a visible UIViewController:

AdMobManager manager = AdMobManager.Instance;

try
{
    ConsentGatheringResult consent = await manager.GatherConsentAsync(this);
    if (!consent.CanRequestAds)
        return;
}
catch (ConsentException exception) when (exception.CanRequestAds == true)
{
    // The previous consent state still permits requests.
}

await manager.InitializeAsync(this);

See Privacy and Consent UMP for privacy options, reset, under-age, and debug behavior.

Logger-aware objects

The manager and all ad wrappers accept IAppleLogger:

IAppleLogger logger = new MyAppleLogger();
AdMobManager manager = new(logger);
BannerAdWrapper banner = new(logger);

Use the same logger instance for the manager and wrappers if you want one ordered native diagnostic stream.

Adaptive banner

nfloat availableWidth = bannerContainer.Bounds.Width;
BannerAdWrapper banner = new(logger: null);

UIView adView = banner.LoadWithAdUnitId(
    "ca-app-pub-3940256099942544/6300978111",
    this,
    BannerAdViewSize.Adaptive,
    availableWidth,
    new BannerLoadListener(),
    eventListener: null);

bannerContainer.AddSubview(adView);

Fixed values are Banner, LargeBanner, MediumRectangle, FullBanner, and Leaderboard. Center fixed banners and ensure their width fits the current device class.

Interstitial

InterstitialAdWrapper interstitial = new(logger: null);
interstitial.LoadWithAdUnitId(
    "ca-app-pub-3940256099942544/1033173712",
    new AdLoadListener(),
    new AdEventListener());

if (interstitial.IsLoaded)
    interstitial.ShowWithViewController(this);

Rewarded

RewardedAdWrapper rewarded = new(logger: null);
rewarded.LoadWithAdUnitId(
    "ca-app-pub-3940256099942544/5224354917",
    new AdLoadListener(),
    new AdEventListener());

if (rewarded.IsLoaded)
    rewarded.ShowWithViewController(this, new RewardListener());

App open

AppOpenAdWrapper appOpen = new(logger: null);
appOpen.LoadWithAdUnitId(
    "ca-app-pub-3940256099942544/9257395921",
    new AdLoadListener(),
    new AdEventListener());

if (appOpen.IsLoaded && !appOpen.IsShowing)
    appOpen.ShowWithViewController(this);

Dismissal lifecycle

willDismiss emits a debug log only. The public dismissed callback is raised from didDismiss, after the native presentation has actually ended. Reload one-shot full-screen formats after dismissal.

Threading

Consent status access and UMP UI are main-thread operations in the native Swift framework. Start them from a visible view controller and marshal your own UI updates to the main thread when necessary.

Clone this wiki locally