SDK docs 0.1.0 preview
ContentsFor AI coding agents
0.1.0 preview. You install 0.1.0 from Maven Central and NGA's public repositories. Every 0.x version is a preview under the NGA SDK License, and the API can change until 1.0. Questions: hi@nga.network.

Guide

For AI coding agents

View as Markdown

Hand the integration to a coding agent such as Claude Code, Cursor or Copilot. Copy one prompt; the agent integrates the SDK up to a working test integration and asks you what only you can decide.

Before your agent starts #

Do these in the portal first; the agent cannot:

  1. Your studio is approved. See Sign up.
  2. The game is registered, from its store link or, before launch, from its package name or bundle id. See Register a game.
  3. Its placements exist: a Native placement for the banner, and an Interstitial or Rewarded placement for each full-screen backfill. See Placements.
  4. You have the app key and the placement ids. The agent asks for them first, and stops if they do not exist yet.

Copy the instructions #

Open your agent in your game's repository and paste this prompt. Fill in {{APP_KEY}}, {{PLATFORM}} and {{PLACEMENTS}} first, or leave them and the agent will ask.

agent-prompt.md
# Integrate the NGA SDK into this game, up to a working test integration

You are adding the NGA SDK 0.1.0, a preview version (the API can change until 1.0), to the game in this repository. NGA lets a studio promote its own games inside its other games: a native cross-promo banner the SDK shows at the bottom of the screen, and NGA's full-screen interstitial or rewarded ad, shown only when the game's own ad mediation has no fill. Your job ends at a working test integration. You do not take the game live.

## The rules

- Read https://nga.io/docs/sdk/llms-full.txt in full before you change anything. It is the whole guide and API reference. Follow it exactly: the package coordinates, the version 0.1.0, every call and callback name. Where this prompt and the docs differ, the docs win; tell the developer.
- Never invent an app key or a placement id, and never use the docs' examples (`app_YOURAPPKEY`, `plc_example_native`, `plc_example_interstitial`, `plc_example_rewarded`) in the game.
- Keep the game's mediation in charge: never load NGA's full-screen placement except from the mediation's load-failed callback, and never show it while the mediation has an ad ready.
- Change nothing in the game's mediation setup, ad units or consent flow except to add the NGA calls the docs give.
- Exception: if the game does not retry a failed mediation load, add the retry the Full-screen backfill page requires, and tell the developer.
- Do not edit files inside the NGA packages.
- When this prompt says to ask the developer, ask and wait for the answer. Go on with the work that does not depend on it.

## 1. The ids from the NGA portal

The integration needs these values from the developer's NGA portal (https://portal.nga.io):

- App key: {{APP_KEY}}
- Platform: {{PLATFORM}}
- Placements, each with its format: {{PLACEMENTS}}

If a value above is still a `{{…}}` placeholder, ask the developer for it before you write code that uses it. If they have no app key or no placements yet, stop. Tell them what is missing and send them to https://nga.io/docs/sdk/portal/ to get the studio approved, register the game, and create its placements (a Native placement for the banner; an Interstitial or Rewarded placement for each full-screen backfill). Continue when they have the ids.

## 2. Look before you change

Find these in the repository and tell the developer what you found:

