A Unity sample project demonstrating a clean, maintainable integration of AppLovin MAX for showing ads:
- Banner ads
- Interstitial ads
- Two separate Rewarded ad units
Test the app on your own (APK Build 1.2.2)
Watch the app in action (Video Recording)
The project implements all listener and delegate methods for each ad type — even if only for logging — so you can clearly see the lifecycle of ads and how to hook into them.
This project and documentation can be extended upon request. New features like Zenject demonstration, automated android version and similar useful implementation can be added.
- Banner – Toggle on/off, positioned via settings.
- Interstitial – Fullscreen ad between content.
- Rewarded A & Rewarded B – Two separate reward scenarios for testing.
All relevant MAX callbacks are implemented and logged:
- SDK
OnSdkInitializedEvent
- Banner
OnAdLoadedEvent
OnAdLoadFailedEvent
OnAdClickedEvent
OnAdExpandedEvent
OnAdCollapsedEvent
OnAdRevenuePaidEvent
- Interstitial
OnAdLoadedEvent
OnAdLoadFailedEvent
OnAdDisplayedEvent
OnAdDisplayFailedEvent
OnAdClickedEvent
OnAdHiddenEvent
OnAdRevenuePaidEvent
- Rewarded
OnAdLoadedEvent
OnAdLoadFailedEvent
OnAdDisplayedEvent
OnAdDisplayFailedEvent
OnAdClickedEvent
OnAdHiddenEvent
OnAdReceivedRewardEvent
OnAdRevenuePaidEvent
-
- Initializes the MAX SDK once at app start and survives scene loads (DontDestroyOnLoad).
- Optional switches for verbose logging and test device IDs (must be set before InitializeSdk).
- Subscribes to MaxSdkCallbacks.OnSdkInitializedEvent and is the single place to kick off ad loading via MaxAdsService.
- Editor-safe: can expose a helper to open the Mediation Debugger on device.
- Common pitfalls it prevents: calling load/show before the SDK is initialized.
-
-
A small facade singleton that owns all ad controllers and exposes a tiny UI API:
- ToggleBanner(),
- ShowInterstitial(),
- ShowRewardedA(),
- ShowRewardedB().
-
Accepts a MaxAdSettings asset (ScriptableObject) so no IDs are hard-coded.
-
Subscribes once and guards against double registration (e.g., scene reloads).
-
Raises a simple ready signal after MAX init so UI can wire listeners safely.
-
Ideal place to later route impression revenue to analytics/MMPs (kept out of controllers).
-
-
- Creates/configures a banner via AdViewConfiguration (position + background color).
- Handles load/show/hide/toggle and logs all supported banner callbacks:
- OnAdLoaded,
- OnAdLoadFailed,
- OnAdClicked,
- OnAdExpanded,
- OnAdCollapsed,
- OnAdRevenuePaid.
-
-
Manages full-screen interstitials: preload → show → preload next.
-
Implements exponential backoff retry on load failures (1–64s).
-
Logs all interstitial callbacks:
- OnAdLoaded,
- OnAdLoadFailed,
- OnAdDisplayed,
- OnAdDisplayFailed,
- OnAdClicked,
- OnAdHidden,
- OnAdRevenuePaid.
-
Public API:
- Initialize(adUnitId),
- Preload(),
- Show().
-
-
-
Same lifecycle as interstitials, plus the reward flow.
- Logs all rewarded callbacks:
- OnAdLoaded,
- OnAdLoadFailed,
- OnAdDisplayed,
- OnAdDisplayFailed,
- OnAdClicked,
- OnAdHidden,
- OnAdReceivedReward,
- OnAdRevenuePaid.
- Logs all rewarded callbacks:
-
Exposes OnRewardGranted event so game code (e.g., “skip question”, coins) can react without touching ad logic.
-
Instantiated twice by MaxAdsService for Rewarded A and Rewarded B ad units.
-
-
-
ScriptableObject that centralizes ad configuration:
-
Android Ad Unit IDs:
- Banner,
- Interstitial,
- Rewarded A and Rewarded B
-
Banner position and background color
-
Whether the banner starts hidden
-
Create multiple assets (e.g., Dev, Staging, Prod) and swap them without changing code.
-
-
- Tiny helper to open the Mediation Debugger on device.
- Add to any UI button; useful for enabling Test Ads quickly and inspecting integrations.
-
- Binds a label to a resource value (e.g., coins), subscribing to updates from ResourcesController.
- Keeps the UI in sync when rewards are granted—great for demos/screenshots.
-
- Optional runtime wiring: attaches button onClick handlers after MaxAdsService reports ready.
- Prevents double listeners and logs wiring, so you don’t need to set OnClick in the Inspector.
-
- Minimal “reward sinks” to demonstrate integrating ads with game state.
- Each resource tracks a value (e.g., “Coins A/B”).
-
- Listens to RewardedAdController.OnRewardGranted and applies the corresponding reward to the selected resource(s).
- Updates any SimpleResourceLabel listeners and can persist via PlayerPrefs (optional).
- Keeps gameplay concerns (state/UI) decoupled from ad concerns (loading/showing/listening).
-
MaxInitializer
runs at startup.- Calls
MaxSdk.InitializeSdk()
and logs SDK details.
-
MaxAdsService
creates and initializes controllers for- Banner,
- Interstitial,
- Rewarded A, and Rewarded B.
- Preloads all ads on initialization as suggested.
- Exposes simple methods:
ToggleBanner()
,ShowInterstitial()
,ShowRewardedA()
,ShowRewardedB()
.
-
Controllers
- Each ad type has its own controller:
- Subscribes to all MAX events and logs them.
- Includes retry logic for failed loads (Interstitial & Rewarded).
- Banner appearance and placement is configurable via MaxAdSettings.
-
Rewards
- ResourcesController listens to
OnAdReceivedRewardEvent
. - Matches ad unit IDs to ResourceA or ResourceB.
- Grants rewards (with fallback amounts if
reward.Amount
is 0). - ResourceLabel updates UI automatically when resource values change.
- ResourcesController listens to
-
UI Binding
- AdButtonsBinder connects Unity UI Buttons to ad service methods once
MaxAdsService
is ready. - MediationButton opens the Mediation Debugger.
- AdButtonsBinder connects Unity UI Buttons to ad service methods once
-
Get Ad Unit IDs
- In the MAX dashboard, create:
- 1x Banner
- 1x Interstitial
- 2x Rewarded
- Assign them to MaxAdSettings in the Unity Inspector.
- In the MAX dashboard, create:
-
Test Device
- (Optional) Find your GAID and enter it in
MaxInitializer.testDeviceGAID
to enable test ads. - Additionally, set your device as a test device using the Mediation Debugger.
- (Optional) Find your GAID and enter it in
-
Run
- Open the demo scene.
- Press Play.
- Use the buttons to trigger ads and watch logs in the Console.
- New Rewarded Ads: Add new fields in
MaxAdSettings
and handle them inResourcesController
. - Different Reward Logic: Replace
ResourceA/B
with your own reward systems. - Custom UI: Replace
AdButtonsBinder
with your own game UI integration.
- Mediation Debugger – Use the “Open Mediation Debugger” button to inspect network setup.
- Verbose Logging – Toggle in
MaxInitializer
to see detailed logs. - Event Logs – All ad lifecycle events are logged with
[Banner]
,[Interstitial]
,[Rewarded]
tags.
There is no guard to protect the current Ad Service implementation from pausing/unfocusing the app. There may occur unwanted issues accordingly.
This repo includes automated versioning and continuous integration setup, so commit on main branch triggers version bumping without the need for manual actions.
- Automated Versioning – Uses semantic-release to bump version numbers, generate changelogs, and tag releases based on commit history.
- Why it matters – Ensures that demo builds shared with clients are always reproducible, versioned, and match the code in the repo.
This sample is for demonstration purposes.
Logo / Branding Notice:
The application icon and any sample branding used in this demo do not belong to me. They are included solely to improve UX and presentation for demonstration purposes. All trademarks, service marks, and logos remain the property of their respective owners. No affiliation or endorsement is implied. If you are a rights holder and would like any asset removed, please contact me and I will take it down immediately.
Developer: Alp Kurt, Berlin, Germany
If you have questions about this demo or the implementation details, feel free to reach out.