diff --git a/CHANGELOG.md b/CHANGELOG.md index 787e06d..4b65f80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,44 +1,11 @@ # Changelog -All notable changes to this project are documented in this file. -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to -[Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.1.0 (2026-10-09) -## [Unreleased] - -## [0.2.0] - 2026-10-10 - -First public release on npm. No behaviour changes to the native bridges since 0.1.0. - -### Added -- Complete README: compatibility table, iOS (SPM and CocoaPods) and Android setup, usage guide, mediation adapters - (Gradle, Swift packages, local-package workaround for networks without an official Swift package), privacy and - ATT guide, troubleshooting, FAQ. -- API reference generated from the JSDoc in `src/definitions.ts` with `@capacitor/docgen` (`bun run docgen`, also - part of `bun run build`); `dist/docs.json` ships with the package. -- JSDoc with `@since` for every method, option, event and type. -- `verify:android` script and a standalone Gradle setup (`android/settings.gradle`, Gradle wrapper 8.14.3) that builds - the Android library against `@capacitor/android` (dev dependency). -- `CONTRIBUTING.md`. - -### Changed -- `package.json`: description, author (`VOX Games`, https://vox.games), `homepage`, `bugs`, `repository`, keywords, - `engines` (Node 22+, as Capacitor 8), `files` (adds `CHANGELOG.md`). -- Podspec: homepage from `package.json`, source is `https://git.crt.fyi/CRT/capacitor-levelplay.git` at tag - `v`. -- `tsconfig.json`: no explicit `lib` (same defaults for `target: es2017`), so docgen resolves `Promise` types. - -## [0.1.0] - 2026-10-09 - -### Added -- Capacitor 8 plugin for Unity LevelPlay rewarded and interstitial ads (ad-unit API). +- First release: Capacitor 8 plugin for Unity LevelPlay rewarded and interstitial ads (ad-unit API). - iOS: Swift Package Manager with the official LevelPlay-Swift-Package (SDK 9.6.1); podspec on `IronSourceSDK ~> 9.6.1`. - Android: `com.unity3d.ads-mediation:mediation-sdk:9.6.1` from Maven Central, Play services ids, consumer ProGuard rules. - API: `initialize`, `setConsent` (GDPR / CCPA / COPPA), `setMetaData`, iOS ATT, load / show / isReady per ad unit, `launchTestSuite`, `validateIntegration`, events `loaded` `loadFailed` `displayed` `displayFailed` `clicked` `closed` `rewarded`. Show calls resolve after close with `{ shown, rewarded, reward?, error? }`. - `LEVELPLAY_DEMO`: Unity's public demo app keys and ad unit ids. - -[Unreleased]: https://git.crt.fyi/CRT/capacitor-levelplay/compare/v0.2.0...main -[0.2.0]: https://git.crt.fyi/CRT/capacitor-levelplay/compare/v0.1.0...v0.2.0 -[0.1.0]: https://git.crt.fyi/CRT/capacitor-levelplay/releases/tag/v0.1.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index c5835bc..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,30 +0,0 @@ -# Contributing - -Thanks for helping. Bug reports, questions and feature requests go to the -[issue tracker](https://git.crt.fyi/CRT/capacitor-levelplay/issues). For a bug, include the plugin version, the -LevelPlay SDK and adapter versions, the platform and OS version, and the native log (Xcode console or -`adb logcat | grep -E "LevelPlay|IronSource|IntegrationHelper"`). - -## Development - -Requirements: [Bun](https://bun.sh), Xcode 26+ for iOS, JDK 21 and the Android SDK for Android. - -```sh -bun install -bun run build # docgen (README API section) + dist/ -bun run typecheck -bun run verify:ios # xcodebuild the Swift package (iOS simulator) -JAVA_HOME=$(/usr/libexec/java_home -v 21) bun run verify:android -``` - -- The public API lives in `src/definitions.ts`. Document every method, option and event with JSDoc (`@since`), then - run `bun run build` so the API section of `README.md` is regenerated. Do not edit between the `docgen` markers by hand. -- Keep the Android (`android/src/main/java/...`) and iOS (`ios/Sources/...`) bridges in step: same method names, same - result and event shapes. -- `dist/` is committed so the package can be installed from git; rebuild it in the same commit as source changes. -- Add an entry under `Unreleased` in `CHANGELOG.md`. - -## Pull requests - -Keep them focused, describe what changed and how you tested it (device or simulator, OS version, network). By -contributing you agree that your work is released under the [MIT License](LICENSE). diff --git a/CapacitorLevelplay.podspec b/CapacitorLevelplay.podspec index e285827..cad99e2 100644 --- a/CapacitorLevelplay.podspec +++ b/CapacitorLevelplay.podspec @@ -1,21 +1,18 @@ require 'json' package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) -repo = 'https://git.crt.fyi/CRT/capacitor-levelplay' Pod::Spec.new do |s| s.name = 'CapacitorLevelplay' s.version = package['version'] - s.summary = 'Capacitor plugin for Unity LevelPlay rewarded and interstitial ads.' - s.description = package['description'] + s.summary = package['description'] s.license = package['license'] - s.homepage = package['homepage'] - s.author = package['author']['name'] - s.source = { :git => "#{repo}.git", :tag => "v#{s.version}" } + s.homepage = package['repository']['url'] + s.author = package['author'] + s.source = { :git => package['repository']['url'], :tag => 'v' + package['version'] } s.source_files = 'ios/Sources/**/*.{swift,h,m}' s.ios.deployment_target = '15.0' s.dependency 'Capacitor' - # Unity LevelPlay SDK (ironSource), https://cocoapods.org/pods/IronSourceSDK s.dependency 'IronSourceSDK', '~> 9.6.1' s.frameworks = 'AppTrackingTransparency' s.swift_version = '5.9' diff --git a/README.md b/README.md index 56685d6..c27e698 100644 --- a/README.md +++ b/README.md @@ -1,131 +1,49 @@ # capacitor-levelplay -[![npm version](https://img.shields.io/npm/v/capacitor-levelplay.svg)](https://www.npmjs.com/package/capacitor-levelplay) -[![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) -[![Capacitor 8](https://img.shields.io/badge/Capacitor-8-119eff.svg)](https://capacitorjs.com) -[![LevelPlay SDK 9.6.1](https://img.shields.io/badge/LevelPlay%20SDK-9.6.1-222.svg)](https://docs.unity.com/en-us/grow/levelplay) - Capacitor 8 plugin for [Unity LevelPlay](https://docs.unity.com/en-us/grow/levelplay) (formerly ironSource) mediation: -**rewarded** and **interstitial** ads on Android and iOS, built on LevelPlay's current **ad-unit API** +**rewarded** and **interstitial** ads on Android and iOS, using LevelPlay's current ad-unit API (`LevelPlay.init`, `LevelPlayRewardedAd` / `LPMRewardedAd`, `LevelPlayInterstitialAd` / `LPMInterstitialAd`). +No banners, no native ads. -```ts -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](#features) -- [Compatibility](#compatibility) -- [Install](#install) -- [iOS setup](#ios-setup) -- [Android setup](#android-setup) -- [Quick start](#quick-start) -- [Usage guide](#usage-guide) -- [Mediation adapters](#mediation-adapters) -- [Privacy and consent](#privacy-and-consent) -- [Troubleshooting](#troubleshooting) -- [FAQ](#faq) -- [API reference](#api) -- [Contributing](#contributing) -- [License](#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` / `showInterstitial` resolve 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.swift` depends on Unity's official - [LevelPlay-Swift-Package](https://github.com/ironsource-mobile/LevelPlay-Swift-Package), so `npx cap sync` on 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) | +| Capacitor | 8 | +| LevelPlay SDK | Android `com.unity3d.ads-mediation:mediation-sdk:9.6.1` (Maven Central) ยท iOS `9.6.1` via the official [LevelPlay-Swift-Package](https://github.com/ironsource-mobile/LevelPlay-Swift-Package) (`IronSourceSDK` pod for CocoaPods) | +| iOS | 15+, Swift Package Manager first (the plugin's `Package.swift` really pulls the SDK); a podspec is included for CocoaPods projects | +| Android | minSdk 24, Java 21 | -| Plugin | Capacitor | LevelPlay SDK | -|---|---|---| -| 0.2.x | 8 | 9.6.1 | -| 0.1.x | 8 | 9.6.1 | +Why another LevelPlay plugin: the existing `capacitor-levelplay-ads` package targets CocoaPods first and its +`Package.swift` does not depend on the LevelPlay SDK; this one is SPM-first, pulls the SDK under SPM, and exposes only +the ad-unit API. ## Install ```sh -npm install capacitor-levelplay +npm install capacitor-levelplay # or: bun add capacitor-levelplay npx cap sync ``` -```sh -bun add capacitor-levelplay && bunx cap sync -yarn add capacitor-levelplay && yarn cap sync -pnpm add capacitor-levelplay && pnpm cap sync -``` +### iOS setup -## 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 -(`IronSourceAdapter`) in the app's `Podfile`. - -### `-ObjC` linker flag - -LevelPlay requires it: App target > **Build Settings** > **Linking** > **Other Linker Flags** > add `-ObjC`. - -### Info.plist +1. **`-ObjC` linker flag** (required by LevelPlay): App target > Build Settings > *Other Linker Flags* > add `-ObjC`. +2. **Info.plist**: ```xml - -NSUserTrackingUsageDescription -Your data will be used to deliver ads that are more relevant to you. - - + SKAdNetworkItems SKAdNetworkIdentifier su67r6k2v3.skadnetwork - - - + +NSUserTrackingUsageDescription +Your data will be used to deliver ads that are more relevant to you. + NSAdvertisingAttributionReportEndpoint https://postbacks-is.com/ - NSAppTransportSecurity @@ -134,32 +52,17 @@ LevelPlay requires it: App target > **Build Settings** > **Linking** > **Other L ``` -**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](https://docs.unity.com/en-us/grow/levelplay/sdk/ios/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. +With SPM, `npx cap sync` adds the plugin to `CapApp-SPM/Package.swift`; Xcode resolves the LevelPlay package +(binary xcframework, about 27 MB download) on the next build. -Full checklist: Unity's [iOS SDK integration](https://docs.unity.com/en-us/grow/levelplay/sdk/ios/sdk-integration) guide. +### Android setup -## Android setup +Nothing beyond `npx cap sync`: the plugin module declares `mediation-sdk` (Maven Central) plus the Play services +`ads-identifier`, `appset` and `basement` artifacts, and the SDK's manifest brings its activities, providers and the +`INTERNET` / `ACCESS_NETWORK_STATE` permissions. The plugin adds `com.google.android.gms.permission.AD_ID` +(remove it with `tools:node="remove"` in a child-directed app). -Nothing beyond `npx cap sync` for most apps: - -- **Repositories**: the SDK and all LevelPlay adapters are on Maven Central. Capacitor's default - `android/build.gradle` already lists `google()` and `mavenCentral()`; 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 brings `INTERNET`, `ACCESS_NETWORK_STATE`, its activities and providers. A - child-directed app can strip `AD_ID` from its manifest with `tools:node="remove"`. -- **Dependencies**: the plugin module declares `mediation-sdk` plus the Play services `ads-identifier`, `appset` and - `basement` artifacts 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](https://docs.unity.com/en-us/grow/levelplay/sdk/android/sdk-integration) guide for each - adapter you add. - -Optional: pin a different 9.x SDK from the app's `android/variables.gradle`: +Optional overrides in the app's `android/variables.gradle`: ```gradle ext { @@ -167,163 +70,40 @@ ext { } ``` -Gradle in Capacitor 8 projects needs **JDK 21** (see [Troubleshooting](#android-build-fails-with-unsupported-class-file-major-version)). +Mediation adapters (Unity Ads, AdMob, AppLovin, ...) go into the app module, e.g. +`implementation 'com.unity3d.ads-mediation:unityads-adapter:5.+'`; see Unity's +[mediation networks](https://docs.unity.com/en-us/grow/levelplay/sdk/android/mediation-networks) page. +If you minify, the core keep rules ship as consumer ProGuard rules; add the per-network rules yourself. -## Quick start +## Usage ```ts -import { Capacitor } from '@capacitor/core'; import { LevelPlay, LEVELPLAY_DEMO } from 'capacitor-levelplay'; +import { Capacitor } from '@capacitor/core'; -// 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 { - 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 }); -} +await LevelPlay.requestTrackingAuthorization(); // iOS ATT prompt; no-op elsewhere +await LevelPlay.setConsent({ gdprConsent: true, ccpaDoNotSell: false }); // from your CMP +await LevelPlay.initialize({ appKey: ids.appKey }); -export async function watchVideoForCoins(): Promise { - 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; +await LevelPlay.addListener('loaded', (e) => console.log('loaded', e.format, e.adUnitId)); +await LevelPlay.loadRewarded({ adUnitId: ids.rewarded }); + +// later, when the user taps "watch video": +const { ready } = await LevelPlay.isReady({ format: 'rewarded', adUnitId: ids.rewarded }); +if (ready) { + const r = await LevelPlay.showRewarded({ adUnitId: ids.rewarded }); + if (r.rewarded) grantReward(r.reward); + await LevelPlay.loadRewarded({ adUnitId: ids.rewarded }); // preload the next one } ``` -## 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. - -```ts -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 - -```ts -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 `rewarded` is `true`. 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' } }`. -- `placementName` is optional and refers to a placement configured in the LevelPlay dashboard (capping, pacing, reward). -- For server-side rewards, pass `userId` to `initialize` and configure server-to-server callbacks in the dashboard. - -### Interstitial ads - -```ts -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. - -```ts -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](https://docs.unity.com/en-us/grow/levelplay/sdk/android/integration-test-suite) shows every -configured network, its adapter status and lets you request test ads per network. - -```ts -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 - -```ts -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: - -```ts -await LevelPlay.setMetaData({ key: 'is_deviceid_optout', value: 'true' }); -``` +`showRewarded` / `showInterstitial` resolve **after the ad closes** (or failed to display) with +`{ shown, rewarded, reward?, error?, adInfo? }`. They never reject because an ad is not ready; they resolve +`{ shown: false, error: { code: -1, message: 'Ad not ready' } }`. Reward and close callbacks can arrive in either order +on some networks; the plugin waits up to 1 s after the close for a late reward before resolving. Grant rewards only +when `rewarded` is `true` (or on the `rewarded` event). ### Demo ids @@ -331,841 +111,60 @@ await LevelPlay.setMetaData({ key: 'is_deviceid_optout', value: 'true' }); ([Mediation-Demo-Apps](https://github.com/ironsource-mobile/Mediation-Demo-Apps)). They serve test ads; never ship them. -| Platform | App key | Rewarded | Interstitial | +| 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](https://docs.unity.com/en-us/grow/levelplay/sdk/android/mediation-networks), -[iOS](https://docs.unity.com/en-us/grow/levelplay/sdk/ios/mediation-networks)) 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:-adapter:`. Add each adapter and the -network SDK to `android/app/build.gradle`: - -```gradle -dependencies { - // Unity Ads - implementation 'com.unity3d.ads-mediation:unityads-adapter:' - implementation 'com.unity3d.ads:unity-ads:' - // Liftoff Monetize (Vungle) - implementation 'com.unity3d.ads-mediation:vungle-adapter:' - implementation 'com.vungle:vungle-ads:' -} -``` - -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--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: - -1. Use CocoaPods for the project and add the `IronSourceAdapter` pod. -2. Keep SPM and wrap the adapter in a small **local Swift package** that mirrors the official packages: a - `binaryTarget` pointing at the adapter zip Unity publishes for CocoaPods (the URL is in the adapter's podspec, pin its - SHA-256 with `swift package compute-checksum`), a dependency on the network's own Swift package at the version the - adapter supports, a dependency on `LevelPlay-Swift-Package` 9.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 - // 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//SDK-Swift-Package.git", exact: ""), - .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: "", package: "SDK-Swift-Package"), - .product(name: "UnityMediationSDK", package: "LevelPlay-Swift-Package"), - ]), - .binaryTarget( - name: "ExampleAdapterBinary", - url: "", - checksum: ""), - ] - ) - ``` - - Add any system libraries the network's manual-integration guide lists as `linkerSettings`. - -After adding networks: update `SKAdNetworkItems` ([iOS setup](#infoplist)), 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](https://docs.unity.com/en-us/grow/levelplay/sdk/ios/regulation-advanced-settings). - -- **GDPR (EEA, UK, Switzerland)**: pass `gdprConsent: false` until a consent management platform (CMP) collected - consent, then `true` or `false` according 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: true` when the user opted out of the sale or sharing of personal - data. -- **COPPA**: `coppa: true` for users who must get child-directed treatment. Child-directed apps should also strip the - `AD_ID` permission 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: - -1. Add `NSUserTrackingUsageDescription` to `Info.plist`. -2. Call `requestTrackingAuthorization()` **when the app is active** (iOS ignores the request while the app is still - launching or in the background) and **before** `initialize`. Show your CMP first if you have one. -3. iOS shows the system prompt only once; later calls resolve the stored status. Use - `getTrackingAuthorizationStatus()` to read it without prompting. +### Integration Test Suite ```ts -const { status } = await LevelPlay.getTrackingAuthorizationStatus(); -if (status === 'notDetermined') await LevelPlay.requestTrackingAuthorization(); -await LevelPlay.initialize({ appKey }); +await LevelPlay.initialize({ appKey, testSuite: true }); // sets is_test_suite=enable before init +await LevelPlay.launchTestSuite(); ``` -## Troubleshooting +Development builds only. The suite is portrait only. -### 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](https://docs.unity.com/en-us/grow/levelplay/sdk/ios/troubleshoot-no-ads-displaying) lists -more causes. +### Privacy -### 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: - -```sh -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 ios` after every install or upgrade of the plugin; it rewrites `CapApp-SPM/Package.swift`. -- In Xcode: **File > Packages > Reset Package Caches**, then **Resolve Package Versions**. -- Still stuck: quit Xcode, delete `~/Library/Developer/Xcode/DerivedData/-*` 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. +`setConsent({ gdprConsent?, ccpaDoNotSell?, coppa? })` maps to `LevelPlayPrivacySettings` (Android) / +`LPMPrivacySettings` (iOS): `setGDPRConsent`, `setCCPA`, `setCOPPA` (SDK 9.5+ APIs). Call it before `initialize` +(or pass `consent` to `initialize`). LevelPlay also reads a Google UMP / IAB TCF CMP's consent string by itself. +Raw meta data flags (for example `is_deviceid_optout`) go through `setMetaData({ key, value })`. ## API - - -* [`initialize(...)`](#initialize) -* [`getSdkVersion()`](#getsdkversion) -* [`setConsent(...)`](#setconsent) -* [`setMetaData(...)`](#setmetadata) -* [`requestTrackingAuthorization()`](#requesttrackingauthorization) -* [`getTrackingAuthorizationStatus()`](#gettrackingauthorizationstatus) -* [`loadRewarded(...)`](#loadrewarded) -* [`showRewarded(...)`](#showrewarded) -* [`loadInterstitial(...)`](#loadinterstitial) -* [`showInterstitial(...)`](#showinterstitial) -* [`isReady(...)`](#isready) -* [`launchTestSuite()`](#launchtestsuite) -* [`validateIntegration()`](#validateintegration) -* [`addListener('loaded', ...)`](#addlistenerloaded-) -* [`addListener('loadFailed', ...)`](#addlistenerloadfailed-) -* [`addListener('displayed', ...)`](#addlistenerdisplayed-) -* [`addListener('displayFailed', ...)`](#addlistenerdisplayfailed-) -* [`addListener('clicked', ...)`](#addlistenerclicked-) -* [`addListener('closed', ...)`](#addlistenerclosed-) -* [`addListener('rewarded', ...)`](#addlistenerrewarded-) -* [`removeAllListeners()`](#removealllisteners) -* [Interfaces](#interfaces) -* [Type Aliases](#type-aliases) - - - - - - -Unity LevelPlay rewarded and interstitial ads (ad-unit API). - -### initialize(...) - -```typescript -initialize(options: InitOptions) => Promise -``` - -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() - -```typescript -getSdkVersion() => Promise -``` - -Native LevelPlay SDK version. Works before init. - -**Returns:** Promise<InitResult> - -**Since:** 0.1.0 - --------------------- - - -### setConsent(...) - -```typescript -setConsent(options: ConsentOptions) => Promise -``` - -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(...) - -```typescript -setMetaData(options: MetaDataOptions) => Promise -``` - -Raw `LevelPlay.setMetaData(key, value)` for SDK or network-specific flags. Call it before init. - -| Param | Type | -| ------------- | ----------------------------------------------------------- | -| **`options`** | MetaDataOptions | - -**Since:** 0.1.0 - --------------------- - - -### requestTrackingAuthorization() - -```typescript -requestTrackingAuthorization() => Promise -``` - -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() - -```typescript -getTrackingAuthorizationStatus() => Promise -``` - -Current App Tracking Transparency status without prompting (iOS). Android and web: `unavailable`. - -**Returns:** Promise<TrackingResult> - -**Since:** 0.1.0 - --------------------- - - -### loadRewarded(...) - -```typescript -loadRewarded(options: AdUnitOptions) => Promise -``` - -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(...) - -```typescript -showRewarded(options: ShowOptions) => Promise -``` - -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(...) - -```typescript -loadInterstitial(options: AdUnitOptions) => Promise -``` - -Start loading an interstitial ad for the ad unit. Works like `loadRewarded()`. - -| Param | Type | -| ------------- | ------------------------------------------------------- | -| **`options`** | AdUnitOptions | - -**Since:** 0.1.0 - --------------------- - - -### showInterstitial(...) - -```typescript -showInterstitial(options: ShowOptions) => Promise -``` - -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(...) - -```typescript -isReady(options: IsReadyOptions) => Promise -``` - -`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() - -```typescript -launchTestSuite() => Promise -``` - -Open the LevelPlay Integration Test Suite. Requires `initialize({ testSuite: true })` first. -Development builds only. Rejects on the web. - -**Since:** 0.1.0 - --------------------- - - -### validateIntegration() - -```typescript -validateIntegration() => Promise -``` - -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', ...) - -```typescript -addListener(eventName: 'loaded', listenerFunc: (event: AdEvent) => void) => Promise -``` - -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', ...) - -```typescript -addListener(eventName: 'loadFailed', listenerFunc: (event: AdErrorEvent) => void) => Promise -``` - -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', ...) - -```typescript -addListener(eventName: 'displayed', listenerFunc: (event: AdEvent) => void) => Promise -``` - -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', ...) - -```typescript -addListener(eventName: 'displayFailed', listenerFunc: (event: AdErrorEvent) => void) => Promise -``` - -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', ...) - -```typescript -addListener(eventName: 'clicked', listenerFunc: (event: AdEvent) => void) => Promise -``` - -The user clicked the ad. - -| Param | Type | -| ------------------ | --------------------------------------------------------------- | -| **`eventName`** | 'clicked' | -| **`listenerFunc`** | (event: AdEvent) => void | - -**Returns:** Promise<PluginListenerHandle> - -**Since:** 0.1.0 - --------------------- - - -### addListener('closed', ...) - -```typescript -addListener(eventName: 'closed', listenerFunc: (event: AdEvent) => void) => Promise -``` - -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', ...) - -```typescript -addListener(eventName: 'rewarded', listenerFunc: (event: AdRewardEvent) => void) => Promise -``` - -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() - -```typescript -removeAllListeners() => Promise -``` - -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](https://git.crt.fyi/CRT/capacitor-levelplay/issues). See -[CONTRIBUTING.md](CONTRIBUTING.md). +| method | description | +|---|---| +| `initialize({ appKey, userId?, testSuite?, adaptersDebug?, consent? })` | `LevelPlay.init`; resolves `{ sdkVersion }` on success, rejects with the init error. Idempotent. | +| `getSdkVersion()` | `{ sdkVersion }` | +| `setConsent({ gdprConsent?, ccpaDoNotSell?, coppa? })` | privacy signals | +| `setMetaData({ key, value })` | `LevelPlay.setMetaData` | +| `requestTrackingAuthorization()` / `getTrackingAuthorizationStatus()` | iOS ATT, `{ status }`; `unavailable` on Android / web | +| `loadRewarded({ adUnitId })` / `loadInterstitial({ adUnitId })` | start a load; outcome via `loaded` / `loadFailed` | +| `showRewarded({ adUnitId, placementName? })` / `showInterstitial(...)` | show; resolves after close with the result | +| `isReady({ format, adUnitId })` | `{ ready }` | +| `launchTestSuite()` | LevelPlay Integration Test Suite | +| `validateIntegration()` | integration helper report in the native log | + +Events (`addListener`): `loaded`, `loadFailed`, `displayed`, `displayFailed`, `clicked`, `closed`, `rewarded`. +Every event carries `{ format: 'rewarded' | 'interstitial', adUnitId, adInfo? }`, plus `error` (failures) or `reward`. +Full types with JSDoc: [`src/definitions.ts`](src/definitions.ts). + +On the web the plugin is a stub: `initialize` rejects as unimplemented, nothing is ever ready and shows resolve +`{ shown: false }`. + +## Development ```sh 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) +bun run build # dist/ (esm + cjs + iife) +bun run verify:ios # xcodebuild the Swift package ``` -Release notes: [CHANGELOG.md](CHANGELOG.md). +`dist/` is committed so the package can be installed straight from git. ## License -[MIT](LICENSE) ยฉ [VOX Games](https://vox.games) - -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. +MIT (see [LICENSE](LICENSE)). The Unity LevelPlay SDK itself is proprietary and governed by Unity's terms; this +plugin only declares it as a dependency and does not redistribute it. diff --git a/android/gradle.properties b/android/gradle.properties deleted file mode 100644 index 23192e2..0000000 --- a/android/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -# Standalone build of the plugin library (`bun run verify:android`). Not used by consuming apps. -org.gradle.jvmargs=-Xmx1536m -android.useAndroidX=true diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 1b33c55..0000000 Binary files a/android/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 7705927..0000000 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/android/gradlew b/android/gradlew deleted file mode 100755 index 23d15a9..0000000 --- a/android/gradlew +++ /dev/null @@ -1,251 +0,0 @@ -#!/bin/sh - -# -# Copyright ยฉ 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions ยซ$varยป, ยซ${var}ยป, ยซ${var:-default}ยป, ยซ${var+SET}ยป, -# ยซ${var#prefix}ยป, ยซ${var%suffix}ยป, and ยซ$( cmd )ยป; -# * compound commands having a testable exit status, especially ยซcaseยป; -# * various built-in commands including ยซcommandยป, ยซsetยป, and ยซulimitยป. -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH="\\\"\\\"" - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, -# and any embedded shellness will be escaped. -# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be -# treated as '${Hostname}' itself on the command line. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/android/gradlew.bat b/android/gradlew.bat deleted file mode 100644 index 5eed7ee..0000000 --- a/android/gradlew.bat +++ /dev/null @@ -1,94 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem -@rem SPDX-License-Identifier: Apache-2.0 -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH= - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/android/settings.gradle b/android/settings.gradle deleted file mode 100644 index 1c79088..0000000 --- a/android/settings.gradle +++ /dev/null @@ -1,4 +0,0 @@ -// Standalone build of the plugin library, used by `bun run verify:android` (needs `bun install` first). -// Consuming apps do not use this file: `npx cap sync` includes the module from their own settings. -include ':capacitor-android' -project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor') diff --git a/dist/docs.json b/dist/docs.json deleted file mode 100644 index 8ab1068..0000000 --- a/dist/docs.json +++ /dev/null @@ -1,1323 +0,0 @@ -{ - "api": { - "name": "LevelPlayPlugin", - "slug": "levelplayplugin", - "docs": "Unity LevelPlay rewarded and interstitial ads (ad-unit API).", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "methods": [ - { - "name": "initialize", - "signature": "(options: InitOptions) => Promise", - "parameters": [ - { - "name": "options", - "docs": "", - "type": "InitOptions" - } - ], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "Initialise the LevelPlay SDK (`LevelPlay.init`). Resolves on init success, rejects with the init error\n(code and message from the SDK) otherwise. Calling it again after a successful init resolves immediately;\nconcurrent calls share one init. Load ads only after this resolves.\n\nSet consent (and on iOS ask for ATT) before calling it.\n\nOn the web it rejects as unimplemented.", - "complexTypes": [ - "InitResult", - "InitOptions" - ], - "slug": "initialize" - }, - { - "name": "getSdkVersion", - "signature": "() => Promise", - "parameters": [], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "Native LevelPlay SDK version. Works before init.", - "complexTypes": [ - "InitResult" - ], - "slug": "getsdkversion" - }, - { - "name": "setConsent", - "signature": "(options: ConsentOptions) => Promise", - "parameters": [ - { - "name": "options", - "docs": "", - "type": "ConsentOptions" - } - ], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "Forward GDPR / CCPA / COPPA signals to LevelPlay. Call it before `initialize()` when you\ncan, and again whenever the user changes their choice.", - "complexTypes": [ - "ConsentOptions" - ], - "slug": "setconsent" - }, - { - "name": "setMetaData", - "signature": "(options: MetaDataOptions) => Promise", - "parameters": [ - { - "name": "options", - "docs": "", - "type": "MetaDataOptions" - } - ], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "Raw `LevelPlay.setMetaData(key, value)` for SDK or network-specific flags. Call it before init.", - "complexTypes": [ - "MetaDataOptions" - ], - "slug": "setmetadata" - }, - { - "name": "requestTrackingAuthorization", - "signature": "() => Promise", - "parameters": [], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "iOS: show the App Tracking Transparency prompt and resolve with the resulting status. Needs\n`NSUserTrackingUsageDescription` in `Info.plist`. iOS only shows the prompt once; later calls resolve the stored\nstatus. Call it before `initialize()`, while the app is active.\n\nAndroid and web: resolves `unavailable`.", - "complexTypes": [ - "TrackingResult" - ], - "slug": "requesttrackingauthorization" - }, - { - "name": "getTrackingAuthorizationStatus", - "signature": "() => Promise", - "parameters": [], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "Current App Tracking Transparency status without prompting (iOS). Android and web: `unavailable`.", - "complexTypes": [ - "TrackingResult" - ], - "slug": "gettrackingauthorizationstatus" - }, - { - "name": "loadRewarded", - "signature": "(options: AdUnitOptions) => Promise", - "parameters": [ - { - "name": "options", - "docs": "", - "type": "AdUnitOptions" - } - ], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "Start loading a rewarded ad for the ad unit. The native ad object is created on first use and reused for the\nad unit. Resolves once the request is issued; the outcome arrives as a `loaded` or `loadFailed` event.\nLoad the next ad after each show.", - "complexTypes": [ - "AdUnitOptions" - ], - "slug": "loadrewarded" - }, - { - "name": "showRewarded", - "signature": "(options: ShowOptions) => Promise", - "parameters": [ - { - "name": "options", - "docs": "", - "type": "ShowOptions" - } - ], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "Show a loaded rewarded ad. Resolves after the ad closed (or failed to display) with what happened. The reward\nand close callbacks can arrive in either order on some networks, so the plugin waits up to 1 second after the close\nfor a late reward. Never rejects for \"not ready\": resolves `{ shown: false, rewarded: false, error }` instead.", - "complexTypes": [ - "ShowResult", - "ShowOptions" - ], - "slug": "showrewarded" - }, - { - "name": "loadInterstitial", - "signature": "(options: AdUnitOptions) => Promise", - "parameters": [ - { - "name": "options", - "docs": "", - "type": "AdUnitOptions" - } - ], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "Start loading an interstitial ad for the ad unit. Works like `loadRewarded()`.", - "complexTypes": [ - "AdUnitOptions" - ], - "slug": "loadinterstitial" - }, - { - "name": "showInterstitial", - "signature": "(options: ShowOptions) => Promise", - "parameters": [ - { - "name": "options", - "docs": "", - "type": "ShowOptions" - } - ], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "Show a loaded interstitial. Resolves after it closed (or failed to display). Never rejects for \"not ready\".", - "complexTypes": [ - "ShowResult", - "ShowOptions" - ], - "slug": "showinterstitial" - }, - { - "name": "isReady", - "signature": "(options: IsReadyOptions) => Promise", - "parameters": [ - { - "name": "options", - "docs": "", - "type": "IsReadyOptions" - } - ], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "`isAdReady()` of the native ad object for this ad unit. `false` when the ad unit was never loaded.", - "complexTypes": [ - "IsReadyResult", - "IsReadyOptions" - ], - "slug": "isready" - }, - { - "name": "launchTestSuite", - "signature": "() => Promise", - "parameters": [], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "Open the LevelPlay Integration Test Suite. Requires `initialize({ testSuite: true })` first.\nDevelopment builds only. Rejects on the web.", - "complexTypes": [], - "slug": "launchtestsuite" - }, - { - "name": "validateIntegration", - "signature": "() => Promise", - "parameters": [], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "Write the LevelPlay integration helper report to the native log (Xcode console; Android logcat tag\n`IntegrationHelper`): SDK, adapter and network SDK versions, each `VERIFIED` or not. Development only.", - "complexTypes": [], - "slug": "validateintegration" - }, - { - "name": "addListener", - "signature": "(eventName: 'loaded', listenerFunc: (event: AdEvent) => void) => Promise", - "parameters": [ - { - "name": "eventName", - "docs": "", - "type": "'loaded'" - }, - { - "name": "listenerFunc", - "docs": "", - "type": "(event: AdEvent) => void" - } - ], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "An ad finished loading for the ad unit and can be shown.", - "complexTypes": [ - "PluginListenerHandle", - "AdEvent" - ], - "slug": "addlistenerloaded-" - }, - { - "name": "addListener", - "signature": "(eventName: 'loadFailed', listenerFunc: (event: AdErrorEvent) => void) => Promise", - "parameters": [ - { - "name": "eventName", - "docs": "", - "type": "'loadFailed'" - }, - { - "name": "listenerFunc", - "docs": "", - "type": "(event: AdErrorEvent) => void" - } - ], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "Loading failed, for example `509` (no fill). Retry later with a backoff.", - "complexTypes": [ - "PluginListenerHandle", - "AdErrorEvent" - ], - "slug": "addlistenerloadfailed-" - }, - { - "name": "addListener", - "signature": "(eventName: 'displayed', listenerFunc: (event: AdEvent) => void) => Promise", - "parameters": [ - { - "name": "eventName", - "docs": "", - "type": "'displayed'" - }, - { - "name": "listenerFunc", - "docs": "", - "type": "(event: AdEvent) => void" - } - ], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "The ad was displayed (impression). `adInfo.revenue` is available here.", - "complexTypes": [ - "PluginListenerHandle", - "AdEvent" - ], - "slug": "addlistenerdisplayed-" - }, - { - "name": "addListener", - "signature": "(eventName: 'displayFailed', listenerFunc: (event: AdErrorEvent) => void) => Promise", - "parameters": [ - { - "name": "eventName", - "docs": "", - "type": "'displayFailed'" - }, - { - "name": "listenerFunc", - "docs": "", - "type": "(event: AdErrorEvent) => void" - } - ], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "The ad failed to display. The pending show call resolves with the same error.", - "complexTypes": [ - "PluginListenerHandle", - "AdErrorEvent" - ], - "slug": "addlistenerdisplayfailed-" - }, - { - "name": "addListener", - "signature": "(eventName: 'clicked', listenerFunc: (event: AdEvent) => void) => Promise", - "parameters": [ - { - "name": "eventName", - "docs": "", - "type": "'clicked'" - }, - { - "name": "listenerFunc", - "docs": "", - "type": "(event: AdEvent) => void" - } - ], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "The user clicked the ad.", - "complexTypes": [ - "PluginListenerHandle", - "AdEvent" - ], - "slug": "addlistenerclicked-" - }, - { - "name": "addListener", - "signature": "(eventName: 'closed', listenerFunc: (event: AdEvent) => void) => Promise", - "parameters": [ - { - "name": "eventName", - "docs": "", - "type": "'closed'" - }, - { - "name": "listenerFunc", - "docs": "", - "type": "(event: AdEvent) => void" - } - ], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "The ad was closed and the app is back in front.", - "complexTypes": [ - "PluginListenerHandle", - "AdEvent" - ], - "slug": "addlistenerclosed-" - }, - { - "name": "addListener", - "signature": "(eventName: 'rewarded', listenerFunc: (event: AdRewardEvent) => void) => Promise", - "parameters": [ - { - "name": "eventName", - "docs": "", - "type": "'rewarded'" - }, - { - "name": "listenerFunc", - "docs": "", - "type": "(event: AdRewardEvent) => void" - } - ], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "Rewarded only: the user earned the reward. Can fire before or after `closed`.", - "complexTypes": [ - "PluginListenerHandle", - "AdRewardEvent" - ], - "slug": "addlistenerrewarded-" - }, - { - "name": "removeAllListeners", - "signature": "() => Promise", - "parameters": [], - "returns": "Promise", - "tags": [ - { - "name": "since", - "text": "0.1.0" - } - ], - "docs": "Remove every listener of this plugin.", - "complexTypes": [], - "slug": "removealllisteners" - } - ], - "properties": [] - }, - "interfaces": [ - { - "name": "InitResult", - "slug": "initresult", - "docs": "Result of `initialize()` and `getSdkVersion()`.", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "methods": [], - "properties": [ - { - "name": "sdkVersion", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Native LevelPlay SDK version, for example `9.6.1`. `web` on the web.", - "complexTypes": [], - "type": "string" - } - ] - }, - { - "name": "InitOptions", - "slug": "initoptions", - "docs": "Options for `initialize()`.", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "methods": [], - "properties": [ - { - "name": "appKey", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "LevelPlay app key from the LevelPlay dashboard. Android and iOS apps have different keys.", - "complexTypes": [], - "type": "string" - }, - { - "name": "userId", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Optional user id. Needed for server-to-server reward callbacks and the Ad Quality user journey.", - "complexTypes": [], - "type": "string | undefined" - }, - { - "name": "testSuite", - "tags": [ - { - "text": "false", - "name": "default" - }, - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Enable the LevelPlay Integration Test Suite: sets the `is_test_suite=enable` meta data before init.\nCall `launchTestSuite()` after `initialize` resolves. Never ship this enabled.", - "complexTypes": [], - "type": "boolean | undefined" - }, - { - "name": "adaptersDebug", - "tags": [ - { - "text": "false", - "name": "default" - }, - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Turn on debug logs of the mediated ad network adapters (`LevelPlay.setAdaptersDebug(true)`). Development only.", - "complexTypes": [], - "type": "boolean | undefined" - }, - { - "name": "consent", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Privacy signals applied right before init (LevelPlay recommends setting them before the SDK starts).\nSame as calling `setConsent()` first.", - "complexTypes": [ - "ConsentOptions" - ], - "type": "ConsentOptions" - } - ] - }, - { - "name": "ConsentOptions", - "slug": "consentoptions", - "docs": "Privacy signals forwarded to LevelPlay (`LevelPlayPrivacySettings` on Android, `LPMPrivacySettings` on iOS).\nOmitted fields are left untouched.", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "methods": [], - "properties": [ - { - "name": "gdprConsent", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "GDPR: `true` when the user consented to personalised ads and data processing, `false` when they did not.\nFor users in the EEA, UK and Switzerland pass `false` until a consent management platform (CMP) says otherwise.", - "complexTypes": [], - "type": "boolean | undefined" - }, - { - "name": "ccpaDoNotSell", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "CCPA and other US state privacy laws: `true` when the user opted OUT of the sale or sharing of personal data\n(\"do not sell\"), `false` otherwise.", - "complexTypes": [], - "type": "boolean | undefined" - }, - { - "name": "coppa", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "COPPA: `true` when the user must be treated as a child (child-directed treatment).", - "complexTypes": [], - "type": "boolean | undefined" - } - ] - }, - { - "name": "MetaDataOptions", - "slug": "metadataoptions", - "docs": "Options for `setMetaData()`.", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "methods": [], - "properties": [ - { - "name": "key", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Meta data key, for example `is_deviceid_optout` or a network-specific flag from Unity's docs.", - "complexTypes": [], - "type": "string" - }, - { - "name": "value", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Meta data value, always a string (for example `\"true\"`).", - "complexTypes": [], - "type": "string" - } - ] - }, - { - "name": "TrackingResult", - "slug": "trackingresult", - "docs": "Result of `requestTrackingAuthorization()` and\n`getTrackingAuthorizationStatus()`.", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "methods": [], - "properties": [ - { - "name": "status", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "iOS App Tracking Transparency status. Always `unavailable` on Android and web.", - "complexTypes": [ - "TrackingStatus" - ], - "type": "TrackingStatus" - } - ] - }, - { - "name": "AdUnitOptions", - "slug": "adunitoptions", - "docs": "Identifies one ad unit.", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "methods": [], - "properties": [ - { - "name": "adUnitId", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Ad unit id from the LevelPlay dashboard (Ad units page). Android and iOS ad units have different ids.", - "complexTypes": [], - "type": "string" - } - ] - }, - { - "name": "ShowResult", - "slug": "showresult", - "docs": "Result of `showRewarded()` and `showInterstitial()`, resolved after the ad\nclosed or failed to display.", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "methods": [], - "properties": [ - { - "name": "shown", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "The ad was displayed (the `displayed` event fired).", - "complexTypes": [], - "type": "boolean" - }, - { - "name": "rewarded", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Rewarded only: the reward callback fired for this show. Grant the reward only when this is `true`.\nAlways `false` for interstitials.", - "complexTypes": [], - "type": "boolean" - }, - { - "name": "reward", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "The reward, present when `rewarded` is `true`.", - "complexTypes": [ - "Reward" - ], - "type": "Reward" - }, - { - "name": "error", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Present when the ad was not ready (`code: -1`) or failed to display.", - "complexTypes": [ - "AdError" - ], - "type": "AdError" - }, - { - "name": "adInfo", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Info of the displayed ad.", - "complexTypes": [ - "AdInfo" - ], - "type": "AdInfo" - } - ] - }, - { - "name": "Reward", - "slug": "reward", - "docs": "The reward of a rewarded ad, as configured in the LevelPlay dashboard (per ad unit or placement).", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "methods": [], - "properties": [ - { - "name": "name", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Name of the reward, for example `Coins`.", - "complexTypes": [], - "type": "string" - }, - { - "name": "amount", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Amount of the reward.", - "complexTypes": [], - "type": "number" - } - ] - }, - { - "name": "AdError", - "slug": "aderror", - "docs": "Error reported by the SDK (load / display failures) or by the plugin.", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "methods": [], - "properties": [ - { - "name": "code", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "LevelPlay error code, for example `509` (no fill). `-1` is used by the plugin for \"Ad not ready\" and for the web\nstub.", - "complexTypes": [], - "type": "number" - }, - { - "name": "message", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Human readable message.", - "complexTypes": [], - "type": "string" - } - ] - }, - { - "name": "AdInfo", - "slug": "adinfo", - "docs": "Subset of the native `LevelPlayAdInfo` (Android) / `LPMAdInfo` (iOS) that is useful in JavaScript.\nFields the SDK does not report are omitted.", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "methods": [], - "properties": [ - { - "name": "adId", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Unique id of this ad.", - "complexTypes": [], - "type": "string | undefined" - }, - { - "name": "adUnitId", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Ad unit id.", - "complexTypes": [], - "type": "string" - }, - { - "name": "adUnitName", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Ad unit name from the dashboard.", - "complexTypes": [], - "type": "string | undefined" - }, - { - "name": "adFormat", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Ad format as reported by the SDK.", - "complexTypes": [], - "type": "string | undefined" - }, - { - "name": "placementName", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Placement name of the show call, when one was used.", - "complexTypes": [], - "type": "string | undefined" - }, - { - "name": "adNetwork", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Name of the mediated network that served the ad.", - "complexTypes": [], - "type": "string | undefined" - }, - { - "name": "instanceName", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Mediation instance name.", - "complexTypes": [], - "type": "string | undefined" - }, - { - "name": "instanceId", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Mediation instance id.", - "complexTypes": [], - "type": "string | undefined" - }, - { - "name": "country", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Country code of the impression.", - "complexTypes": [], - "type": "string | undefined" - }, - { - "name": "auctionId", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Auction id.", - "complexTypes": [], - "type": "string | undefined" - }, - { - "name": "revenue", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Impression revenue in USD as reported by the SDK (may be absent or 0 before display).", - "complexTypes": [], - "type": "number | undefined" - }, - { - "name": "precision", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Revenue precision as reported by the SDK.", - "complexTypes": [], - "type": "string | undefined" - } - ] - }, - { - "name": "ShowOptions", - "slug": "showoptions", - "docs": "Options for `showRewarded()` and `showInterstitial()`: `adUnitId` (see AdUnitOptions) plus an optional placement.", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "methods": [], - "properties": [ - { - "name": "placementName", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Optional placement name configured in the LevelPlay dashboard (capping, pacing and reward per placement).\nOmit it to use the default placement.", - "complexTypes": [], - "type": "string | undefined" - } - ] - }, - { - "name": "IsReadyResult", - "slug": "isreadyresult", - "docs": "Result of `isReady()`.", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "methods": [], - "properties": [ - { - "name": "ready", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "`true` when a loaded ad can be shown right now.", - "complexTypes": [], - "type": "boolean" - } - ] - }, - { - "name": "IsReadyOptions", - "slug": "isreadyoptions", - "docs": "Options for `isReady()`: `adUnitId` (see AdUnitOptions) plus the format.", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "methods": [], - "properties": [ - { - "name": "format", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Format of the ad unit.", - "complexTypes": [ - "AdFormat" - ], - "type": "AdFormat" - } - ] - }, - { - "name": "PluginListenerHandle", - "slug": "pluginlistenerhandle", - "docs": "", - "tags": [], - "methods": [], - "properties": [ - { - "name": "remove", - "tags": [], - "docs": "", - "complexTypes": [], - "type": "() => Promise" - } - ] - }, - { - "name": "AdEvent", - "slug": "adevent", - "docs": "Payload of the `loaded`, `displayed`, `clicked` and `closed` events.", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "methods": [], - "properties": [ - { - "name": "format", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Format of the ad unit that fired the event.", - "complexTypes": [ - "AdFormat" - ], - "type": "AdFormat" - }, - { - "name": "adUnitId", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Ad unit that fired the event.", - "complexTypes": [], - "type": "string" - }, - { - "name": "adInfo", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "Ad info, when the SDK provides it (not on `loadFailed`).", - "complexTypes": [ - "AdInfo" - ], - "type": "AdInfo" - } - ] - }, - { - "name": "AdErrorEvent", - "slug": "aderrorevent", - "docs": "Payload of the `loadFailed` and `displayFailed` events: the AdEvent fields plus `error`.", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "methods": [], - "properties": [ - { - "name": "error", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "What went wrong.", - "complexTypes": [ - "AdError" - ], - "type": "AdError" - } - ] - }, - { - "name": "AdRewardEvent", - "slug": "adrewardevent", - "docs": "Payload of the `rewarded` event: the AdEvent fields plus `reward`.", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "methods": [], - "properties": [ - { - "name": "reward", - "tags": [ - { - "text": "0.1.0", - "name": "since" - } - ], - "docs": "The reward earned.", - "complexTypes": [ - "Reward" - ], - "type": "Reward" - } - ] - } - ], - "enums": [], - "typeAliases": [ - { - "name": "TrackingStatus", - "slug": "trackingstatus", - "docs": "iOS App Tracking Transparency status. `unavailable` on Android, on the web and on unknown future iOS values.", - "types": [ - { - "text": "'authorized'", - "complexTypes": [] - }, - { - "text": "'denied'", - "complexTypes": [] - }, - { - "text": "'restricted'", - "complexTypes": [] - }, - { - "text": "'notDetermined'", - "complexTypes": [] - }, - { - "text": "'unavailable'", - "complexTypes": [] - } - ] - }, - { - "name": "AdFormat", - "slug": "adformat", - "docs": "Full-screen ad formats supported by this plugin. Banners and native ads are intentionally not exposed.", - "types": [ - { - "text": "'rewarded'", - "complexTypes": [] - }, - { - "text": "'interstitial'", - "complexTypes": [] - } - ] - } - ], - "pluginConfigs": [] -} \ No newline at end of file diff --git a/dist/esm/definitions.d.ts b/dist/esm/definitions.d.ts index d4fc256..d055414 100644 --- a/dist/esm/definitions.d.ts +++ b/dist/esm/definitions.d.ts @@ -1,546 +1,155 @@ import type { PluginListenerHandle } from '@capacitor/core'; -/** - * Full-screen ad formats supported by this plugin. Banners and native ads are intentionally not exposed. - * - * @since 0.1.0 - */ +/** Full-screen ad formats supported by this plugin. Banners and native ads are intentionally not exposed. */ export type AdFormat = 'rewarded' | 'interstitial'; -/** - * Options for `initialize()`. - * - * @since 0.1.0 - */ export interface InitOptions { - /** - * LevelPlay app key from the LevelPlay dashboard. Android and iOS apps have different keys. - * - * @since 0.1.0 - */ + /** LevelPlay app key from the LevelPlay dashboard (one per platform). */ appKey: string; - /** - * Optional user id. Needed for server-to-server reward callbacks and the Ad Quality user journey. - * - * @since 0.1.0 - */ + /** Optional user id, needed for server-to-server reward callbacks and the Ad Quality user journey. */ userId?: string; /** - * 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. - * - * @default false - * @since 0.1.0 + * Enable the LevelPlay Integration Test Suite (sets the `is_test_suite=enable` meta data before init). + * Call {@link LevelPlayPlugin.launchTestSuite} after init resolves. Never ship this enabled. */ testSuite?: boolean; - /** - * Turn on debug logs of the mediated ad network adapters (`LevelPlay.setAdaptersDebug(true)`). Development only. - * - * @default false - * @since 0.1.0 - */ + /** Turn on mediated ad network debug logs (`setAdaptersDebug`). Development only. */ adaptersDebug?: boolean; /** - * Privacy signals applied right before init (LevelPlay recommends setting them before the SDK starts). - * Same as calling `setConsent()` first. - * - * @since 0.1.0 + * Privacy flags applied right before init (LevelPlay recommends setting them before the SDK starts). + * Same as calling {@link LevelPlayPlugin.setConsent} first. */ consent?: ConsentOptions; } -/** - * Result of `initialize()` and `getSdkVersion()`. - * - * @since 0.1.0 - */ export interface InitResult { - /** - * Native LevelPlay SDK version, for example `9.6.1`. `web` on the web. - * - * @since 0.1.0 - */ + /** Native LevelPlay SDK version, for example `9.6.1`. */ sdkVersion: string; } /** * Privacy signals forwarded to LevelPlay (`LevelPlayPrivacySettings` on Android, `LPMPrivacySettings` on iOS). * Omitted fields are left untouched. - * - * @since 0.1.0 */ export interface ConsentOptions { - /** - * 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. - * - * @since 0.1.0 - */ + /** GDPR: `true` when the user consented to personalised ads / data processing. */ gdprConsent?: 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. - * - * @since 0.1.0 - */ + /** CCPA / US state privacy: `true` when the user opted OUT of the sale or sharing of personal data. */ ccpaDoNotSell?: boolean; - /** - * COPPA: `true` when the user must be treated as a child (child-directed treatment). - * - * @since 0.1.0 - */ + /** COPPA: `true` when the user must be treated as a child (child-directed treatment). */ coppa?: boolean; } -/** - * Options for `setMetaData()`. - * - * @since 0.1.0 - */ export interface MetaDataOptions { - /** - * Meta data key, for example `is_deviceid_optout` or a network-specific flag from Unity's docs. - * - * @since 0.1.0 - */ key: string; - /** - * Meta data value, always a string (for example `"true"`). - * - * @since 0.1.0 - */ value: string; } -/** - * Identifies one ad unit. - * - * @since 0.1.0 - */ export interface AdUnitOptions { - /** - * Ad unit id from the LevelPlay dashboard (Ad units page). Android and iOS ad units have different ids. - * - * @since 0.1.0 - */ + /** Ad unit id from the LevelPlay dashboard. */ adUnitId: string; } -/** - * Options for `showRewarded()` and `showInterstitial()`: `adUnitId` (see AdUnitOptions) plus an optional placement. - * - * @since 0.1.0 - */ export interface ShowOptions extends AdUnitOptions { - /** - * Optional placement name configured in the LevelPlay dashboard (capping, pacing and reward per placement). - * Omit it to use the default placement. - * - * @since 0.1.0 - */ + /** Optional placement name configured in the LevelPlay dashboard (capping / pacing / reward per placement). */ placementName?: string; } -/** - * Options for `isReady()`: `adUnitId` (see AdUnitOptions) plus the format. - * - * @since 0.1.0 - */ export interface IsReadyOptions extends AdUnitOptions { - /** - * Format of the ad unit. - * - * @since 0.1.0 - */ format: AdFormat; } -/** - * Result of `isReady()`. - * - * @since 0.1.0 - */ export interface IsReadyResult { - /** - * `true` when a loaded ad can be shown right now. - * - * @since 0.1.0 - */ ready: boolean; } -/** - * The reward of a rewarded ad, as configured in the LevelPlay dashboard (per ad unit or placement). - * - * @since 0.1.0 - */ export interface Reward { - /** - * Name of the reward, for example `Coins`. - * - * @since 0.1.0 - */ name: string; - /** - * Amount of the reward. - * - * @since 0.1.0 - */ amount: number; } -/** - * Error reported by the SDK (load / display failures) or by the plugin. - * - * @since 0.1.0 - */ export interface AdError { - /** - * LevelPlay error code, for example `509` (no fill). `-1` is used by the plugin for "Ad not ready" and for the web - * stub. - * - * @since 0.1.0 - */ code: number; - /** - * Human readable message. - * - * @since 0.1.0 - */ message: string; } -/** - * Subset of the native `LevelPlayAdInfo` (Android) / `LPMAdInfo` (iOS) that is useful in JavaScript. - * Fields the SDK does not report are omitted. - * - * @since 0.1.0 - */ +/** Subset of the native `LevelPlayAdInfo` / `LPMAdInfo` that is useful in JavaScript. */ export interface AdInfo { - /** - * Unique id of this ad. - * - * @since 0.1.0 - */ adId?: string; - /** - * Ad unit id. - * - * @since 0.1.0 - */ adUnitId: string; - /** - * Ad unit name from the dashboard. - * - * @since 0.1.0 - */ adUnitName?: string; - /** - * Ad format as reported by the SDK. - * - * @since 0.1.0 - */ adFormat?: string; - /** - * Placement name of the show call, when one was used. - * - * @since 0.1.0 - */ placementName?: string; - /** - * Name of the mediated network that served the ad. - * - * @since 0.1.0 - */ adNetwork?: string; - /** - * Mediation instance name. - * - * @since 0.1.0 - */ instanceName?: string; - /** - * Mediation instance id. - * - * @since 0.1.0 - */ instanceId?: string; - /** - * Country code of the impression. - * - * @since 0.1.0 - */ country?: string; - /** - * Auction id. - * - * @since 0.1.0 - */ auctionId?: string; - /** - * Impression revenue in USD as reported by the SDK (may be absent or 0 before display). - * - * @since 0.1.0 - */ + /** Impression revenue in USD as reported by the SDK (may be absent before display). */ revenue?: number; - /** - * Revenue precision as reported by the SDK. - * - * @since 0.1.0 - */ precision?: string; } -/** - * Result of `showRewarded()` and `showInterstitial()`, resolved after the ad - * closed or failed to display. - * - * @since 0.1.0 - */ export interface ShowResult { - /** - * The ad was displayed (the `displayed` event fired). - * - * @since 0.1.0 - */ + /** The ad was displayed (`displayed` fired). */ shown: boolean; - /** - * Rewarded only: the reward callback fired for this show. Grant the reward only when this is `true`. - * Always `false` for interstitials. - * - * @since 0.1.0 - */ + /** Rewarded only: the reward callback fired for this show. Grant the reward only when this is true. */ rewarded: boolean; - /** - * The reward, present when `rewarded` is `true`. - * - * @since 0.1.0 - */ reward?: Reward; - /** - * Present when the ad was not ready (`code: -1`) or failed to display. - * - * @since 0.1.0 - */ + /** Present when the ad was not ready or failed to display. */ error?: AdError; - /** - * Info of the displayed ad. - * - * @since 0.1.0 - */ adInfo?: AdInfo; } -/** - * Payload of the `loaded`, `displayed`, `clicked` and `closed` events. - * - * @since 0.1.0 - */ export interface AdEvent { - /** - * Format of the ad unit that fired the event. - * - * @since 0.1.0 - */ format: AdFormat; - /** - * Ad unit that fired the event. - * - * @since 0.1.0 - */ adUnitId: string; - /** - * Ad info, when the SDK provides it (not on `loadFailed`). - * - * @since 0.1.0 - */ adInfo?: AdInfo; } -/** - * Payload of the `loadFailed` and `displayFailed` events: the AdEvent fields plus `error`. - * - * @since 0.1.0 - */ export interface AdErrorEvent extends AdEvent { - /** - * What went wrong. - * - * @since 0.1.0 - */ error: AdError; } -/** - * Payload of the `rewarded` event: the AdEvent fields plus `reward`. - * - * @since 0.1.0 - */ export interface AdRewardEvent extends AdEvent { - /** - * The reward earned. - * - * @since 0.1.0 - */ reward: Reward; } -/** - * iOS App Tracking Transparency status. `unavailable` on Android, on the web and on unknown future iOS values. - * - * @since 0.1.0 - */ export type TrackingStatus = 'authorized' | 'denied' | 'restricted' | 'notDetermined' | 'unavailable'; -/** - * Result of `requestTrackingAuthorization()` and - * `getTrackingAuthorizationStatus()`. - * - * @since 0.1.0 - */ export interface TrackingResult { - /** - * iOS App Tracking Transparency status. Always `unavailable` on Android and web. - * - * @since 0.1.0 - */ + /** iOS App Tracking Transparency status. Always `unavailable` on Android and web. */ status: TrackingStatus; } -/** - * Event names emitted by the plugin. - * - * @since 0.1.0 - */ -export type LevelPlayEventName = 'loaded' | 'loadFailed' | 'displayed' | 'displayFailed' | 'clicked' | 'closed' | 'rewarded'; -/** - * Unity LevelPlay rewarded and interstitial ads (ad-unit API). - * - * @since 0.1.0 - */ export interface LevelPlayPlugin { /** - * 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. - * - * @since 0.1.0 + * Initialise the LevelPlay SDK. Resolves on `onInitSuccess`, rejects with the init error otherwise. + * Calling it again after a successful init resolves immediately. Load ads only after this resolves. */ initialize(options: InitOptions): Promise; - /** - * Native LevelPlay SDK version. Works before init. - * - * @since 0.1.0 - */ + /** Native SDK version (available before init). */ getSdkVersion(): Promise; - /** - * Forward GDPR / CCPA / COPPA signals to LevelPlay. Call it before `initialize()` when you - * can, and again whenever the user changes their choice. - * - * @since 0.1.0 - */ + /** Forward GDPR / CCPA / COPPA signals. Call before {@link initialize} when you can. */ setConsent(options: ConsentOptions): Promise; - /** - * Raw `LevelPlay.setMetaData(key, value)` for SDK or network-specific flags. Call it before init. - * - * @since 0.1.0 - */ + /** Raw `LevelPlay.setMetaData(key, value)` for network-specific flags. Call before init. */ setMetaData(options: MetaDataOptions): Promise; /** - * 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`. - * - * @since 0.1.0 + * iOS: show the App Tracking Transparency prompt (needs `NSUserTrackingUsageDescription` in Info.plist) and resolve + * with the resulting status. Call it before {@link initialize}. Android / web: resolves `unavailable`. */ requestTrackingAuthorization(): Promise; - /** - * Current App Tracking Transparency status without prompting (iOS). Android and web: `unavailable`. - * - * @since 0.1.0 - */ + /** Current ATT status without prompting (iOS). Android / web: `unavailable`. */ getTrackingAuthorizationStatus(): Promise; /** - * 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. - * - * @since 0.1.0 + * Start loading a rewarded ad for the ad unit (the ad object is created on first use and reused). + * Resolves once the request is issued; the outcome arrives as `loaded` / `loadFailed` events. */ loadRewarded(options: AdUnitOptions): Promise; /** - * 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. - * - * @since 0.1.0 + * Show a loaded rewarded ad. Resolves after the ad closes (or failed to display) with what happened. + * Never rejects for "not ready": resolves `{ shown: false, error }` instead. */ showRewarded(options: ShowOptions): Promise; - /** - * Start loading an interstitial ad for the ad unit. Works like `loadRewarded()`. - * - * @since 0.1.0 - */ + /** Start loading an interstitial ad (see {@link loadRewarded}). */ loadInterstitial(options: AdUnitOptions): Promise; - /** - * Show a loaded interstitial. Resolves after it closed (or failed to display). Never rejects for "not ready". - * - * @since 0.1.0 - */ + /** Show a loaded interstitial. Resolves after it closes (or failed to display). */ showInterstitial(options: ShowOptions): Promise; - /** - * `isAdReady()` of the native ad object for this ad unit. `false` when the ad unit was never loaded. - * - * @since 0.1.0 - */ + /** `isAdReady()` of the ad object for this ad unit (`false` when it was never loaded). */ isReady(options: IsReadyOptions): Promise; - /** - * Open the LevelPlay Integration Test Suite. Requires `initialize({ testSuite: true })` first. - * Development builds only. Rejects on the web. - * - * @since 0.1.0 - */ + /** Open the LevelPlay Integration Test Suite. Requires `initialize({ testSuite: true })` first. */ launchTestSuite(): Promise; - /** - * 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 - */ + /** Log the LevelPlay integration helper report to the native console (development only). */ validateIntegration(): Promise; - /** - * An ad finished loading for the ad unit and can be shown. - * - * @since 0.1.0 - */ addListener(eventName: 'loaded', listenerFunc: (event: AdEvent) => void): Promise; - /** - * Loading failed, for example `509` (no fill). Retry later with a backoff. - * - * @since 0.1.0 - */ addListener(eventName: 'loadFailed', listenerFunc: (event: AdErrorEvent) => void): Promise; - /** - * The ad was displayed (impression). `adInfo.revenue` is available here. - * - * @since 0.1.0 - */ addListener(eventName: 'displayed', listenerFunc: (event: AdEvent) => void): Promise; - /** - * The ad failed to display. The pending show call resolves with the same error. - * - * @since 0.1.0 - */ addListener(eventName: 'displayFailed', listenerFunc: (event: AdErrorEvent) => void): Promise; - /** - * The user clicked the ad. - * - * @since 0.1.0 - */ addListener(eventName: 'clicked', listenerFunc: (event: AdEvent) => void): Promise; - /** - * The ad was closed and the app is back in front. - * - * @since 0.1.0 - */ addListener(eventName: 'closed', listenerFunc: (event: AdEvent) => void): Promise; - /** - * Rewarded only: the user earned the reward. Can fire before or after `closed`. - * - * @since 0.1.0 - */ addListener(eventName: 'rewarded', listenerFunc: (event: AdRewardEvent) => void): Promise; - /** - * Remove every listener of this plugin. - * - * @since 0.1.0 - */ removeAllListeners(): Promise; } +/** Event names emitted by the plugin. */ +export type LevelPlayEventName = 'loaded' | 'loadFailed' | 'displayed' | 'displayFailed' | 'clicked' | 'closed' | 'rewarded'; diff --git a/dist/esm/definitions.js.map b/dist/esm/definitions.js.map index 6064034..2344ece 100644 --- a/dist/esm/definitions.js.map +++ b/dist/esm/definitions.js.map @@ -1 +1 @@ -{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\n/**\n * Full-screen ad formats supported by this plugin. Banners and native ads are intentionally not exposed.\n *\n * @since 0.1.0\n */\nexport type AdFormat = 'rewarded' | 'interstitial';\n\n/**\n * Options for `initialize()`.\n *\n * @since 0.1.0\n */\nexport interface InitOptions {\n /**\n * LevelPlay app key from the LevelPlay dashboard. Android and iOS apps have different keys.\n *\n * @since 0.1.0\n */\n appKey: string;\n /**\n * Optional user id. Needed for server-to-server reward callbacks and the Ad Quality user journey.\n *\n * @since 0.1.0\n */\n userId?: string;\n /**\n * Enable the LevelPlay Integration Test Suite: sets the `is_test_suite=enable` meta data before init.\n * Call `launchTestSuite()` after `initialize` resolves. Never ship this enabled.\n *\n * @default false\n * @since 0.1.0\n */\n testSuite?: boolean;\n /**\n * Turn on debug logs of the mediated ad network adapters (`LevelPlay.setAdaptersDebug(true)`). Development only.\n *\n * @default false\n * @since 0.1.0\n */\n adaptersDebug?: boolean;\n /**\n * Privacy signals applied right before init (LevelPlay recommends setting them before the SDK starts).\n * Same as calling `setConsent()` first.\n *\n * @since 0.1.0\n */\n consent?: ConsentOptions;\n}\n\n/**\n * Result of `initialize()` and `getSdkVersion()`.\n *\n * @since 0.1.0\n */\nexport interface InitResult {\n /**\n * Native LevelPlay SDK version, for example `9.6.1`. `web` on the web.\n *\n * @since 0.1.0\n */\n sdkVersion: string;\n}\n\n/**\n * Privacy signals forwarded to LevelPlay (`LevelPlayPrivacySettings` on Android, `LPMPrivacySettings` on iOS).\n * Omitted fields are left untouched.\n *\n * @since 0.1.0\n */\nexport interface ConsentOptions {\n /**\n * GDPR: `true` when the user consented to personalised ads and data processing, `false` when they did not.\n * For users in the EEA, UK and Switzerland pass `false` until a consent management platform (CMP) says otherwise.\n *\n * @since 0.1.0\n */\n gdprConsent?: boolean;\n /**\n * CCPA and other US state privacy laws: `true` when the user opted OUT of the sale or sharing of personal data\n * (\"do not sell\"), `false` otherwise.\n *\n * @since 0.1.0\n */\n ccpaDoNotSell?: boolean;\n /**\n * COPPA: `true` when the user must be treated as a child (child-directed treatment).\n *\n * @since 0.1.0\n */\n coppa?: boolean;\n}\n\n/**\n * Options for `setMetaData()`.\n *\n * @since 0.1.0\n */\nexport interface MetaDataOptions {\n /**\n * Meta data key, for example `is_deviceid_optout` or a network-specific flag from Unity's docs.\n *\n * @since 0.1.0\n */\n key: string;\n /**\n * Meta data value, always a string (for example `\"true\"`).\n *\n * @since 0.1.0\n */\n value: string;\n}\n\n/**\n * Identifies one ad unit.\n *\n * @since 0.1.0\n */\nexport interface AdUnitOptions {\n /**\n * Ad unit id from the LevelPlay dashboard (Ad units page). Android and iOS ad units have different ids.\n *\n * @since 0.1.0\n */\n adUnitId: string;\n}\n\n/**\n * Options for `showRewarded()` and `showInterstitial()`: `adUnitId` (see AdUnitOptions) plus an optional placement.\n *\n * @since 0.1.0\n */\nexport interface ShowOptions extends AdUnitOptions {\n /**\n * Optional placement name configured in the LevelPlay dashboard (capping, pacing and reward per placement).\n * Omit it to use the default placement.\n *\n * @since 0.1.0\n */\n placementName?: string;\n}\n\n/**\n * Options for `isReady()`: `adUnitId` (see AdUnitOptions) plus the format.\n *\n * @since 0.1.0\n */\nexport interface IsReadyOptions extends AdUnitOptions {\n /**\n * Format of the ad unit.\n *\n * @since 0.1.0\n */\n format: AdFormat;\n}\n\n/**\n * Result of `isReady()`.\n *\n * @since 0.1.0\n */\nexport interface IsReadyResult {\n /**\n * `true` when a loaded ad can be shown right now.\n *\n * @since 0.1.0\n */\n ready: boolean;\n}\n\n/**\n * The reward of a rewarded ad, as configured in the LevelPlay dashboard (per ad unit or placement).\n *\n * @since 0.1.0\n */\nexport interface Reward {\n /**\n * Name of the reward, for example `Coins`.\n *\n * @since 0.1.0\n */\n name: string;\n /**\n * Amount of the reward.\n *\n * @since 0.1.0\n */\n amount: number;\n}\n\n/**\n * Error reported by the SDK (load / display failures) or by the plugin.\n *\n * @since 0.1.0\n */\nexport interface AdError {\n /**\n * LevelPlay error code, for example `509` (no fill). `-1` is used by the plugin for \"Ad not ready\" and for the web\n * stub.\n *\n * @since 0.1.0\n */\n code: number;\n /**\n * Human readable message.\n *\n * @since 0.1.0\n */\n message: string;\n}\n\n/**\n * Subset of the native `LevelPlayAdInfo` (Android) / `LPMAdInfo` (iOS) that is useful in JavaScript.\n * Fields the SDK does not report are omitted.\n *\n * @since 0.1.0\n */\nexport interface AdInfo {\n /**\n * Unique id of this ad.\n *\n * @since 0.1.0\n */\n adId?: string;\n /**\n * Ad unit id.\n *\n * @since 0.1.0\n */\n adUnitId: string;\n /**\n * Ad unit name from the dashboard.\n *\n * @since 0.1.0\n */\n adUnitName?: string;\n /**\n * Ad format as reported by the SDK.\n *\n * @since 0.1.0\n */\n adFormat?: string;\n /**\n * Placement name of the show call, when one was used.\n *\n * @since 0.1.0\n */\n placementName?: string;\n /**\n * Name of the mediated network that served the ad.\n *\n * @since 0.1.0\n */\n adNetwork?: string;\n /**\n * Mediation instance name.\n *\n * @since 0.1.0\n */\n instanceName?: string;\n /**\n * Mediation instance id.\n *\n * @since 0.1.0\n */\n instanceId?: string;\n /**\n * Country code of the impression.\n *\n * @since 0.1.0\n */\n country?: string;\n /**\n * Auction id.\n *\n * @since 0.1.0\n */\n auctionId?: string;\n /**\n * Impression revenue in USD as reported by the SDK (may be absent or 0 before display).\n *\n * @since 0.1.0\n */\n revenue?: number;\n /**\n * Revenue precision as reported by the SDK.\n *\n * @since 0.1.0\n */\n precision?: string;\n}\n\n/**\n * Result of `showRewarded()` and `showInterstitial()`, resolved after the ad\n * closed or failed to display.\n *\n * @since 0.1.0\n */\nexport interface ShowResult {\n /**\n * The ad was displayed (the `displayed` event fired).\n *\n * @since 0.1.0\n */\n shown: boolean;\n /**\n * Rewarded only: the reward callback fired for this show. Grant the reward only when this is `true`.\n * Always `false` for interstitials.\n *\n * @since 0.1.0\n */\n rewarded: boolean;\n /**\n * The reward, present when `rewarded` is `true`.\n *\n * @since 0.1.0\n */\n reward?: Reward;\n /**\n * Present when the ad was not ready (`code: -1`) or failed to display.\n *\n * @since 0.1.0\n */\n error?: AdError;\n /**\n * Info of the displayed ad.\n *\n * @since 0.1.0\n */\n adInfo?: AdInfo;\n}\n\n/**\n * Payload of the `loaded`, `displayed`, `clicked` and `closed` events.\n *\n * @since 0.1.0\n */\nexport interface AdEvent {\n /**\n * Format of the ad unit that fired the event.\n *\n * @since 0.1.0\n */\n format: AdFormat;\n /**\n * Ad unit that fired the event.\n *\n * @since 0.1.0\n */\n adUnitId: string;\n /**\n * Ad info, when the SDK provides it (not on `loadFailed`).\n *\n * @since 0.1.0\n */\n adInfo?: AdInfo;\n}\n\n/**\n * Payload of the `loadFailed` and `displayFailed` events: the AdEvent fields plus `error`.\n *\n * @since 0.1.0\n */\nexport interface AdErrorEvent extends AdEvent {\n /**\n * What went wrong.\n *\n * @since 0.1.0\n */\n error: AdError;\n}\n\n/**\n * Payload of the `rewarded` event: the AdEvent fields plus `reward`.\n *\n * @since 0.1.0\n */\nexport interface AdRewardEvent extends AdEvent {\n /**\n * The reward earned.\n *\n * @since 0.1.0\n */\n reward: Reward;\n}\n\n/**\n * iOS App Tracking Transparency status. `unavailable` on Android, on the web and on unknown future iOS values.\n *\n * @since 0.1.0\n */\nexport type TrackingStatus = 'authorized' | 'denied' | 'restricted' | 'notDetermined' | 'unavailable';\n\n/**\n * Result of `requestTrackingAuthorization()` and\n * `getTrackingAuthorizationStatus()`.\n *\n * @since 0.1.0\n */\nexport interface TrackingResult {\n /**\n * iOS App Tracking Transparency status. Always `unavailable` on Android and web.\n *\n * @since 0.1.0\n */\n status: TrackingStatus;\n}\n\n/**\n * Event names emitted by the plugin.\n *\n * @since 0.1.0\n */\nexport type LevelPlayEventName =\n | 'loaded'\n | 'loadFailed'\n | 'displayed'\n | 'displayFailed'\n | 'clicked'\n | 'closed'\n | 'rewarded';\n\n/**\n * Unity LevelPlay rewarded and interstitial ads (ad-unit API).\n *\n * @since 0.1.0\n */\nexport interface LevelPlayPlugin {\n /**\n * Initialise the LevelPlay SDK (`LevelPlay.init`). Resolves on init success, rejects with the init error\n * (code and message from the SDK) otherwise. Calling it again after a successful init resolves immediately;\n * concurrent calls share one init. Load ads only after this resolves.\n *\n * Set consent (and on iOS ask for ATT) before calling it.\n *\n * On the web it rejects as unimplemented.\n *\n * @since 0.1.0\n */\n initialize(options: InitOptions): Promise;\n\n /**\n * Native LevelPlay SDK version. Works before init.\n *\n * @since 0.1.0\n */\n getSdkVersion(): Promise;\n\n /**\n * Forward GDPR / CCPA / COPPA signals to LevelPlay. Call it before `initialize()` when you\n * can, and again whenever the user changes their choice.\n *\n * @since 0.1.0\n */\n setConsent(options: ConsentOptions): Promise;\n\n /**\n * Raw `LevelPlay.setMetaData(key, value)` for SDK or network-specific flags. Call it before init.\n *\n * @since 0.1.0\n */\n setMetaData(options: MetaDataOptions): Promise;\n\n /**\n * iOS: show the App Tracking Transparency prompt and resolve with the resulting status. Needs\n * `NSUserTrackingUsageDescription` in `Info.plist`. iOS only shows the prompt once; later calls resolve the stored\n * status. Call it before `initialize()`, while the app is active.\n *\n * Android and web: resolves `unavailable`.\n *\n * @since 0.1.0\n */\n requestTrackingAuthorization(): Promise;\n\n /**\n * Current App Tracking Transparency status without prompting (iOS). Android and web: `unavailable`.\n *\n * @since 0.1.0\n */\n getTrackingAuthorizationStatus(): Promise;\n\n /**\n * Start loading a rewarded ad for the ad unit. The native ad object is created on first use and reused for the\n * ad unit. Resolves once the request is issued; the outcome arrives as a `loaded` or `loadFailed` event.\n * Load the next ad after each show.\n *\n * @since 0.1.0\n */\n loadRewarded(options: AdUnitOptions): Promise;\n\n /**\n * Show a loaded rewarded ad. Resolves after the ad closed (or failed to display) with what happened. The reward\n * and close callbacks can arrive in either order on some networks, so the plugin waits up to 1 second after the close\n * for a late reward. Never rejects for \"not ready\": resolves `{ shown: false, rewarded: false, error }` instead.\n *\n * @since 0.1.0\n */\n showRewarded(options: ShowOptions): Promise;\n\n /**\n * Start loading an interstitial ad for the ad unit. Works like `loadRewarded()`.\n *\n * @since 0.1.0\n */\n loadInterstitial(options: AdUnitOptions): Promise;\n\n /**\n * Show a loaded interstitial. Resolves after it closed (or failed to display). Never rejects for \"not ready\".\n *\n * @since 0.1.0\n */\n showInterstitial(options: ShowOptions): Promise;\n\n /**\n * `isAdReady()` of the native ad object for this ad unit. `false` when the ad unit was never loaded.\n *\n * @since 0.1.0\n */\n isReady(options: IsReadyOptions): Promise;\n\n /**\n * Open the LevelPlay Integration Test Suite. Requires `initialize({ testSuite: true })` first.\n * Development builds only. Rejects on the web.\n *\n * @since 0.1.0\n */\n launchTestSuite(): Promise;\n\n /**\n * Write the LevelPlay integration helper report to the native log (Xcode console; Android logcat tag\n * `IntegrationHelper`): SDK, adapter and network SDK versions, each `VERIFIED` or not. Development only.\n *\n * @since 0.1.0\n */\n validateIntegration(): Promise;\n\n /**\n * An ad finished loading for the ad unit and can be shown.\n *\n * @since 0.1.0\n */\n addListener(eventName: 'loaded', listenerFunc: (event: AdEvent) => void): Promise;\n\n /**\n * Loading failed, for example `509` (no fill). Retry later with a backoff.\n *\n * @since 0.1.0\n */\n addListener(eventName: 'loadFailed', listenerFunc: (event: AdErrorEvent) => void): Promise;\n\n /**\n * The ad was displayed (impression). `adInfo.revenue` is available here.\n *\n * @since 0.1.0\n */\n addListener(eventName: 'displayed', listenerFunc: (event: AdEvent) => void): Promise;\n\n /**\n * The ad failed to display. The pending show call resolves with the same error.\n *\n * @since 0.1.0\n */\n addListener(\n eventName: 'displayFailed',\n listenerFunc: (event: AdErrorEvent) => void,\n ): Promise;\n\n /**\n * The user clicked the ad.\n *\n * @since 0.1.0\n */\n addListener(eventName: 'clicked', listenerFunc: (event: AdEvent) => void): Promise;\n\n /**\n * The ad was closed and the app is back in front.\n *\n * @since 0.1.0\n */\n addListener(eventName: 'closed', listenerFunc: (event: AdEvent) => void): Promise;\n\n /**\n * Rewarded only: the user earned the reward. Can fire before or after `closed`.\n *\n * @since 0.1.0\n */\n addListener(eventName: 'rewarded', listenerFunc: (event: AdRewardEvent) => void): Promise;\n\n /**\n * Remove every listener of this plugin.\n *\n * @since 0.1.0\n */\n removeAllListeners(): Promise;\n}\n"]} \ No newline at end of file +{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\n/** Full-screen ad formats supported by this plugin. Banners and native ads are intentionally not exposed. */\nexport type AdFormat = 'rewarded' | 'interstitial';\n\nexport interface InitOptions {\n /** LevelPlay app key from the LevelPlay dashboard (one per platform). */\n appKey: string;\n /** Optional user id, needed for server-to-server reward callbacks and the Ad Quality user journey. */\n userId?: string;\n /**\n * Enable the LevelPlay Integration Test Suite (sets the `is_test_suite=enable` meta data before init).\n * Call {@link LevelPlayPlugin.launchTestSuite} after init resolves. Never ship this enabled.\n */\n testSuite?: boolean;\n /** Turn on mediated ad network debug logs (`setAdaptersDebug`). Development only. */\n adaptersDebug?: boolean;\n /**\n * Privacy flags applied right before init (LevelPlay recommends setting them before the SDK starts).\n * Same as calling {@link LevelPlayPlugin.setConsent} first.\n */\n consent?: ConsentOptions;\n}\n\nexport interface InitResult {\n /** Native LevelPlay SDK version, for example `9.6.1`. */\n sdkVersion: string;\n}\n\n/**\n * Privacy signals forwarded to LevelPlay (`LevelPlayPrivacySettings` on Android, `LPMPrivacySettings` on iOS).\n * Omitted fields are left untouched.\n */\nexport interface ConsentOptions {\n /** GDPR: `true` when the user consented to personalised ads / data processing. */\n gdprConsent?: boolean;\n /** CCPA / US state privacy: `true` when the user opted OUT of the sale or sharing of personal data. */\n ccpaDoNotSell?: boolean;\n /** COPPA: `true` when the user must be treated as a child (child-directed treatment). */\n coppa?: boolean;\n}\n\nexport interface MetaDataOptions {\n key: string;\n value: string;\n}\n\nexport interface AdUnitOptions {\n /** Ad unit id from the LevelPlay dashboard. */\n adUnitId: string;\n}\n\nexport interface ShowOptions extends AdUnitOptions {\n /** Optional placement name configured in the LevelPlay dashboard (capping / pacing / reward per placement). */\n placementName?: string;\n}\n\nexport interface IsReadyOptions extends AdUnitOptions {\n format: AdFormat;\n}\n\nexport interface IsReadyResult {\n ready: boolean;\n}\n\nexport interface Reward {\n name: string;\n amount: number;\n}\n\nexport interface AdError {\n code: number;\n message: string;\n}\n\n/** Subset of the native `LevelPlayAdInfo` / `LPMAdInfo` that is useful in JavaScript. */\nexport interface AdInfo {\n adId?: string;\n adUnitId: string;\n adUnitName?: string;\n adFormat?: string;\n placementName?: string;\n adNetwork?: string;\n instanceName?: string;\n instanceId?: string;\n country?: string;\n auctionId?: string;\n /** Impression revenue in USD as reported by the SDK (may be absent before display). */\n revenue?: number;\n precision?: string;\n}\n\nexport interface ShowResult {\n /** The ad was displayed (`displayed` fired). */\n shown: boolean;\n /** Rewarded only: the reward callback fired for this show. Grant the reward only when this is true. */\n rewarded: boolean;\n reward?: Reward;\n /** Present when the ad was not ready or failed to display. */\n error?: AdError;\n adInfo?: AdInfo;\n}\n\nexport interface AdEvent {\n format: AdFormat;\n adUnitId: string;\n adInfo?: AdInfo;\n}\n\nexport interface AdErrorEvent extends AdEvent {\n error: AdError;\n}\n\nexport interface AdRewardEvent extends AdEvent {\n reward: Reward;\n}\n\nexport type TrackingStatus = 'authorized' | 'denied' | 'restricted' | 'notDetermined' | 'unavailable';\n\nexport interface TrackingResult {\n /** iOS App Tracking Transparency status. Always `unavailable` on Android and web. */\n status: TrackingStatus;\n}\n\nexport interface LevelPlayPlugin {\n /**\n * Initialise the LevelPlay SDK. Resolves on `onInitSuccess`, rejects with the init error otherwise.\n * Calling it again after a successful init resolves immediately. Load ads only after this resolves.\n */\n initialize(options: InitOptions): Promise;\n\n /** Native SDK version (available before init). */\n getSdkVersion(): Promise;\n\n /** Forward GDPR / CCPA / COPPA signals. Call before {@link initialize} when you can. */\n setConsent(options: ConsentOptions): Promise;\n\n /** Raw `LevelPlay.setMetaData(key, value)` for network-specific flags. Call before init. */\n setMetaData(options: MetaDataOptions): Promise;\n\n /**\n * iOS: show the App Tracking Transparency prompt (needs `NSUserTrackingUsageDescription` in Info.plist) and resolve\n * with the resulting status. Call it before {@link initialize}. Android / web: resolves `unavailable`.\n */\n requestTrackingAuthorization(): Promise;\n\n /** Current ATT status without prompting (iOS). Android / web: `unavailable`. */\n getTrackingAuthorizationStatus(): Promise;\n\n /**\n * Start loading a rewarded ad for the ad unit (the ad object is created on first use and reused).\n * Resolves once the request is issued; the outcome arrives as `loaded` / `loadFailed` events.\n */\n loadRewarded(options: AdUnitOptions): Promise;\n\n /**\n * Show a loaded rewarded ad. Resolves after the ad closes (or failed to display) with what happened.\n * Never rejects for \"not ready\": resolves `{ shown: false, error }` instead.\n */\n showRewarded(options: ShowOptions): Promise;\n\n /** Start loading an interstitial ad (see {@link loadRewarded}). */\n loadInterstitial(options: AdUnitOptions): Promise;\n\n /** Show a loaded interstitial. Resolves after it closes (or failed to display). */\n showInterstitial(options: ShowOptions): Promise;\n\n /** `isAdReady()` of the ad object for this ad unit (`false` when it was never loaded). */\n isReady(options: IsReadyOptions): Promise;\n\n /** Open the LevelPlay Integration Test Suite. Requires `initialize({ testSuite: true })` first. */\n launchTestSuite(): Promise;\n\n /** Log the LevelPlay integration helper report to the native console (development only). */\n validateIntegration(): Promise;\n\n addListener(eventName: 'loaded', listenerFunc: (event: AdEvent) => void): Promise;\n addListener(eventName: 'loadFailed', listenerFunc: (event: AdErrorEvent) => void): Promise;\n addListener(eventName: 'displayed', listenerFunc: (event: AdEvent) => void): Promise;\n addListener(eventName: 'displayFailed', listenerFunc: (event: AdErrorEvent) => void): Promise;\n addListener(eventName: 'clicked', listenerFunc: (event: AdEvent) => void): Promise;\n addListener(eventName: 'closed', listenerFunc: (event: AdEvent) => void): Promise;\n addListener(eventName: 'rewarded', listenerFunc: (event: AdRewardEvent) => void): Promise;\n\n removeAllListeners(): Promise;\n}\n\n/** Event names emitted by the plugin. */\nexport type LevelPlayEventName = 'loaded' | 'loadFailed' | 'displayed' | 'displayFailed' | 'clicked' | 'closed' | 'rewarded';\n"]} \ No newline at end of file diff --git a/package.json b/package.json index c3f9535..c6a275d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "capacitor-levelplay", - "version": "0.2.0", - "description": "Capacitor 8 plugin for Unity LevelPlay (ironSource) rewarded and interstitial ads on Android and iOS: ad-unit API, Swift Package Manager first, ATT and GDPR / CCPA / COPPA consent.", + "version": "0.1.0", + "description": "Capacitor 8 plugin for Unity LevelPlay (ironSource) rewarded and interstitial ads. Swift Package Manager first, ad-unit API.", "main": "dist/plugin.cjs.js", "module": "dist/esm/index.js", "types": "dist/esm/index.d.ts", @@ -11,62 +11,36 @@ "android/build.gradle", "android/proguard-rules.pro", "dist/", - "ios/Sources/", + "ios/Sources", "Package.swift", - "CapacitorLevelplay.podspec", - "CHANGELOG.md" + "CapacitorLevelplay.podspec" ], - "author": { - "name": "VOX Games", - "url": "https://vox.games" - }, + "author": "VOX Games", "license": "MIT", - "homepage": "https://git.crt.fyi/CRT/capacitor-levelplay#readme", - "bugs": { - "url": "https://git.crt.fyi/CRT/capacitor-levelplay/issues" - }, "repository": { "type": "git", - "url": "git+https://git.crt.fyi/CRT/capacitor-levelplay.git" + "url": "https://git.crt.fyi/CRT/capacitor-levelplay.git" }, "keywords": [ "capacitor", - "capacitor-plugin", - "capacitor8", "plugin", "native", "levelplay", - "unity-levelplay", "ironsource", "unity", - "unity-ads", "ads", - "mediation", "rewarded", - "rewarded-video", - "interstitial", - "ios", - "android", - "swift-package-manager" + "interstitial" ], - "engines": { - "node": ">=22" - }, "scripts": { - "build": "bun run clean && bun run docgen && tsc && rollup -c rollup.config.mjs", - "clean": "rm -rf dist", - "docgen": "docgen --api LevelPlayPlugin --output-readme README.md --output-json dist/docs.json", + "build": "rm -rf dist && tsc && rollup -c rollup.config.mjs", "typecheck": "tsc --noEmit", - "verify": "bun run typecheck && bun run build && bun run verify:ios && bun run verify:android", "verify:ios": "xcodebuild build -scheme CapacitorLevelplay -destination 'generic/platform=iOS Simulator'", - "verify:android": "cd android && ./gradlew clean build test && cd ..", "verify:web": "bun run build", "prepublishOnly": "bun run build" }, "devDependencies": { - "@capacitor/android": "^8.0.0", "@capacitor/core": "^8.0.0", - "@capacitor/docgen": "^0.3.1", "rollup": "^4.53.3", "typescript": "^5.9.3" }, diff --git a/src/definitions.ts b/src/definitions.ts index f4a8b85..8a9063b 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -1,596 +1,189 @@ import type { PluginListenerHandle } from '@capacitor/core'; -/** - * Full-screen ad formats supported by this plugin. Banners and native ads are intentionally not exposed. - * - * @since 0.1.0 - */ +/** Full-screen ad formats supported by this plugin. Banners and native ads are intentionally not exposed. */ export type AdFormat = 'rewarded' | 'interstitial'; -/** - * Options for `initialize()`. - * - * @since 0.1.0 - */ export interface InitOptions { - /** - * LevelPlay app key from the LevelPlay dashboard. Android and iOS apps have different keys. - * - * @since 0.1.0 - */ + /** LevelPlay app key from the LevelPlay dashboard (one per platform). */ appKey: string; - /** - * Optional user id. Needed for server-to-server reward callbacks and the Ad Quality user journey. - * - * @since 0.1.0 - */ + /** Optional user id, needed for server-to-server reward callbacks and the Ad Quality user journey. */ userId?: string; /** - * 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. - * - * @default false - * @since 0.1.0 + * Enable the LevelPlay Integration Test Suite (sets the `is_test_suite=enable` meta data before init). + * Call {@link LevelPlayPlugin.launchTestSuite} after init resolves. Never ship this enabled. */ testSuite?: boolean; - /** - * Turn on debug logs of the mediated ad network adapters (`LevelPlay.setAdaptersDebug(true)`). Development only. - * - * @default false - * @since 0.1.0 - */ + /** Turn on mediated ad network debug logs (`setAdaptersDebug`). Development only. */ adaptersDebug?: boolean; /** - * Privacy signals applied right before init (LevelPlay recommends setting them before the SDK starts). - * Same as calling `setConsent()` first. - * - * @since 0.1.0 + * Privacy flags applied right before init (LevelPlay recommends setting them before the SDK starts). + * Same as calling {@link LevelPlayPlugin.setConsent} first. */ consent?: ConsentOptions; } -/** - * Result of `initialize()` and `getSdkVersion()`. - * - * @since 0.1.0 - */ export interface InitResult { - /** - * Native LevelPlay SDK version, for example `9.6.1`. `web` on the web. - * - * @since 0.1.0 - */ + /** Native LevelPlay SDK version, for example `9.6.1`. */ sdkVersion: string; } /** * Privacy signals forwarded to LevelPlay (`LevelPlayPrivacySettings` on Android, `LPMPrivacySettings` on iOS). * Omitted fields are left untouched. - * - * @since 0.1.0 */ export interface ConsentOptions { - /** - * 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. - * - * @since 0.1.0 - */ + /** GDPR: `true` when the user consented to personalised ads / data processing. */ gdprConsent?: 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. - * - * @since 0.1.0 - */ + /** CCPA / US state privacy: `true` when the user opted OUT of the sale or sharing of personal data. */ ccpaDoNotSell?: boolean; - /** - * COPPA: `true` when the user must be treated as a child (child-directed treatment). - * - * @since 0.1.0 - */ + /** COPPA: `true` when the user must be treated as a child (child-directed treatment). */ coppa?: boolean; } -/** - * Options for `setMetaData()`. - * - * @since 0.1.0 - */ export interface MetaDataOptions { - /** - * Meta data key, for example `is_deviceid_optout` or a network-specific flag from Unity's docs. - * - * @since 0.1.0 - */ key: string; - /** - * Meta data value, always a string (for example `"true"`). - * - * @since 0.1.0 - */ value: string; } -/** - * Identifies one ad unit. - * - * @since 0.1.0 - */ export interface AdUnitOptions { - /** - * Ad unit id from the LevelPlay dashboard (Ad units page). Android and iOS ad units have different ids. - * - * @since 0.1.0 - */ + /** Ad unit id from the LevelPlay dashboard. */ adUnitId: string; } -/** - * Options for `showRewarded()` and `showInterstitial()`: `adUnitId` (see AdUnitOptions) plus an optional placement. - * - * @since 0.1.0 - */ export interface ShowOptions extends AdUnitOptions { - /** - * Optional placement name configured in the LevelPlay dashboard (capping, pacing and reward per placement). - * Omit it to use the default placement. - * - * @since 0.1.0 - */ + /** Optional placement name configured in the LevelPlay dashboard (capping / pacing / reward per placement). */ placementName?: string; } -/** - * Options for `isReady()`: `adUnitId` (see AdUnitOptions) plus the format. - * - * @since 0.1.0 - */ export interface IsReadyOptions extends AdUnitOptions { - /** - * Format of the ad unit. - * - * @since 0.1.0 - */ format: AdFormat; } -/** - * Result of `isReady()`. - * - * @since 0.1.0 - */ export interface IsReadyResult { - /** - * `true` when a loaded ad can be shown right now. - * - * @since 0.1.0 - */ ready: boolean; } -/** - * The reward of a rewarded ad, as configured in the LevelPlay dashboard (per ad unit or placement). - * - * @since 0.1.0 - */ export interface Reward { - /** - * Name of the reward, for example `Coins`. - * - * @since 0.1.0 - */ name: string; - /** - * Amount of the reward. - * - * @since 0.1.0 - */ amount: number; } -/** - * Error reported by the SDK (load / display failures) or by the plugin. - * - * @since 0.1.0 - */ export interface AdError { - /** - * LevelPlay error code, for example `509` (no fill). `-1` is used by the plugin for "Ad not ready" and for the web - * stub. - * - * @since 0.1.0 - */ code: number; - /** - * Human readable message. - * - * @since 0.1.0 - */ message: string; } -/** - * Subset of the native `LevelPlayAdInfo` (Android) / `LPMAdInfo` (iOS) that is useful in JavaScript. - * Fields the SDK does not report are omitted. - * - * @since 0.1.0 - */ +/** Subset of the native `LevelPlayAdInfo` / `LPMAdInfo` that is useful in JavaScript. */ export interface AdInfo { - /** - * Unique id of this ad. - * - * @since 0.1.0 - */ adId?: string; - /** - * Ad unit id. - * - * @since 0.1.0 - */ adUnitId: string; - /** - * Ad unit name from the dashboard. - * - * @since 0.1.0 - */ adUnitName?: string; - /** - * Ad format as reported by the SDK. - * - * @since 0.1.0 - */ adFormat?: string; - /** - * Placement name of the show call, when one was used. - * - * @since 0.1.0 - */ placementName?: string; - /** - * Name of the mediated network that served the ad. - * - * @since 0.1.0 - */ adNetwork?: string; - /** - * Mediation instance name. - * - * @since 0.1.0 - */ instanceName?: string; - /** - * Mediation instance id. - * - * @since 0.1.0 - */ instanceId?: string; - /** - * Country code of the impression. - * - * @since 0.1.0 - */ country?: string; - /** - * Auction id. - * - * @since 0.1.0 - */ auctionId?: string; - /** - * Impression revenue in USD as reported by the SDK (may be absent or 0 before display). - * - * @since 0.1.0 - */ + /** Impression revenue in USD as reported by the SDK (may be absent before display). */ revenue?: number; - /** - * Revenue precision as reported by the SDK. - * - * @since 0.1.0 - */ precision?: string; } -/** - * Result of `showRewarded()` and `showInterstitial()`, resolved after the ad - * closed or failed to display. - * - * @since 0.1.0 - */ export interface ShowResult { - /** - * The ad was displayed (the `displayed` event fired). - * - * @since 0.1.0 - */ + /** The ad was displayed (`displayed` fired). */ shown: boolean; - /** - * Rewarded only: the reward callback fired for this show. Grant the reward only when this is `true`. - * Always `false` for interstitials. - * - * @since 0.1.0 - */ + /** Rewarded only: the reward callback fired for this show. Grant the reward only when this is true. */ rewarded: boolean; - /** - * The reward, present when `rewarded` is `true`. - * - * @since 0.1.0 - */ reward?: Reward; - /** - * Present when the ad was not ready (`code: -1`) or failed to display. - * - * @since 0.1.0 - */ + /** Present when the ad was not ready or failed to display. */ error?: AdError; - /** - * Info of the displayed ad. - * - * @since 0.1.0 - */ adInfo?: AdInfo; } -/** - * Payload of the `loaded`, `displayed`, `clicked` and `closed` events. - * - * @since 0.1.0 - */ export interface AdEvent { - /** - * Format of the ad unit that fired the event. - * - * @since 0.1.0 - */ format: AdFormat; - /** - * Ad unit that fired the event. - * - * @since 0.1.0 - */ adUnitId: string; - /** - * Ad info, when the SDK provides it (not on `loadFailed`). - * - * @since 0.1.0 - */ adInfo?: AdInfo; } -/** - * Payload of the `loadFailed` and `displayFailed` events: the AdEvent fields plus `error`. - * - * @since 0.1.0 - */ export interface AdErrorEvent extends AdEvent { - /** - * What went wrong. - * - * @since 0.1.0 - */ error: AdError; } -/** - * Payload of the `rewarded` event: the AdEvent fields plus `reward`. - * - * @since 0.1.0 - */ export interface AdRewardEvent extends AdEvent { - /** - * The reward earned. - * - * @since 0.1.0 - */ reward: Reward; } -/** - * iOS App Tracking Transparency status. `unavailable` on Android, on the web and on unknown future iOS values. - * - * @since 0.1.0 - */ export type TrackingStatus = 'authorized' | 'denied' | 'restricted' | 'notDetermined' | 'unavailable'; -/** - * Result of `requestTrackingAuthorization()` and - * `getTrackingAuthorizationStatus()`. - * - * @since 0.1.0 - */ export interface TrackingResult { - /** - * iOS App Tracking Transparency status. Always `unavailable` on Android and web. - * - * @since 0.1.0 - */ + /** iOS App Tracking Transparency status. Always `unavailable` on Android and web. */ status: TrackingStatus; } -/** - * Event names emitted by the plugin. - * - * @since 0.1.0 - */ -export type LevelPlayEventName = - | 'loaded' - | 'loadFailed' - | 'displayed' - | 'displayFailed' - | 'clicked' - | 'closed' - | 'rewarded'; - -/** - * Unity LevelPlay rewarded and interstitial ads (ad-unit API). - * - * @since 0.1.0 - */ export interface LevelPlayPlugin { /** - * 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. - * - * @since 0.1.0 + * Initialise the LevelPlay SDK. Resolves on `onInitSuccess`, rejects with the init error otherwise. + * Calling it again after a successful init resolves immediately. Load ads only after this resolves. */ initialize(options: InitOptions): Promise; - /** - * Native LevelPlay SDK version. Works before init. - * - * @since 0.1.0 - */ + /** Native SDK version (available before init). */ getSdkVersion(): Promise; - /** - * Forward GDPR / CCPA / COPPA signals to LevelPlay. Call it before `initialize()` when you - * can, and again whenever the user changes their choice. - * - * @since 0.1.0 - */ + /** Forward GDPR / CCPA / COPPA signals. Call before {@link initialize} when you can. */ setConsent(options: ConsentOptions): Promise; - /** - * Raw `LevelPlay.setMetaData(key, value)` for SDK or network-specific flags. Call it before init. - * - * @since 0.1.0 - */ + /** Raw `LevelPlay.setMetaData(key, value)` for network-specific flags. Call before init. */ setMetaData(options: MetaDataOptions): Promise; /** - * 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`. - * - * @since 0.1.0 + * iOS: show the App Tracking Transparency prompt (needs `NSUserTrackingUsageDescription` in Info.plist) and resolve + * with the resulting status. Call it before {@link initialize}. Android / web: resolves `unavailable`. */ requestTrackingAuthorization(): Promise; - /** - * Current App Tracking Transparency status without prompting (iOS). Android and web: `unavailable`. - * - * @since 0.1.0 - */ + /** Current ATT status without prompting (iOS). Android / web: `unavailable`. */ getTrackingAuthorizationStatus(): Promise; /** - * 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. - * - * @since 0.1.0 + * Start loading a rewarded ad for the ad unit (the ad object is created on first use and reused). + * Resolves once the request is issued; the outcome arrives as `loaded` / `loadFailed` events. */ loadRewarded(options: AdUnitOptions): Promise; /** - * 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. - * - * @since 0.1.0 + * Show a loaded rewarded ad. Resolves after the ad closes (or failed to display) with what happened. + * Never rejects for "not ready": resolves `{ shown: false, error }` instead. */ showRewarded(options: ShowOptions): Promise; - /** - * Start loading an interstitial ad for the ad unit. Works like `loadRewarded()`. - * - * @since 0.1.0 - */ + /** Start loading an interstitial ad (see {@link loadRewarded}). */ loadInterstitial(options: AdUnitOptions): Promise; - /** - * Show a loaded interstitial. Resolves after it closed (or failed to display). Never rejects for "not ready". - * - * @since 0.1.0 - */ + /** Show a loaded interstitial. Resolves after it closes (or failed to display). */ showInterstitial(options: ShowOptions): Promise; - /** - * `isAdReady()` of the native ad object for this ad unit. `false` when the ad unit was never loaded. - * - * @since 0.1.0 - */ + /** `isAdReady()` of the ad object for this ad unit (`false` when it was never loaded). */ isReady(options: IsReadyOptions): Promise; - /** - * Open the LevelPlay Integration Test Suite. Requires `initialize({ testSuite: true })` first. - * Development builds only. Rejects on the web. - * - * @since 0.1.0 - */ + /** Open the LevelPlay Integration Test Suite. Requires `initialize({ testSuite: true })` first. */ launchTestSuite(): Promise; - /** - * 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 - */ + /** Log the LevelPlay integration helper report to the native console (development only). */ validateIntegration(): Promise; - /** - * An ad finished loading for the ad unit and can be shown. - * - * @since 0.1.0 - */ addListener(eventName: 'loaded', listenerFunc: (event: AdEvent) => void): Promise; - - /** - * Loading failed, for example `509` (no fill). Retry later with a backoff. - * - * @since 0.1.0 - */ addListener(eventName: 'loadFailed', listenerFunc: (event: AdErrorEvent) => void): Promise; - - /** - * The ad was displayed (impression). `adInfo.revenue` is available here. - * - * @since 0.1.0 - */ addListener(eventName: 'displayed', listenerFunc: (event: AdEvent) => void): Promise; - - /** - * The ad failed to display. The pending show call resolves with the same error. - * - * @since 0.1.0 - */ - addListener( - eventName: 'displayFailed', - listenerFunc: (event: AdErrorEvent) => void, - ): Promise; - - /** - * The user clicked the ad. - * - * @since 0.1.0 - */ + addListener(eventName: 'displayFailed', listenerFunc: (event: AdErrorEvent) => void): Promise; addListener(eventName: 'clicked', listenerFunc: (event: AdEvent) => void): Promise; - - /** - * The ad was closed and the app is back in front. - * - * @since 0.1.0 - */ addListener(eventName: 'closed', listenerFunc: (event: AdEvent) => void): Promise; - - /** - * Rewarded only: the user earned the reward. Can fire before or after `closed`. - * - * @since 0.1.0 - */ addListener(eventName: 'rewarded', listenerFunc: (event: AdRewardEvent) => void): Promise; - /** - * Remove every listener of this plugin. - * - * @since 0.1.0 - */ removeAllListeners(): Promise; } + +/** Event names emitted by the plugin. */ +export type LevelPlayEventName = 'loaded' | 'loadFailed' | 'displayed' | 'displayFailed' | 'clicked' | 'closed' | 'rewarded'; diff --git a/tsconfig.json b/tsconfig.json index d074ff1..2bf6f98 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ "declaration": true, "esModuleInterop": true, "inlineSources": true, + "lib": ["dom", "es2017"], "module": "esnext", "moduleResolution": "node", "noFallthroughCasesInSwitch": true,