Features, compatibility, install, iOS (SPM / CocoaPods) and Android setup, usage guide, mediation adapters, privacy and ATT, troubleshooting, FAQ with a comparison to capacitor-levelplay-ads, and the docgen API section. |
||
|---|---|---|
| android | ||
| dist | ||
| ios/Sources/LevelPlayPlugin | ||
| src | ||
| .gitignore | ||
| CapacitorLevelplay.podspec | ||
| CHANGELOG.md | ||
| LICENSE | ||
| package.json | ||
| Package.swift | ||
| README.md | ||
| rollup.config.mjs | ||
| tsconfig.json | ||
capacitor-levelplay
Capacitor 8 plugin for Unity LevelPlay (formerly ironSource) mediation:
rewarded and interstitial ads on Android and iOS, built on LevelPlay's current ad-unit API
(LevelPlay.init, LevelPlayRewardedAd / LPMRewardedAd, LevelPlayInterstitialAd / LPMInterstitialAd).
import { LevelPlay } from 'capacitor-levelplay';
await LevelPlay.initialize({ appKey: 'your-app-key' });
await LevelPlay.loadRewarded({ adUnitId: 'your-rewarded-ad-unit' });
// ...
const result = await LevelPlay.showRewarded({ adUnitId: 'your-rewarded-ad-unit' });
if (result.rewarded) grantCoins(result.reward!.amount);
Contents
- Features
- Compatibility
- Install
- iOS setup
- Android setup
- Quick start
- Usage guide
- Mediation adapters
- Privacy and consent
- Troubleshooting
- FAQ
- API reference
- Contributing
- License
Features
- Rewarded and interstitial ads with LevelPlay's ad-unit API (SDK 9.x). One native ad object per ad unit id, so several rewarded or interstitial ad units can be used side by side.
- Promise-based show:
showRewarded/showInterstitialresolve after the ad closes with{ shown, rewarded, reward?, error?, adInfo? }. They never reject because an ad was not ready, and the plugin handles networks that deliver the reward after the close callback. - Swift Package Manager first on iOS: the plugin's
Package.swiftdepends on Unity's official LevelPlay-Swift-Package, sonpx cap syncon an SPM project really pulls the SDK. A podspec (IronSourceSDK) is included for CocoaPods projects. - App Tracking Transparency helper on iOS (
requestTrackingAuthorization,getTrackingAuthorizationStatus). - GDPR, CCPA and COPPA signals through LevelPlay's privacy settings API, settable before init.
- Integration Test Suite and integration validation (
launchTestSuite,validateIntegration) for checking adapters during development. - Typed events (
loaded,loadFailed,displayed,displayFailed,clicked,closed,rewarded) with ad info including impression revenue. - Demo ids (
LEVELPLAY_DEMO) from Unity's public sample apps for test ads during development. - Web stub: on the web nothing is ever ready and shows resolve
{ shown: false }, so the same game code runs in a browser.
Banners and native ads are not supported.
Compatibility
| Version | |
|---|---|
| Capacitor | 8 (@capacitor/core >= 8.0.0) |
| Unity LevelPlay SDK | 9.6.1 (Android com.unity3d.ads-mediation:mediation-sdk:9.6.1; iOS LevelPlay-Swift-Package 9.6.1 up to < 10, or the IronSourceSDK ~> 9.6.1 pod) |
| iOS | 15.0+ deployment target |
| Xcode | 26+ (Capacitor 8 requirement); tested with Xcode 27 |
| Android | minSdk 24, compileSdk / targetSdk 36 (Capacitor 8 defaults, overridable from variables.gradle) |
| Java | JDK 21 for Gradle builds |
| Node.js | 22+ (Capacitor 8 CLI) |
| Plugin | Capacitor | LevelPlay SDK |
|---|---|---|
| 0.2.x | 8 | 9.6.1 |
| 0.1.x | 8 | 9.6.1 |
Install
npm install capacitor-levelplay
npx cap sync
bun add capacitor-levelplay && bunx cap sync
yarn add capacitor-levelplay && yarn cap sync
pnpm add capacitor-levelplay && pnpm cap sync
iOS setup
Swift Package Manager (default)
Capacitor 8 projects created with SPM need nothing extra: npx cap sync adds the plugin to CapApp-SPM/Package.swift
and Xcode resolves the LevelPlay package (a binary xcframework, roughly 27 MB) on the next build.
CocoaPods (alternative)
CocoaPods projects get the CapacitorLevelplay pod from npx cap sync; it depends on Capacitor and
IronSourceSDK ~> 9.6.1. Run pod install (or npx cap sync ios) as usual. Mediation adapters are then added as pods
(IronSource<Network>Adapter) in the app's Podfile.
-ObjC linker flag
LevelPlay requires it: App target > Build Settings > Linking > Other Linker Flags > add -ObjC.
Info.plist
<!-- App Tracking Transparency prompt text (requestTrackingAuthorization). -->
<key>NSUserTrackingUsageDescription</key>
<string>Your data will be used to deliver ads that are more relevant to you.</string>
<!-- SKAdNetwork ids: LevelPlay's own id plus the ids of every network you mediate (see below). -->
<key>SKAdNetworkItems</key>
<array>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>su67r6k2v3.skadnetwork</string>
</dict>
<!-- ... -->
</array>
<!-- Recommended: copies of winning SKAdNetwork install-validation postbacks. -->
<key>NSAdvertisingAttributionReportEndpoint</key>
<string>https://postbacks-is.com/</string>
<!-- LevelPlay's integration guide asks for arbitrary loads (some ad creatives are served over http). -->
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Generating SKAdNetworkItems. su67r6k2v3.skadnetwork is LevelPlay's (ironSource Ads) id. Every mediated network
needs its own ids as well. Use Unity's SKAdNetwork ID manager
to export the combined list for the networks you enable, or merge each network's official list yourself (for example
Unity Ads publishes https://skan.mz.unity3d.com/v3/partner/skadnetworks.plist.json). A small script that downloads
the lists, extracts every xxxxxxxxxx.skadnetwork id, de-duplicates them and rewrites the SKAdNetworkItems array keeps
this repeatable; re-run it whenever you add a network and before each release. Some lists also carry AdAttributionKit
ids (.adattributionkit), which go into the AdNetworkIdentifiers array.
Full checklist: Unity's iOS SDK integration guide.
Android setup
Nothing beyond npx cap sync for most apps:
- Repositories: the SDK and all LevelPlay adapters are on Maven Central. Capacitor's default
android/build.gradlealready listsgoogle()andmavenCentral(); keep both. - Permissions: the plugin's manifest adds
com.google.android.gms.permission.AD_ID(required for the advertising id on Android 13+). The SDK's own manifest bringsINTERNET,ACCESS_NETWORK_STATE, its activities and providers. A child-directed app can stripAD_IDfrom its manifest withtools:node="remove". - Dependencies: the plugin module declares
mediation-sdkplus the Play servicesads-identifier,appsetandbasementartifacts the LevelPlay guide asks for. - ProGuard / R8: the core keep rules ship as consumer rules. If you minify, add the per-network rules from Unity's Android SDK integration guide for each adapter you add.
Optional: pin a different 9.x SDK from the app's android/variables.gradle:
ext {
levelPlayVersion = '9.6.1'
}
Gradle in Capacitor 8 projects needs JDK 21 (see Troubleshooting).
Quick start
import { Capacitor } from '@capacitor/core';
import { LevelPlay, LEVELPLAY_DEMO } from 'capacitor-levelplay';
// Unity's public demo ids serve test ads. Replace them with your own before release.
const ids = Capacitor.getPlatform() === 'ios' ? LEVELPLAY_DEMO.ios : LEVELPLAY_DEMO.android;
export async function startAds(): Promise<void> {
await LevelPlay.requestTrackingAuthorization(); // iOS ATT prompt; resolves 'unavailable' elsewhere
await LevelPlay.initialize({
appKey: ids.appKey,
consent: { gdprConsent: false }, // until your CMP says otherwise, see "Privacy and consent"
});
await LevelPlay.loadRewarded({ adUnitId: ids.rewarded });
await LevelPlay.loadInterstitial({ adUnitId: ids.interstitial });
}
export async function watchVideoForCoins(): Promise<number> {
const result = await LevelPlay.showRewarded({ adUnitId: ids.rewarded });
void LevelPlay.loadRewarded({ adUnitId: ids.rewarded }); // preload the next one
return result.rewarded ? (result.reward?.amount ?? 0) : 0;
}
Usage guide
Initialise with consent
Initialise once, as early as is sensible, after consent is known (and on iOS after the ATT prompt). Ads can only be
loaded after initialize resolves.
const { status } = await LevelPlay.requestTrackingAuthorization(); // iOS only, see Privacy and consent
const { sdkVersion } = await LevelPlay.initialize({
appKey: ids.appKey,
userId: playerId, // optional: needed for server-to-server reward callbacks
consent: {
gdprConsent: cmpSaysYes, // EEA / UK / CH users: false until a CMP collected consent
ccpaDoNotSell: false, // true if a US user opted out of sale / sharing
coppa: false, // true for child-directed treatment
},
});
initialize rejects with the SDK's init error (code, message); you can call it again later. Calling it after a
successful init resolves immediately, and concurrent calls share one init.
Rewarded ads
const REWARDED = ids.rewarded;
await LevelPlay.loadRewarded({ adUnitId: REWARDED });
// When the player taps "Watch a video":
const { ready } = await LevelPlay.isReady({ format: 'rewarded', adUnitId: REWARDED });
if (!ready) {
showToast('No video available right now');
} else {
const result = await LevelPlay.showRewarded({ adUnitId: REWARDED, placementName: 'DoubleCoins' });
if (result.rewarded && result.reward) {
grant(result.reward.name, result.reward.amount);
} else if (result.error) {
console.warn('rewarded not shown', result.error.code, result.error.message);
}
await LevelPlay.loadRewarded({ adUnitId: REWARDED }); // always load the next one
}
- The show promise resolves after the ad closes (or failed to display).
- Grant the reward only when
rewardedistrue. The reward and close callbacks can arrive in either order on some networks; the plugin waits up to 1 second after the close for a late reward before resolving. - When the ad is not ready, the promise resolves
{ shown: false, rewarded: false, error: { code: -1, message: 'Ad not ready' } }. placementNameis optional and refers to a placement configured in the LevelPlay dashboard (capping, pacing, reward).- For server-side rewards, pass
userIdtoinitializeand configure server-to-server callbacks in the dashboard.
Interstitial ads
await LevelPlay.loadInterstitial({ adUnitId: ids.interstitial });
// At a natural break, for example between levels:
const result = await LevelPlay.showInterstitial({ adUnitId: ids.interstitial });
// result.shown tells you whether it was displayed; game flow continues after the close.
void LevelPlay.loadInterstitial({ adUnitId: ids.interstitial });
Listening to events
Load results arrive only as events, so listen for loaded / loadFailed if you want to drive UI or retry logic.
import type { PluginListenerHandle } from '@capacitor/core';
const handles: PluginListenerHandle[] = [
await LevelPlay.addListener('loaded', (e) => console.log('loaded', e.format, e.adUnitId, e.adInfo?.adNetwork)),
await LevelPlay.addListener('loadFailed', (e) => {
console.warn('load failed', e.format, e.error.code, e.error.message);
setTimeout(() => {
void (e.format === 'rewarded'
? LevelPlay.loadRewarded({ adUnitId: e.adUnitId })
: LevelPlay.loadInterstitial({ adUnitId: e.adUnitId }));
}, 30_000); // retry later; use an increasing backoff in production
}),
await LevelPlay.addListener('displayed', (e) => trackImpression(e.adInfo?.revenue, e.adInfo?.adNetwork)),
await LevelPlay.addListener('rewarded', (e) => console.log('reward', e.reward.name, e.reward.amount)),
await LevelPlay.addListener('closed', (e) => resumeAudio()),
];
// later
await Promise.all(handles.map((h) => h.remove()));
// or: await LevelPlay.removeAllListeners();
Every event carries { format: 'rewarded' | 'interstitial', adUnitId, adInfo? }, plus error on loadFailed /
displayFailed and reward on rewarded.
Checking readiness
isReady({ format, adUnitId }) returns the native isAdReady() for that ad unit. It is false for an ad unit that was
never loaded. Use it to enable or disable a "watch video" button.
Integration Test Suite
The Integration Test Suite shows every configured network, its adapter status and lets you request test ads per network.
await LevelPlay.initialize({ appKey: ids.appKey, testSuite: true }); // sets is_test_suite=enable before init
await LevelPlay.launchTestSuite();
Development builds only. Unity recommends not calling other LevelPlay APIs before launching the suite, and the suite supports portrait orientation only.
Validate the integration
await LevelPlay.validateIntegration();
Writes LevelPlay's integration helper report to the native log: the Xcode console on iOS, logcat tag
IntegrationHelper on Android (adb logcat | grep IntegrationHelper). Each network is listed with its adapter and SDK
version and VERIFIED when everything is in place. Remove the call from release builds.
Meta data
Network-specific and SDK flags go through setMetaData before init, for example:
await LevelPlay.setMetaData({ key: 'is_deviceid_optout', value: 'true' });
Demo ids
LEVELPLAY_DEMO holds the public app keys and ad unit ids from Unity's official sample apps
(Mediation-Demo-Apps). They serve test ads; never ship
them.
| Platform | App key | Rewarded | Interstitial |
|---|---|---|---|
| Android | 25b63cf85 |
syz3d8ekts22q0or |
h3xw38h9214adgxo |
| iOS | 8545d445 |
qwouvdrkuwivay5q |
wmgt0712uuux8ju4 |
Web
LevelPlay has no web SDK. On the web initialize and launchTestSuite reject as unimplemented, isReady is always
false and shows resolve { shown: false, rewarded: false, error: { code: -1, ... } }.
Mediation adapters
The plugin brings the LevelPlay SDK (which includes ironSource Ads). Every other network is an adapter plus that network's SDK, added to your app, not to the plugin. Pick versions from Unity's adapter tables (Android, iOS) and take each adapter together with the network SDK version it was built for (the adapter changelog says "Supporting SDK version ..."). Then enable the network in the LevelPlay dashboard.
Android (Gradle)
Adapters live on Maven Central under com.unity3d.ads-mediation:<network>-adapter:<version>. Add each adapter and the
network SDK to android/app/build.gradle:
dependencies {
// Unity Ads
implementation 'com.unity3d.ads-mediation:unityads-adapter:<adapter version>'
implementation 'com.unity3d.ads:unity-ads:<sdk version>'
// Liftoff Monetize (Vungle)
implementation 'com.unity3d.ads-mediation:vungle-adapter:<adapter version>'
implementation 'com.vungle:vungle-ads:<sdk version>'
}
List the network SDK explicitly: the adapter artifacts do not pull it in. Some networks need more (Google AdMob, for
example, needs its com.google.android.gms.ads.APPLICATION_ID meta-data in AndroidManifest.xml, or the app crashes at
launch); check the network's page in Unity's docs.
iOS (Swift Package Manager)
Unity publishes official adapter packages on GitHub as
https://github.com/ironsource-mobile/LevelPlay-<Network>-Adapter-Swift-Package (for example
LevelPlay-UnityAds-Adapter-Swift-Package, LevelPlay-Vungle-Adapter-Swift-Package). In Xcode: File > Add Package
Dependencies, enter the URL, choose an exact version and add the product to the App target. Each package pulls
its network SDK and LevelPlay-Swift-Package 9.x, which resolves to the same copy the plugin uses.
Networks without an official Swift package. Not every network has one (at the time of writing, InMobi does not). Two options:
-
Use CocoaPods for the project and add the
IronSource<Network>Adapterpod. -
Keep SPM and wrap the adapter in a small local Swift package that mirrors the official packages: a
binaryTargetpointing at the adapter zip Unity publishes for CocoaPods (the URL is in the adapter's podspec, pin its SHA-256 withswift package compute-checksum), a dependency on the network's own Swift package at the version the adapter supports, a dependency onLevelPlay-Swift-Package9.x, and an empty Swift source file for the wrapper target. Add the local package to the App target via Add Package Dependencies > Add Local....// swift-tools-version: 5.9 import PackageDescription let package = Package( name: "LevelPlay-Example-Adapter", platforms: [.iOS(.v13)], products: [.library(name: "ExampleAdapter", targets: ["ExampleAdapter"])], dependencies: [ .package(url: "https://github.com/<network>/<Network>SDK-Swift-Package.git", exact: "<sdk version>"), .package(url: "https://github.com/ironsource-mobile/LevelPlay-Swift-Package.git", "9.0.0"..<"10.0.0"), ], targets: [ .target( name: "ExampleAdapter", // Sources/ExampleAdapter/ExampleAdapter.swift can be empty dependencies: [ "ExampleAdapterBinary", .product(name: "<NetworkSDK product>", package: "<Network>SDK-Swift-Package"), .product(name: "UnityMediationSDK", package: "LevelPlay-Swift-Package"), ]), .binaryTarget( name: "ExampleAdapterBinary", url: "<adapter zip URL from the adapter podspec>", checksum: "<sha256>"), ] )Add any system libraries the network's manual-integration guide lists as
linkerSettings.
After adding networks: update SKAdNetworkItems (iOS setup), rebuild both platforms and run
validateIntegration().
Privacy and consent
LevelPlay recommends setting privacy signals before initialize. Pass them as consent to initialize or call
setConsent first; call setConsent again whenever the user changes their choice. They map to
LevelPlayPrivacySettings (Android) and LPMPrivacySettings (iOS): setGDPRConsent, setCCPA, setCOPPA. See
Unity's regulation settings.
- GDPR (EEA, UK, Switzerland): pass
gdprConsent: falseuntil a consent management platform (CMP) collected consent, thentrueorfalseaccording to the user's choice. If you use an IAB TCF v2 CMP (for example Google UMP), LevelPlay and many networks also read the TCF consent string the CMP stores on the device. - CCPA and other US state laws:
ccpaDoNotSell: truewhen the user opted out of the sale or sharing of personal data. - COPPA:
coppa: truefor users who must get child-directed treatment. Child-directed apps should also strip theAD_IDpermission on Android and should not show the ATT prompt.
App Tracking Transparency (iOS)
Without ATT authorization the IDFA is zeros and ads earn less, so ask before init:
- Add
NSUserTrackingUsageDescriptiontoInfo.plist. - Call
requestTrackingAuthorization()when the app is active (iOS ignores the request while the app is still launching or in the background) and beforeinitialize. Show your CMP first if you have one. - iOS shows the system prompt only once; later calls resolve the stored status. Use
getTrackingAuthorizationStatus()to read it without prompting.
const { status } = await LevelPlay.getTrackingAuthorizationStatus();
if (status === 'notDetermined') await LevelPlay.requestTrackingAuthorization();
await LevelPlay.initialize({ appKey });
Troubleshooting
Loads fail with 509 "No fill"
Common and usually not a bug. An app that is not live in its store yet (or not approved in the LevelPlay dashboard)
gets little or no real demand. Use the demo ids (LEVELPLAY_DEMO) or the Integration Test Suite with test ads to
check your integration, and retry loads with a backoff in production. Unity's
troubleshooting guide lists
more causes.
Unity Ads: "Invalid Game ID"
The Unity Ads adapter is started with the game id configured on the Unity Ads instance in LevelPlay. If Unity Ads answers "Invalid Game ID: ..." (iOS: "Initialization failed: not found"), the Unity Ads project or game is not active, or the instance uses a game id from another project. Check the game ids in the Unity dashboard and that they belong to the project linked to your LevelPlay app.
Android build fails with "Unsupported class file major version"
Gradle for Capacitor 8 must run on JDK 21. Android Studio's bundled runtime can be newer than the Gradle version supports (for example "Unsupported class file major version 69" with Java 25). Point Gradle at a JDK 21:
export JAVA_HOME=$(/usr/libexec/java_home -v 21) # macOS
cd android && ./gradlew assembleDebug
In Android Studio: Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JDK.
iOS: "No such module 'IronSource'" or the package does not update
- Run
npx cap sync iosafter every install or upgrade of the plugin; it rewritesCapApp-SPM/Package.swift. - In Xcode: File > Packages > Reset Package Caches, then Resolve Package Versions.
- Still stuck: quit Xcode, delete
~/Library/Developer/Xcode/DerivedData/<App>-*and~/Library/Caches/org.swift.swiftpm, then reopen. - CocoaPods projects:
cd ios/App && pod install --repo-update.
iOS: crash or missing symbols at launch
Check the -ObjC linker flag on the App target.
Nothing happens on showRewarded
showRewarded resolves { shown: false, error: { code: -1, message: 'Ad not ready' } } when no ad is loaded for that ad
unit. Make sure you called loadRewarded with the same adUnitId after initialize resolved, and wait for the
loaded event (or isReady).
FAQ
Which LevelPlay API does it use?
LevelPlay's ad-unit API, the current API in SDK 9.x: LevelPlay.init with an init request,
LevelPlayRewardedAd / LevelPlayInterstitialAd on Android and LPMRewardedAd / LPMInterstitialAd on iOS. The
legacy IronSource.* placement API is not used.
Can I use more than one ad unit per format?
Yes. Every call takes an adUnitId, and the plugin keeps one native ad object per id.
Does it support banners or native ads? No. It focuses on full-screen formats.
How is this different from capacitor-levelplay-ads?
Both are Capacitor 8 plugins for LevelPlay and both use the ad-unit API. The differences, as of capacitor-levelplay-ads
0.1.42:
capacitor-levelplay |
capacitor-levelplay-ads |
|
|---|---|---|
| iOS integration | SPM first: Package.swift depends on LevelPlay-Swift-Package; podspec as alternative |
CocoaPods first; its Package.swift does not depend on the SDK (SDK code is compiled out unless you add a package yourself) |
| Formats | rewarded, interstitial | banner, rewarded, interstitial |
| Ad units | any number per format side by side, addressed by adUnitId |
one ad object per format at a time |
| Show result | promise resolves after close with { shown, rewarded, reward } |
outcome via events |
| Consent | GDPR / CCPA / COPPA flags; bring your own CMP | built-in consent flows (own consent modal, optional Usercentrics / InMobi CMP) |
| Adapters | added by the app (Gradle / Swift packages / pods) | helper script that injects adapter pods from package.json |
Pick the one that fits your project.
Is the LevelPlay SDK bundled? No. The plugin declares the SDK as a dependency (Maven Central, Swift package or pod). The SDK is proprietary and covered by Unity's terms.
API
initialize(...)getSdkVersion()setConsent(...)setMetaData(...)requestTrackingAuthorization()getTrackingAuthorizationStatus()loadRewarded(...)showRewarded(...)loadInterstitial(...)showInterstitial(...)isReady(...)launchTestSuite()validateIntegration()addListener('loaded', ...)addListener('loadFailed', ...)addListener('displayed', ...)addListener('displayFailed', ...)addListener('clicked', ...)addListener('closed', ...)addListener('rewarded', ...)removeAllListeners()- Interfaces
- Type Aliases
Unity LevelPlay rewarded and interstitial ads (ad-unit API).
initialize(...)
initialize(options: InitOptions) => Promise<InitResult>
Initialise the LevelPlay SDK (LevelPlay.init). Resolves on init success, rejects with the init error
(code and message from the SDK) otherwise. Calling it again after a successful init resolves immediately;
concurrent calls share one init. Load ads only after this resolves.
Set consent (and on iOS ask for ATT) before calling it.
On the web it rejects as unimplemented.
| Param | Type |
|---|---|
options |
InitOptions |
Returns: Promise<InitResult>
Since: 0.1.0
getSdkVersion()
getSdkVersion() => Promise<InitResult>
Native LevelPlay SDK version. Works before init.
Returns: Promise<InitResult>
Since: 0.1.0
setConsent(...)
setConsent(options: ConsentOptions) => Promise<void>
Forward GDPR / CCPA / COPPA signals to LevelPlay. Call it before initialize() when you
can, and again whenever the user changes their choice.
| Param | Type |
|---|---|
options |
ConsentOptions |
Since: 0.1.0
setMetaData(...)
setMetaData(options: MetaDataOptions) => Promise<void>
Raw LevelPlay.setMetaData(key, value) for SDK or network-specific flags. Call it before init.
| Param | Type |
|---|---|
options |
MetaDataOptions |
Since: 0.1.0
requestTrackingAuthorization()
requestTrackingAuthorization() => Promise<TrackingResult>
iOS: show the App Tracking Transparency prompt and resolve with the resulting status. Needs
NSUserTrackingUsageDescription in Info.plist. iOS only shows the prompt once; later calls resolve the stored
status. Call it before initialize(), while the app is active.
Android and web: resolves unavailable.
Returns: Promise<TrackingResult>
Since: 0.1.0
getTrackingAuthorizationStatus()
getTrackingAuthorizationStatus() => Promise<TrackingResult>
Current App Tracking Transparency status without prompting (iOS). Android and web: unavailable.
Returns: Promise<TrackingResult>
Since: 0.1.0
loadRewarded(...)
loadRewarded(options: AdUnitOptions) => Promise<void>
Start loading a rewarded ad for the ad unit. The native ad object is created on first use and reused for the
ad unit. Resolves once the request is issued; the outcome arrives as a loaded or loadFailed event.
Load the next ad after each show.
| Param | Type |
|---|---|
options |
AdUnitOptions |
Since: 0.1.0
showRewarded(...)
showRewarded(options: ShowOptions) => Promise<ShowResult>
Show a loaded rewarded ad. Resolves after the ad closed (or failed to display) with what happened. The reward
and close callbacks can arrive in either order on some networks, so the plugin waits up to 1 second after the close
for a late reward. Never rejects for "not ready": resolves { shown: false, rewarded: false, error } instead.
| Param | Type |
|---|---|
options |
ShowOptions |
Returns: Promise<ShowResult>
Since: 0.1.0
loadInterstitial(...)
loadInterstitial(options: AdUnitOptions) => Promise<void>
Start loading an interstitial ad for the ad unit. Works like loadRewarded().
| Param | Type |
|---|---|
options |
AdUnitOptions |
Since: 0.1.0
showInterstitial(...)
showInterstitial(options: ShowOptions) => Promise<ShowResult>
Show a loaded interstitial. Resolves after it closed (or failed to display). Never rejects for "not ready".
| Param | Type |
|---|---|
options |
ShowOptions |
Returns: Promise<ShowResult>
Since: 0.1.0
isReady(...)
isReady(options: IsReadyOptions) => Promise<IsReadyResult>
isAdReady() of the native ad object for this ad unit. false when the ad unit was never loaded.
| Param | Type |
|---|---|
options |
IsReadyOptions |
Returns: Promise<IsReadyResult>
Since: 0.1.0
launchTestSuite()
launchTestSuite() => Promise<void>
Open the LevelPlay Integration Test Suite. Requires initialize({ testSuite: true }) first.
Development builds only. Rejects on the web.
Since: 0.1.0
validateIntegration()
validateIntegration() => Promise<void>
Write the LevelPlay integration helper report to the native log (Xcode console; Android logcat tag
IntegrationHelper): SDK, adapter and network SDK versions, each VERIFIED or not. Development only.
Since: 0.1.0
addListener('loaded', ...)
addListener(eventName: 'loaded', listenerFunc: (event: AdEvent) => void) => Promise<PluginListenerHandle>
An ad finished loading for the ad unit and can be shown.
| Param | Type |
|---|---|
eventName |
'loaded' |
listenerFunc |
(event: AdEvent) => void |
Returns: Promise<PluginListenerHandle>
Since: 0.1.0
addListener('loadFailed', ...)
addListener(eventName: 'loadFailed', listenerFunc: (event: AdErrorEvent) => void) => Promise<PluginListenerHandle>
Loading failed, for example 509 (no fill). Retry later with a backoff.
| Param | Type |
|---|---|
eventName |
'loadFailed' |
listenerFunc |
(event: AdErrorEvent) => void |
Returns: Promise<PluginListenerHandle>
Since: 0.1.0
addListener('displayed', ...)
addListener(eventName: 'displayed', listenerFunc: (event: AdEvent) => void) => Promise<PluginListenerHandle>
The ad was displayed (impression). adInfo.revenue is available here.
| Param | Type |
|---|---|
eventName |
'displayed' |
listenerFunc |
(event: AdEvent) => void |
Returns: Promise<PluginListenerHandle>
Since: 0.1.0
addListener('displayFailed', ...)
addListener(eventName: 'displayFailed', listenerFunc: (event: AdErrorEvent) => void) => Promise<PluginListenerHandle>
The ad failed to display. The pending show call resolves with the same error.
| Param | Type |
|---|---|
eventName |
'displayFailed' |
listenerFunc |
(event: AdErrorEvent) => void |
Returns: Promise<PluginListenerHandle>
Since: 0.1.0
addListener('clicked', ...)
addListener(eventName: 'clicked', listenerFunc: (event: AdEvent) => void) => Promise<PluginListenerHandle>
The user clicked the ad.
| Param | Type |
|---|---|
eventName |
'clicked' |
listenerFunc |
(event: AdEvent) => void |
Returns: Promise<PluginListenerHandle>
Since: 0.1.0
addListener('closed', ...)
addListener(eventName: 'closed', listenerFunc: (event: AdEvent) => void) => Promise<PluginListenerHandle>
The ad was closed and the app is back in front.
| Param | Type |
|---|---|
eventName |
'closed' |
listenerFunc |
(event: AdEvent) => void |
Returns: Promise<PluginListenerHandle>
Since: 0.1.0
addListener('rewarded', ...)
addListener(eventName: 'rewarded', listenerFunc: (event: AdRewardEvent) => void) => Promise<PluginListenerHandle>
Rewarded only: the user earned the reward. Can fire before or after closed.
| Param | Type |
|---|---|
eventName |
'rewarded' |
listenerFunc |
(event: AdRewardEvent) => void |
Returns: Promise<PluginListenerHandle>
Since: 0.1.0
removeAllListeners()
removeAllListeners() => Promise<void>
Remove every listener of this plugin.
Since: 0.1.0
Interfaces
InitResult
Result of initialize() and getSdkVersion().
| Prop | Type | Description | Since |
|---|---|---|---|
sdkVersion |
string |
Native LevelPlay SDK version, for example 9.6.1. web on the web. |
0.1.0 |
InitOptions
Options for initialize().
| Prop | Type | Description | Default | Since |
|---|---|---|---|---|
appKey |
string |
LevelPlay app key from the LevelPlay dashboard. Android and iOS apps have different keys. | 0.1.0 | |
userId |
string |
Optional user id. Needed for server-to-server reward callbacks and the Ad Quality user journey. | 0.1.0 | |
testSuite |
boolean |
Enable the LevelPlay Integration Test Suite: sets the is_test_suite=enable meta data before init. Call launchTestSuite() after initialize resolves. Never ship this enabled. |
false |
0.1.0 |
adaptersDebug |
boolean |
Turn on debug logs of the mediated ad network adapters (LevelPlay.setAdaptersDebug(true)). Development only. |
false |
0.1.0 |
consent |
ConsentOptions |
Privacy signals applied right before init (LevelPlay recommends setting them before the SDK starts). Same as calling setConsent() first. |
0.1.0 |
ConsentOptions
Privacy signals forwarded to LevelPlay (LevelPlayPrivacySettings on Android, LPMPrivacySettings on iOS).
Omitted fields are left untouched.
| Prop | Type | Description | Since |
|---|---|---|---|
gdprConsent |
boolean |
GDPR: true when the user consented to personalised ads and data processing, false when they did not. For users in the EEA, UK and Switzerland pass false until a consent management platform (CMP) says otherwise. |
0.1.0 |
ccpaDoNotSell |
boolean |
CCPA and other US state privacy laws: true when the user opted OUT of the sale or sharing of personal data ("do not sell"), false otherwise. |
0.1.0 |
coppa |
boolean |
COPPA: true when the user must be treated as a child (child-directed treatment). |
0.1.0 |
MetaDataOptions
Options for setMetaData().
| Prop | Type | Description | Since |
|---|---|---|---|
key |
string |
Meta data key, for example is_deviceid_optout or a network-specific flag from Unity's docs. |
0.1.0 |
value |
string |
Meta data value, always a string (for example "true"). |
0.1.0 |
TrackingResult
Result of requestTrackingAuthorization() and
getTrackingAuthorizationStatus().
| Prop | Type | Description | Since |
|---|---|---|---|
status |
TrackingStatus |
iOS App Tracking Transparency status. Always unavailable on Android and web. |
0.1.0 |
AdUnitOptions
Identifies one ad unit.
| Prop | Type | Description | Since |
|---|---|---|---|
adUnitId |
string |
Ad unit id from the LevelPlay dashboard (Ad units page). Android and iOS ad units have different ids. | 0.1.0 |
ShowResult
Result of showRewarded() and showInterstitial(), resolved after the ad
closed or failed to display.
| Prop | Type | Description | Since |
|---|---|---|---|
shown |
boolean |
The ad was displayed (the displayed event fired). |
0.1.0 |
rewarded |
boolean |
Rewarded only: the reward callback fired for this show. Grant the reward only when this is true. Always false for interstitials. |
0.1.0 |
reward |
Reward |
The reward, present when rewarded is true. |
0.1.0 |
error |
AdError |
Present when the ad was not ready (code: -1) or failed to display. |
0.1.0 |
adInfo |
AdInfo |
Info of the displayed ad. | 0.1.0 |
Reward
The reward of a rewarded ad, as configured in the LevelPlay dashboard (per ad unit or placement).
| Prop | Type | Description | Since |
|---|---|---|---|
name |
string |
Name of the reward, for example Coins. |
0.1.0 |
amount |
number |
Amount of the reward. | 0.1.0 |
AdError
Error reported by the SDK (load / display failures) or by the plugin.
| Prop | Type | Description | Since |
|---|---|---|---|
code |
number |
LevelPlay error code, for example 509 (no fill). -1 is used by the plugin for "Ad not ready" and for the web stub. |
0.1.0 |
message |
string |
Human readable message. | 0.1.0 |
AdInfo
Subset of the native LevelPlayAdInfo (Android) / LPMAdInfo (iOS) that is useful in JavaScript.
Fields the SDK does not report are omitted.
| Prop | Type | Description | Since |
|---|---|---|---|
adId |
string |
Unique id of this ad. | 0.1.0 |
adUnitId |
string |
Ad unit id. | 0.1.0 |
adUnitName |
string |
Ad unit name from the dashboard. | 0.1.0 |
adFormat |
string |
Ad format as reported by the SDK. | 0.1.0 |
placementName |
string |
Placement name of the show call, when one was used. | 0.1.0 |
adNetwork |
string |
Name of the mediated network that served the ad. | 0.1.0 |
instanceName |
string |
Mediation instance name. | 0.1.0 |
instanceId |
string |
Mediation instance id. | 0.1.0 |
country |
string |
Country code of the impression. | 0.1.0 |
auctionId |
string |
Auction id. | 0.1.0 |
revenue |
number |
Impression revenue in USD as reported by the SDK (may be absent or 0 before display). | 0.1.0 |
precision |
string |
Revenue precision as reported by the SDK. | 0.1.0 |
ShowOptions
Options for showRewarded() and showInterstitial(): adUnitId (see AdUnitOptions) plus an optional placement.
| Prop | Type | Description | Since |
|---|---|---|---|
placementName |
string |
Optional placement name configured in the LevelPlay dashboard (capping, pacing and reward per placement). Omit it to use the default placement. | 0.1.0 |
IsReadyResult
Result of isReady().
| Prop | Type | Description | Since |
|---|---|---|---|
ready |
boolean |
true when a loaded ad can be shown right now. |
0.1.0 |
IsReadyOptions
Options for isReady(): adUnitId (see AdUnitOptions) plus the format.
| Prop | Type | Description | Since |
|---|---|---|---|
format |
AdFormat |
Format of the ad unit. | 0.1.0 |
PluginListenerHandle
| Prop | Type |
|---|---|
remove |
() => Promise<void> |
AdEvent
Payload of the loaded, displayed, clicked and closed events.
| Prop | Type | Description | Since |
|---|---|---|---|
format |
AdFormat |
Format of the ad unit that fired the event. | 0.1.0 |
adUnitId |
string |
Ad unit that fired the event. | 0.1.0 |
adInfo |
AdInfo |
Ad info, when the SDK provides it (not on loadFailed). |
0.1.0 |
AdErrorEvent
Payload of the loadFailed and displayFailed events: the AdEvent fields plus error.
| Prop | Type | Description | Since |
|---|---|---|---|
error |
AdError |
What went wrong. | 0.1.0 |
AdRewardEvent
Payload of the rewarded event: the AdEvent fields plus reward.
| Prop | Type | Description | Since |
|---|---|---|---|
reward |
Reward |
The reward earned. | 0.1.0 |
Type Aliases
TrackingStatus
iOS App Tracking Transparency status. unavailable on Android, on the web and on unknown future iOS values.
'authorized' | 'denied' | 'restricted' | 'notDetermined' | 'unavailable'
AdFormat
Full-screen ad formats supported by this plugin. Banners and native ads are intentionally not exposed.
'rewarded' | 'interstitial'
Contributing
Issues and pull requests are welcome on the issue tracker. See CONTRIBUTING.md.
bun install
bun run build # docgen + dist/ (esm, cjs, iife)
bun run typecheck
bun run verify:ios # xcodebuild the Swift package for the iOS simulator
bun run verify:android # Gradle build of the Android library (JDK 21, Android SDK)
Release notes: CHANGELOG.md.
License
The Unity LevelPlay SDK and the mediated network SDKs are proprietary and governed by their owners' terms. This plugin only declares them as dependencies and does not redistribute them. LevelPlay, ironSource and Unity are trademarks of Unity Technologies; this project is not affiliated with or endorsed by Unity.