- **The engine.** Unity (its version, and whether it builds for Android, iOS or both), native Android (Kotlin or Java, and the Gradle DSL), or native iOS (Swift or Objective-C, and how dependencies are managed). If it is none of these, stop: 0.1.0 supports Unity, Android and iOS only.
- **The mediation SDK**: AppLovin MAX, Unity LevelPlay or Google AdMob, its version, and where the game loads and shows its interstitial and rewarded ads. Another mediation, or none: say so, and wire no backfill.
- **The consent platform (CMP)**, if any (Google's UMP, or another that writes the IAB TCF or GPP keys), or the game's own consent screen, and where the game stores the player's answer. Whether the game has an age gate.
- **What is at the bottom of the screen**: whether the game shows a banner ad there, on which screens, and through which class of its mediation; the banner yield (step 4) hides and shows that banner ad.
- **A remove-ads purchase, and the game's languages.** Both decide when the native placement may load; the Native cross-promo page says how.

## 3. Install

Install the SDK as the Install page says for this engine, at 0.1.0: the core library always, and the render library, since this game shows NGA ads. On Unity, add both packages at the same tag, and check the External Dependency Manager and the player settings the page lists (on Unity 2022.3, *Minify* for every Android build type you make, development builds included). Build the game and fix what fails before you go on; on Unity, the NGA build check names each problem.

## 4. Initialize, with consent from the CMP

Initialize once, at start, exactly where and how the Initialize page says for this engine, with the app key from step 1:

- The consent: take it from the CMP the way the Consent, age and privacy page says. With a CMP that writes the IAB keys, pass `NGAConsent.unknown()` and let the SDK read them. With the game's own consent screen, pass the answer it stored, and call `setConsent` wherever that screen saves a new answer.
- In debug builds: test mode on and the log level at `DEBUG` before `initialize`, as the Initialize page shows.
- Log the result of `onInitialized`.
- On Unity, the bootstrap is a component on a GameObject in the first scene, as the Initialize page says. If you cannot add it to the scene yourself, write the component, make it run before the mediation's own start (its execution order), and ask the developer to add it.
- **The banner yield**, if the game shows a banner ad of its own: right after `initialize`, register `NGASDK.setBannerYield(hide, restore)` (`SetBannerYield` in Unity) with the `hide` and `restore` the Native cross-promo page gives for this mediation and engine, so the game's banner ad leaves the bottom of the screen just before NGA's banner shows and comes back when the show ends. Keep the game's own banner pauses apart from it, as the page's examples do. A game with no banner ad registers none.

## 5. Full-screen backfill

For each interstitial or rewarded NGA placement, wire NGA into the mediation's existing callbacks exactly as the Full-screen backfill page does for this mediation and engine, at the existing load-failed callback and show moment. Keep the game's own pause and resume around it, and leave the rest of the game's ad code as it is.

## 6. Ask the developer what only they can decide

Ask these, all together, and wait for the answers:

1. **The native banner**: on which screens and at which moments it shows. It may show only where nothing else of the game's is at the bottom of the screen: the banner reaches 133 dp on a phone and 236 dp on a tablet above the bottom safe-area edge, across the full width, and the SDK does not move, shrink or report it, so whatever the player must see or tap at that moment must end above that height. The game's own banner ad steps aside through the banner yield (step 4). The Native cross-promo page says when not to load the banner (a player who bought remove-ads; a game running in another language). The game calls `close()` (`Close()` in Unity) before it shows anything of its own at the bottom, and when it leaves that screen.
2. **Children**: is the game directed at children, or does it ask players their age? A game that asks calls `setAge` from its age gate; the Consent, age and privacy page says how.
3. **Rewards**: for each rewarded placement, what the player gets. The game pays it from `onRewardResult`, keyed by the ad's `opportunityId`.

Then wire the banner, the age and the rewards as the answers and the docs say.

## 7. The test integration

Done means all of this holds, on a device or an emulator or simulator:

1. Test mode is on in the build you test.
2. You have found the test-device id the SDK prints at init (`test-device id (App Set ID): …` on Android, `test-device id (IDFV): …` on iOS) and given it to the developer, with the request to register it in the portal under Test devices. The line says what the id covers: an Android build not installed by Google Play (every build you sideload) has an id of its own in each game, so each such game's id needs registering. You cannot register it yourself.
3. The `DEBUG` init summary shows a successful init: the render library found (`render module: found`), the app key accepted by the server, and every placement you wired in the configuration.
4. Each placement you wired loads and shows a test ad on the registered device, or you name the reason it cannot, from the error's `code` and `detail` (no fill while testing: see "No fill while testing" on the Test your integration page). Where the game shows a banner ad, it disappears while NGA's banner shows and comes back after.
5. The Test your integration page's checklist passes for what you wired.

Report each of the five: passed or not, and why. If you cannot run the game on a device, emulator or simulator, say so. Check what you can (both build targets compile; on Unity, the NGA build check passes), and tell the developer what to run and look for, for each of the five.

## What you do not do

You do not take any go-live step:

- You do not turn test mode off or change it for release builds.
- You do not work through the release checklist.
- You do not change anything in the portal: no switch, no serving, no store link, no placement and no test device.

Hand these back to the developer, with a link to https://nga.io/docs/sdk/go-live/, when you report.

The same text is at /docs/sdk/agent-prompt.md.

What the agent does #

It reads the whole guide and reference from one file, installs and initializes the SDK with the consent your consent platform holds, registers the banner yield if your game shows a banner ad, wires full-screen backfill into your mediation's existing load-failed callbacks, and turns test mode on for debug builds. It asks you four things: the app key and placement ids, if you did not fill them in; where the banner shows, with its height kept clear, and when your game closes it; whether the game is directed at children, or asks players their age; and the reward of each rewarded placement.

It stops at a working test integration: test mode on, your test-device id printed for you to register, a successful DEBUG init summary, each placement it wired showing a test ad on your registered device (or the reason it cannot, often no fill while testing), and the testing checklist passed.

You do the go-live steps yourself: test mode off in release builds, the release checklist, and checking the game's switches in the portal.

These docs for agents #

Every page of these docs is also plain Markdown, for an agent or for you:

  • Copy as Markdown, beside each page's title, copies that page. View as Markdown opens it: each page's URL followed by index.md, such as /docs/sdk/install/index.md.
  • /docs/sdk/llms.txt lists every page's Markdown, in the llms.txt convention.
  • /docs/sdk/llms-full.txt holds the whole guide and reference in one file, in the order of the sidebar.

In the Markdown, every platform's code is under its own label, so an agent sees Unity, Android and iOS together.