All skills
google avatar

/google-mobile-ads-banner

@329fa26
by googlegoogle/skills21k stars
1,698

Provides instructions to implement, integrate, or configure Google Mobile Ads (GMA) banner ads in Android, iOS, or Unity mobile applications. Use when the task involves setting up banner ads in a mobile application. Don't use for other ad formats like interstitial or rewarded ads.

Use this Skill: https://skilld.dev/gh/google/skills/google-mobile-ads-banner

This session only. Nothing lands on disk.

referencesunity-banner.md

≈801 tokens on demand. Your agent reads this file only when SKILL.md points to it.

AI Integration Agent Instructions for Unity Banner Ads

Required Imports

Use the following imports to implement a banner ad:

using System;
using UnityEngine;
using GoogleMobileAds.Api;
using GoogleMobileAds.Common;

Banner Ad Workflow

  1. Define the ad view:

    Use the BannerView class from GoogleMobileAds.Api for defining banner ads. Set the appropriate test ad unit ID when creating the ad view:

    • Android anchored adaptive: ca-app-pub-3940256099942544/9214589741
    • iOS anchored adaptive: ca-app-pub-3940256099942544/2435281174
  2. Set the ad size:

    Pass AdSize.Banner or the appropriate adaptive ad size to the BannerView constructor along with AdPosition (AdPosition.Top or AdPosition.Bottom).

    For an anchored adaptive banner, use a large anchored adaptive ad size unless the user complains or a small height is needed.

    int width = MobileAds.Utils.GetDeviceSafeWidth();
    AdSize adSize = AdSize
        .GetCurrentOrientationLargeAnchoredAdaptiveBannerAdSizeWithWidth(width);
    BannerView bannerView =
        new BannerView(_adUnitId, adSize, AdPosition.Bottom);
  3. Register for ad load events:

    Subscribing to ad events on the BannerView object is optional and depends on your application requirements:

    • OnBannerAdLoaded: Subscribe to update UI state when the banner ad is ready and displayed.
    • OnBannerAdLoadFailed: Subscribe to log errors if the banner ad fails to load.
    • OnAdPaid: Subscribe to log estimated ad revenue (AdValue) for impression-level ad monetization tracking.
    • OnAdImpressionRecorded: Subscribe to track ad impressions in internal telemetry or third-party analytics platforms.
    • OnAdClicked: Subscribe to record user clicks on the ad.
    • OnAdFullScreenContentOpened: Subscribe to pause game audio, timers, or gameplay loops when the banner click opens full-screen destination content.
    • OnAdFullScreenContentClosed: Subscribe to resume game audio or gameplay loops when full-screen destination content is dismissed.

    CRITICAL: Whenever you provide code or instructions for Unity ads, you MUST explicitly state that background ad callbacks interacting with Unity objects (UnityEngine) must be scheduled on the main thread using MobileAdsEventExecutor.ExecuteInUpdate(), because Unity APIs are not thread-safe.

    bannerView.OnBannerAdLoaded += () =>
    {
        MobileAdsEventExecutor.ExecuteInUpdate(() =>
        {
            // Interact with UnityEngine objects on the main thread here.
        });
    };
  4. Load the banner ad:

    Call the LoadAd() method on the BannerView object passing a new AdRequest object (bannerView.LoadAd(new AdRequest())).

    bannerView.LoadAd(new AdRequest());
  5. Verify the implementation:

    Compile the Unity csproj file by running dotnet build. Resolve any GMA SDK related compile errors.

Links

Additional documentation:

Source: SKILL.md on GitHub

No alerts8d3 checks · Risk SAFE
  • Gen Agent Trust Hub8d

    This skill provides instructions for implementing Google Mobile Ads banner ads across various platforms. It includes standard developer workflows, such as using local build tools to verify code integrity, and references official documentation.

  • Socket8d

    No alerts

  • Snyk8d

    Risk: LOW · No issues

Signed by skilld at 329fa26. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last week
metadata
{
  "version": "1.1.0",
  "category": "GoogleAds"
}

README badge

README badge for google/skills/google-mobile-ads-banner