0.3.0 API design: banners, native ad templates, impression data, adInfoChanged, placement capping and rewards, segments, dynamic user id
docs/design-0.3.md maps every feature to the exact LevelPlay 9.6.1 Android and iOS classes (read from the AAR and xcframework headers), describes the WebView overlay, error codes, platform gaps, Capacitor 7 findings and the test plan. definitions.ts and web.ts carry the new typed API; native bridges follow in phase 2.
This commit is contained in:
parent
9cb0e74cf7
commit
7a187f5dd1
15 changed files with 6010 additions and 29 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added (API design for 0.3.0; Android and iOS bridges not implemented yet)
|
||||||
|
- `docs/design-0.3.md`: banner, native ad, impression data, placement, segment and dynamic user id design with the
|
||||||
|
exact LevelPlay 9.6.1 Android / iOS mappings, overlay positioning, error codes, Capacitor 7 findings, test plan.
|
||||||
|
- TypeScript API (`@since 0.3.0`): `getCapabilities`, `setSegment`, `setDynamicUserId`, `isPlacementCapped`,
|
||||||
|
`getReward`, `createBanner` / `loadBanner` / `showBanner` / `hideBanner` / `setBannerLayout` / `destroyBanner`,
|
||||||
|
`loadNativeAd` / `showNativeAd` / `setNativeAdRect` / `hideNativeAd` / `destroyNativeAd`; events `adInfoChanged`,
|
||||||
|
`impressionData`, `banner*` and `nativeAd*`.
|
||||||
|
- `AdInfo` gains optional `ab`, `segmentName`, `encryptedCPM`, `creativeId`, `conversionValue` (iOS) and `adSize`.
|
||||||
|
- Web stubs for every new method.
|
||||||
|
|
||||||
## [0.2.1] - 2026-10-10
|
## [0.2.1] - 2026-10-10
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
||||||
2249
dist/docs.json
vendored
2249
dist/docs.json
vendored
File diff suppressed because it is too large
Load diff
1005
dist/esm/definitions.d.ts
vendored
1005
dist/esm/definitions.d.ts
vendored
File diff suppressed because it is too large
Load diff
2
dist/esm/definitions.js.map
vendored
2
dist/esm/definitions.js.map
vendored
File diff suppressed because one or more lines are too long
22
dist/esm/web.d.ts
vendored
22
dist/esm/web.d.ts
vendored
|
|
@ -1,8 +1,12 @@
|
||||||
import { WebPlugin } from '@capacitor/core';
|
import { WebPlugin } from '@capacitor/core';
|
||||||
import type { AdUnitOptions, ConsentOptions, InitOptions, InitResult, IsReadyResult, LevelPlayPlugin, MetaDataOptions, ShowResult, TrackingResult } from './definitions';
|
import type { AdUnitOptions, BannerIdOptions, BannerResult, Capabilities, ConsentOptions, CreateBannerOptions, DynamicUserIdOptions, DynamicUserIdResult, GetRewardOptions, InitOptions, InitResult, IsReadyResult, LevelPlayPlugin, LoadNativeAdOptions, MetaDataOptions, NativeAdIdOptions, NativeAdRectOptions, PlacementCappedOptions, PlacementCappedResult, Reward, SegmentOptions, SetBannerLayoutOptions, ShowResult, TrackingResult } from './definitions';
|
||||||
/**
|
/**
|
||||||
* Web stub. LevelPlay has no web SDK: init rejects with `unimplemented`, ads are never ready and every show resolves
|
* Web stub. LevelPlay has no web SDK: init rejects with `unimplemented`, ads are never ready and every show resolves
|
||||||
* as "not shown" so callers can treat the web like a no-fill platform without special casing.
|
* as "not shown" so callers can treat the web like a no-fill platform without special casing.
|
||||||
|
*
|
||||||
|
* 0.3.0: `getCapabilities()` reports nothing supported. Setters, loads of things that cannot exist, hide and destroy
|
||||||
|
* are no-ops; calls that would have to return a native view (`createBanner`, `showBanner`, `setBannerLayout`,
|
||||||
|
* `loadNativeAd`, `showNativeAd`) reject as unimplemented, like `initialize`.
|
||||||
*/
|
*/
|
||||||
export declare class LevelPlayWeb extends WebPlugin implements LevelPlayPlugin {
|
export declare class LevelPlayWeb extends WebPlugin implements LevelPlayPlugin {
|
||||||
private static readonly NO_FILL;
|
private static readonly NO_FILL;
|
||||||
|
|
@ -19,4 +23,20 @@ export declare class LevelPlayWeb extends WebPlugin implements LevelPlayPlugin {
|
||||||
isReady(): Promise<IsReadyResult>;
|
isReady(): Promise<IsReadyResult>;
|
||||||
launchTestSuite(): Promise<void>;
|
launchTestSuite(): Promise<void>;
|
||||||
validateIntegration(): Promise<void>;
|
validateIntegration(): Promise<void>;
|
||||||
|
getCapabilities(): Promise<Capabilities>;
|
||||||
|
setSegment(_options: SegmentOptions): Promise<void>;
|
||||||
|
setDynamicUserId(_options: DynamicUserIdOptions): Promise<DynamicUserIdResult>;
|
||||||
|
isPlacementCapped(_options: PlacementCappedOptions): Promise<PlacementCappedResult>;
|
||||||
|
getReward(_options: GetRewardOptions): Promise<Reward>;
|
||||||
|
createBanner(_options: CreateBannerOptions): Promise<BannerResult>;
|
||||||
|
loadBanner(_options: BannerIdOptions): Promise<void>;
|
||||||
|
showBanner(_options: BannerIdOptions): Promise<BannerResult>;
|
||||||
|
hideBanner(_options: BannerIdOptions): Promise<void>;
|
||||||
|
setBannerLayout(_options: SetBannerLayoutOptions): Promise<BannerResult>;
|
||||||
|
destroyBanner(_options: BannerIdOptions): Promise<void>;
|
||||||
|
loadNativeAd(_options: LoadNativeAdOptions): Promise<void>;
|
||||||
|
showNativeAd(_options: NativeAdRectOptions): Promise<void>;
|
||||||
|
setNativeAdRect(_options: NativeAdRectOptions): Promise<void>;
|
||||||
|
hideNativeAd(_options: NativeAdIdOptions): Promise<void>;
|
||||||
|
destroyNativeAd(_options: NativeAdIdOptions): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
52
dist/esm/web.js
vendored
52
dist/esm/web.js
vendored
|
|
@ -2,6 +2,10 @@ import { WebPlugin } from '@capacitor/core';
|
||||||
/**
|
/**
|
||||||
* Web stub. LevelPlay has no web SDK: init rejects with `unimplemented`, ads are never ready and every show resolves
|
* Web stub. LevelPlay has no web SDK: init rejects with `unimplemented`, ads are never ready and every show resolves
|
||||||
* as "not shown" so callers can treat the web like a no-fill platform without special casing.
|
* as "not shown" so callers can treat the web like a no-fill platform without special casing.
|
||||||
|
*
|
||||||
|
* 0.3.0: `getCapabilities()` reports nothing supported. Setters, loads of things that cannot exist, hide and destroy
|
||||||
|
* are no-ops; calls that would have to return a native view (`createBanner`, `showBanner`, `setBannerLayout`,
|
||||||
|
* `loadNativeAd`, `showNativeAd`) reject as unimplemented, like `initialize`.
|
||||||
*/
|
*/
|
||||||
export class LevelPlayWeb extends WebPlugin {
|
export class LevelPlayWeb extends WebPlugin {
|
||||||
async initialize(_options) {
|
async initialize(_options) {
|
||||||
|
|
@ -43,6 +47,54 @@ export class LevelPlayWeb extends WebPlugin {
|
||||||
async validateIntegration() {
|
async validateIntegration() {
|
||||||
/* nothing to validate */
|
/* nothing to validate */
|
||||||
}
|
}
|
||||||
|
async getCapabilities() {
|
||||||
|
return { banner: false, nativeAd: false, nativeAdTemplates: [], impressionData: false, adInfoChanged: false };
|
||||||
|
}
|
||||||
|
async setSegment(_options) {
|
||||||
|
/* nothing to forward */
|
||||||
|
}
|
||||||
|
async setDynamicUserId(_options) {
|
||||||
|
return { valid: false };
|
||||||
|
}
|
||||||
|
async isPlacementCapped(_options) {
|
||||||
|
return { capped: false };
|
||||||
|
}
|
||||||
|
async getReward(_options) {
|
||||||
|
return { name: '', amount: 0 };
|
||||||
|
}
|
||||||
|
async createBanner(_options) {
|
||||||
|
throw this.unimplemented('LevelPlay banners are not available on the web.');
|
||||||
|
}
|
||||||
|
async loadBanner(_options) {
|
||||||
|
/* never fills */
|
||||||
|
}
|
||||||
|
async showBanner(_options) {
|
||||||
|
throw this.unimplemented('LevelPlay banners are not available on the web.');
|
||||||
|
}
|
||||||
|
async hideBanner(_options) {
|
||||||
|
/* nothing shown */
|
||||||
|
}
|
||||||
|
async setBannerLayout(_options) {
|
||||||
|
throw this.unimplemented('LevelPlay banners are not available on the web.');
|
||||||
|
}
|
||||||
|
async destroyBanner(_options) {
|
||||||
|
/* nothing to destroy */
|
||||||
|
}
|
||||||
|
async loadNativeAd(_options) {
|
||||||
|
throw this.unimplemented('LevelPlay native ads are not available on the web.');
|
||||||
|
}
|
||||||
|
async showNativeAd(_options) {
|
||||||
|
throw this.unimplemented('LevelPlay native ads are not available on the web.');
|
||||||
|
}
|
||||||
|
async setNativeAdRect(_options) {
|
||||||
|
/* nothing shown */
|
||||||
|
}
|
||||||
|
async hideNativeAd(_options) {
|
||||||
|
/* nothing shown */
|
||||||
|
}
|
||||||
|
async destroyNativeAd(_options) {
|
||||||
|
/* nothing to destroy */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LevelPlayWeb.NO_FILL = {
|
LevelPlayWeb.NO_FILL = {
|
||||||
shown: false,
|
shown: false,
|
||||||
|
|
|
||||||
2
dist/esm/web.js.map
vendored
2
dist/esm/web.js.map
vendored
File diff suppressed because one or more lines are too long
52
dist/plugin.cjs.js
vendored
52
dist/plugin.cjs.js
vendored
|
|
@ -28,6 +28,10 @@ const LevelPlay = core.registerPlugin('LevelPlay', {
|
||||||
/**
|
/**
|
||||||
* Web stub. LevelPlay has no web SDK: init rejects with `unimplemented`, ads are never ready and every show resolves
|
* Web stub. LevelPlay has no web SDK: init rejects with `unimplemented`, ads are never ready and every show resolves
|
||||||
* as "not shown" so callers can treat the web like a no-fill platform without special casing.
|
* as "not shown" so callers can treat the web like a no-fill platform without special casing.
|
||||||
|
*
|
||||||
|
* 0.3.0: `getCapabilities()` reports nothing supported. Setters, loads of things that cannot exist, hide and destroy
|
||||||
|
* are no-ops; calls that would have to return a native view (`createBanner`, `showBanner`, `setBannerLayout`,
|
||||||
|
* `loadNativeAd`, `showNativeAd`) reject as unimplemented, like `initialize`.
|
||||||
*/
|
*/
|
||||||
class LevelPlayWeb extends core.WebPlugin {
|
class LevelPlayWeb extends core.WebPlugin {
|
||||||
async initialize(_options) {
|
async initialize(_options) {
|
||||||
|
|
@ -69,6 +73,54 @@ class LevelPlayWeb extends core.WebPlugin {
|
||||||
async validateIntegration() {
|
async validateIntegration() {
|
||||||
/* nothing to validate */
|
/* nothing to validate */
|
||||||
}
|
}
|
||||||
|
async getCapabilities() {
|
||||||
|
return { banner: false, nativeAd: false, nativeAdTemplates: [], impressionData: false, adInfoChanged: false };
|
||||||
|
}
|
||||||
|
async setSegment(_options) {
|
||||||
|
/* nothing to forward */
|
||||||
|
}
|
||||||
|
async setDynamicUserId(_options) {
|
||||||
|
return { valid: false };
|
||||||
|
}
|
||||||
|
async isPlacementCapped(_options) {
|
||||||
|
return { capped: false };
|
||||||
|
}
|
||||||
|
async getReward(_options) {
|
||||||
|
return { name: '', amount: 0 };
|
||||||
|
}
|
||||||
|
async createBanner(_options) {
|
||||||
|
throw this.unimplemented('LevelPlay banners are not available on the web.');
|
||||||
|
}
|
||||||
|
async loadBanner(_options) {
|
||||||
|
/* never fills */
|
||||||
|
}
|
||||||
|
async showBanner(_options) {
|
||||||
|
throw this.unimplemented('LevelPlay banners are not available on the web.');
|
||||||
|
}
|
||||||
|
async hideBanner(_options) {
|
||||||
|
/* nothing shown */
|
||||||
|
}
|
||||||
|
async setBannerLayout(_options) {
|
||||||
|
throw this.unimplemented('LevelPlay banners are not available on the web.');
|
||||||
|
}
|
||||||
|
async destroyBanner(_options) {
|
||||||
|
/* nothing to destroy */
|
||||||
|
}
|
||||||
|
async loadNativeAd(_options) {
|
||||||
|
throw this.unimplemented('LevelPlay native ads are not available on the web.');
|
||||||
|
}
|
||||||
|
async showNativeAd(_options) {
|
||||||
|
throw this.unimplemented('LevelPlay native ads are not available on the web.');
|
||||||
|
}
|
||||||
|
async setNativeAdRect(_options) {
|
||||||
|
/* nothing shown */
|
||||||
|
}
|
||||||
|
async hideNativeAd(_options) {
|
||||||
|
/* nothing shown */
|
||||||
|
}
|
||||||
|
async destroyNativeAd(_options) {
|
||||||
|
/* nothing to destroy */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LevelPlayWeb.NO_FILL = {
|
LevelPlayWeb.NO_FILL = {
|
||||||
shown: false,
|
shown: false,
|
||||||
|
|
|
||||||
2
dist/plugin.cjs.js.map
vendored
2
dist/plugin.cjs.js.map
vendored
File diff suppressed because one or more lines are too long
52
dist/plugin.js
vendored
52
dist/plugin.js
vendored
|
|
@ -27,6 +27,10 @@ var capacitorLevelPlay = (function (exports, core) {
|
||||||
/**
|
/**
|
||||||
* Web stub. LevelPlay has no web SDK: init rejects with `unimplemented`, ads are never ready and every show resolves
|
* Web stub. LevelPlay has no web SDK: init rejects with `unimplemented`, ads are never ready and every show resolves
|
||||||
* as "not shown" so callers can treat the web like a no-fill platform without special casing.
|
* as "not shown" so callers can treat the web like a no-fill platform without special casing.
|
||||||
|
*
|
||||||
|
* 0.3.0: `getCapabilities()` reports nothing supported. Setters, loads of things that cannot exist, hide and destroy
|
||||||
|
* are no-ops; calls that would have to return a native view (`createBanner`, `showBanner`, `setBannerLayout`,
|
||||||
|
* `loadNativeAd`, `showNativeAd`) reject as unimplemented, like `initialize`.
|
||||||
*/
|
*/
|
||||||
class LevelPlayWeb extends core.WebPlugin {
|
class LevelPlayWeb extends core.WebPlugin {
|
||||||
async initialize(_options) {
|
async initialize(_options) {
|
||||||
|
|
@ -68,6 +72,54 @@ var capacitorLevelPlay = (function (exports, core) {
|
||||||
async validateIntegration() {
|
async validateIntegration() {
|
||||||
/* nothing to validate */
|
/* nothing to validate */
|
||||||
}
|
}
|
||||||
|
async getCapabilities() {
|
||||||
|
return { banner: false, nativeAd: false, nativeAdTemplates: [], impressionData: false, adInfoChanged: false };
|
||||||
|
}
|
||||||
|
async setSegment(_options) {
|
||||||
|
/* nothing to forward */
|
||||||
|
}
|
||||||
|
async setDynamicUserId(_options) {
|
||||||
|
return { valid: false };
|
||||||
|
}
|
||||||
|
async isPlacementCapped(_options) {
|
||||||
|
return { capped: false };
|
||||||
|
}
|
||||||
|
async getReward(_options) {
|
||||||
|
return { name: '', amount: 0 };
|
||||||
|
}
|
||||||
|
async createBanner(_options) {
|
||||||
|
throw this.unimplemented('LevelPlay banners are not available on the web.');
|
||||||
|
}
|
||||||
|
async loadBanner(_options) {
|
||||||
|
/* never fills */
|
||||||
|
}
|
||||||
|
async showBanner(_options) {
|
||||||
|
throw this.unimplemented('LevelPlay banners are not available on the web.');
|
||||||
|
}
|
||||||
|
async hideBanner(_options) {
|
||||||
|
/* nothing shown */
|
||||||
|
}
|
||||||
|
async setBannerLayout(_options) {
|
||||||
|
throw this.unimplemented('LevelPlay banners are not available on the web.');
|
||||||
|
}
|
||||||
|
async destroyBanner(_options) {
|
||||||
|
/* nothing to destroy */
|
||||||
|
}
|
||||||
|
async loadNativeAd(_options) {
|
||||||
|
throw this.unimplemented('LevelPlay native ads are not available on the web.');
|
||||||
|
}
|
||||||
|
async showNativeAd(_options) {
|
||||||
|
throw this.unimplemented('LevelPlay native ads are not available on the web.');
|
||||||
|
}
|
||||||
|
async setNativeAdRect(_options) {
|
||||||
|
/* nothing shown */
|
||||||
|
}
|
||||||
|
async hideNativeAd(_options) {
|
||||||
|
/* nothing shown */
|
||||||
|
}
|
||||||
|
async destroyNativeAd(_options) {
|
||||||
|
/* nothing to destroy */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LevelPlayWeb.NO_FILL = {
|
LevelPlayWeb.NO_FILL = {
|
||||||
shown: false,
|
shown: false,
|
||||||
|
|
|
||||||
2
dist/plugin.js.map
vendored
2
dist/plugin.js.map
vendored
File diff suppressed because one or more lines are too long
446
docs/design-0.3.md
Normal file
446
docs/design-0.3.md
Normal file
|
|
@ -0,0 +1,446 @@
|
||||||
|
# capacitor-levelplay 0.3.0 · API design
|
||||||
|
|
||||||
|
Status: phase 1 (API design). `src/definitions.ts` and `src/web.ts` carry the new API; Android and iOS bridges are
|
||||||
|
not implemented yet. Until they are, calling a new method on a device rejects with Capacitor's `UNIMPLEMENTED`.
|
||||||
|
|
||||||
|
Scope (owner approved): banners, native ads (template overlay), impression-level revenue, `adInfoChanged`, placement
|
||||||
|
capping and reward lookup, segments, dynamic user id, full backwards compatibility with 0.2.x, and a Capacitor 7
|
||||||
|
compatibility study.
|
||||||
|
|
||||||
|
## 0. Sources and method
|
||||||
|
|
||||||
|
Every native name below was read from the SDK binaries of **LevelPlay 9.6.1**, not only from the docs:
|
||||||
|
|
||||||
|
- **Android**: `com.unity3d.ads-mediation:mediation-sdk:9.6.1` AAR from Maven Central, `classes.jar` listed with
|
||||||
|
`javap -public` (JDK 21). The AAR manifest declares `minSdkVersion="19"`.
|
||||||
|
- **iOS**: `IronSource.xcframework` (`CFBundleShortVersionString` 9.6.1, `MinimumOSVersion` 12.0) from the
|
||||||
|
`LevelPlay-Swift-Package` SPM checkout, `ios-arm64/IronSource.framework/Headers/*.h`. `IronSource.h` defines
|
||||||
|
`MEDIATION_SDK_VERSION = @"9.6.1"`. The framework ships no `.swiftinterface`; Swift names come from
|
||||||
|
`NS_SWIFT_NAME` annotations and the ObjC importer.
|
||||||
|
- Unity docs (behaviour, not names): `docs.unity.com/en-us/grow/levelplay/sdk/{android,ios}/banner-integration`,
|
||||||
|
`.../android/native-ads-integration`, `.../flutter/native-ads-integration`.
|
||||||
|
- Capacitor: `@capacitor/android` and `@capacitor/ios` 7.6.9 and 8.5.3 npm tarballs, diffed.
|
||||||
|
|
||||||
|
Notation: `A:` Android (package `com.unity3d.mediation` unless a full name is given), `I:` iOS (header file name).
|
||||||
|
|
||||||
|
## 1. Compatibility rules for 0.3.0
|
||||||
|
|
||||||
|
- No existing method, option, event or type is renamed or removed. `AdFormat` stays `'rewarded' | 'interstitial'`
|
||||||
|
(widening it would break exhaustive `switch` statements in 0.2.x code), so banners and native ads get their own
|
||||||
|
methods and their own event names (`banner*`, `nativeAd*`) instead of reusing `loaded`, `clicked` ...
|
||||||
|
- `AdInfo` only gains optional fields. `LevelPlayEventName` only gains members.
|
||||||
|
- Existing events keep their payloads; `adInfoChanged` and `impressionData` are new names.
|
||||||
|
- Reject codes reuse the existing string style (`INVALID_ARGUMENT`, `NO_VIEW_CONTROLLER`).
|
||||||
|
|
||||||
|
## 2. Capabilities
|
||||||
|
|
||||||
|
`getCapabilities(): Promise<Capabilities>` → `{ banner, nativeAd, nativeAdTemplates, impressionData, adInfoChanged }`.
|
||||||
|
|
||||||
|
| | Android | iOS | Web |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `banner` | true | true | false |
|
||||||
|
| `nativeAd` | true | true | false |
|
||||||
|
| `nativeAdTemplates` | `['small','medium']` | `['small','medium']` | `[]` |
|
||||||
|
| `impressionData` | true | true | false |
|
||||||
|
| `adInfoChanged` | true | true | false |
|
||||||
|
|
||||||
|
It is the honest switch the owner asked for: if a platform implementation ever has to drop a feature (for example
|
||||||
|
templates do not pass review on one OS), the flag goes `false` and the methods reject `UNSUPPORTED`, without an API
|
||||||
|
change.
|
||||||
|
|
||||||
|
## 3. Banners
|
||||||
|
|
||||||
|
### 3.1 TS API
|
||||||
|
|
||||||
|
```ts
|
||||||
|
createBanner({ adUnitId, bannerId?, size?: 'BANNER'|'LARGE'|'MEDIUM_RECTANGLE'|'LEADERBOARD'|'ADAPTIVE',
|
||||||
|
adaptiveWidth?, placementName?, bidFloor?, position?: 'top'|'bottom'|'center',
|
||||||
|
offsetX?, offsetY?, respectSafeArea? }): Promise<BannerResult>
|
||||||
|
loadBanner({ bannerId }): Promise<void>
|
||||||
|
showBanner({ bannerId }): Promise<BannerResult>
|
||||||
|
hideBanner({ bannerId }): Promise<void>
|
||||||
|
setBannerLayout({ bannerId, position?, offsetX?, offsetY?, respectSafeArea? }): Promise<BannerResult>
|
||||||
|
destroyBanner({ bannerId }): Promise<void>
|
||||||
|
// BannerResult = { bannerId, adSize: { width, height, description?, isAdaptive? }, frame: Rect, visible }
|
||||||
|
```
|
||||||
|
|
||||||
|
Defaults: `bannerId = adUnitId`, `size = 'ADAPTIVE'`, `position = 'bottom'`, offsets 0, `respectSafeArea = true`.
|
||||||
|
Several banners can exist at once, keyed by `bannerId` (one ad unit may back several banners).
|
||||||
|
|
||||||
|
Typical flow: `createBanner` → `loadBanner` → `showBanner` (immediately, or on `bannerLoaded`) → `hideBanner` during
|
||||||
|
gameplay → `showBanner` → `destroyBanner` when leaving the screen.
|
||||||
|
|
||||||
|
### 3.2 Native mapping
|
||||||
|
|
||||||
|
| Plugin | Android (`com.unity3d.mediation.banner`) | iOS |
|
||||||
|
|---|---|---|
|
||||||
|
| view class | `LevelPlayBannerAdView extends FrameLayout`, ctor `(Context, String adUnitId, LevelPlayBannerAdView.Config)` | `LPMBannerAdView : UIView`, `initWithAdUnitId:config:` (LPMBannerAdView.h) |
|
||||||
|
| config | `LevelPlayBannerAdView.Config.Builder().setAdSize(LevelPlayAdSize).setBidFloor(double).setPlacementName(String).build()` | `LPMBannerAdViewConfigBuilder` `set(adSize:)`, `set(bidFloor:)` (NSNumber), `set(placementName:)`, `build()` |
|
||||||
|
| `BANNER` | `LevelPlayAdSize.BANNER` | `LPMAdSize.bannerSize()` |
|
||||||
|
| `LARGE` | `LevelPlayAdSize.LARGE` | `LPMAdSize.largeSize()` |
|
||||||
|
| `MEDIUM_RECTANGLE` | `LevelPlayAdSize.MEDIUM_RECTANGLE` | `LPMAdSize.mediumRectangleSize()` |
|
||||||
|
| `LEADERBOARD` | `LevelPlayAdSize.LEADERBOARD` | `LPMAdSize.leaderBoardSize()` |
|
||||||
|
| `ADAPTIVE` | `LevelPlayAdSize.createAdaptiveAdSize(Context, Integer width)` | `LPMAdSize.createAdaptiveAdSize(withWidth: CGFloat)` (nullable: `nil` before init) |
|
||||||
|
| size readout | `getWidth()`, `getHeight()`, `getDescription()`, `isAdaptive()` | `width`, `height`, `sizeDescription`, `isAdaptive` |
|
||||||
|
| listener | `setBannerListener(LevelPlayBannerAdViewListener)` | `setDelegate(LPMBannerAdViewDelegate)` |
|
||||||
|
| impression data | `setImpressionDataListener(LevelPlayImpressionDataListener)` | `setImpressionDataDelegate:` |
|
||||||
|
| load | `loadAd()` (Activity context from the ctor) | `loadAdWithViewController:` (`bridge.viewController`) |
|
||||||
|
| show / hide | `setVisibility(VISIBLE/GONE)` + `resumeAutoRefresh()` / `pauseAutoRefresh()` | `isHidden` + `resumeAutoRefresh` / `pauseAutoRefresh` |
|
||||||
|
| destroy | `destroy()` then remove from parent | `destroy` then `removeFromSuperview` |
|
||||||
|
|
||||||
|
The SDK has no show / hide API; visibility is the host view's job. Unity's docs say pause / resume only matter when a
|
||||||
|
refresh interval is set on the dashboard, and that a resumed banner completes the remaining refresh time. Android's
|
||||||
|
`IronSourceError.ERROR_BN_RELOAD_SKIP_INVISIBLE` shows the SDK itself skips refreshes of invisible banners; pausing
|
||||||
|
explicitly makes that deterministic on both platforms.
|
||||||
|
|
||||||
|
Adaptive width units: the plugin passes CSS px. On Android 1 CSS px = 1 dp in a Capacitor WebView at default zoom;
|
||||||
|
the `Integer` width is treated as dp (to be confirmed in the phase-2 test; see §14 Q3). On iOS 1 CSS px = 1 pt.
|
||||||
|
Both factories need a finished init (iOS returns `nil` before init, documented in LPMAdSize.h), so `createBanner`
|
||||||
|
rejects `NOT_INITIALIZED` before `initialize()` resolved. Unity's docs also say to create banners only after init
|
||||||
|
succeeded.
|
||||||
|
|
||||||
|
### 3.3 Banner events
|
||||||
|
|
||||||
|
| Event | Android `LevelPlayBannerAdViewListener` | iOS `LPMBannerAdViewDelegate` |
|
||||||
|
|---|---|---|
|
||||||
|
| `bannerLoaded` | `onAdLoaded(LevelPlayAdInfo)` | `didLoadAdWithAdInfo:` (required) |
|
||||||
|
| `bannerLoadFailed` | `onAdLoadFailed(LevelPlayAdError)` | `didFailToLoadAdWithAdUnitId:error:` (required) |
|
||||||
|
| `bannerDisplayed` | `onAdDisplayed` (default method) | `didDisplayAdWithAdInfo:` (optional) |
|
||||||
|
| `bannerDisplayFailed` | `onAdDisplayFailed(LevelPlayAdInfo, LevelPlayAdError)` | `didFailToDisplayAdWithAdInfo:error:` |
|
||||||
|
| `bannerClicked` | `onAdClicked` | `didClickAdWithAdInfo:` |
|
||||||
|
| `bannerExpanded` | `onAdExpanded` | `didExpandAdWithAdInfo:` |
|
||||||
|
| `bannerCollapsed` | `onAdCollapsed` | `didCollapseAdWithAdInfo:` |
|
||||||
|
| `bannerLeftApplication` | `onAdLeftApplication` | `didLeaveAppWithAdInfo:` |
|
||||||
|
|
||||||
|
Payload: `BannerEvent { bannerId, adUnitId, adInfo?, frame? }`, plus `error` for the two failure events. All eight
|
||||||
|
callbacks exist on both platforms in 9.6.1. There is **no** `adInfoChanged` callback for banners on either platform.
|
||||||
|
|
||||||
|
## 4. Native ads
|
||||||
|
|
||||||
|
### 4.1 What 9.6.1 has
|
||||||
|
|
||||||
|
- Android: `com.ironsource.mediationsdk.ads.nativead.LevelPlayNativeAd`, built with
|
||||||
|
`new LevelPlayNativeAd.Builder().withPlacementName(String).withListener(LevelPlayNativeAdListener).withActivity(Activity).build()`;
|
||||||
|
`loadAd()`, `destroyAd()`, asset getters `getTitle()`, `getAdvertiser()`, `getBody()`, `getCallToAction()`,
|
||||||
|
`getIcon()` (`NativeAdDataInterface.Image`). Views: `NativeAdLayout extends FrameLayout` with `setTitleView`,
|
||||||
|
`setAdvertiserView`, `setBodyView`, `setIconView`, `setCallToActionView`, `setMediaView(LevelPlayMediaView)`,
|
||||||
|
`registerNativeAdViews(LevelPlayNativeAd)`. Listener (`LevelPlayNativeAdListener` = `NativeAdLoadListener` +
|
||||||
|
`NativeAdInteractionListener`): `onAdLoaded(ad, AdInfo)`, `onAdLoadFailed(ad, IronSourceError)`,
|
||||||
|
`onAdImpression(ad, AdInfo)`, `onAdClicked(ad, AdInfo)`. `AdInfo` is `com.ironsource.mediationsdk.adunit.adapter.utility.AdInfo`.
|
||||||
|
- iOS: `LevelPlayNativeAd` (`initWithBuilder:`, `loadAd`, `destroyAd`, `setDelegate:`, asset properties `title`,
|
||||||
|
`advertiser`, `body`, `callToAction`, `icon` (`ISNativeAdDataImage` with `image` / `url`)), `LevelPlayNativeAdBuilder`
|
||||||
|
(`withViewController:`, `withPlacementName:`, `withDelegate:`, `build`), view `ISNativeAdView : UIView` with outlets
|
||||||
|
`adAppIcon`, `adTitleView`, `adAdvertiserView`, `adBodyView`, `adMediaView` (`LevelPlayMediaView`),
|
||||||
|
`adCallToActionView` and `registerNativeAdViews:`. Delegate `LevelPlayNativeAdDelegate` =
|
||||||
|
`ISNativeAdLoadDelegate` (`didLoad:withAdInfo:`, `didFailToLoad:withError:`) + `ISNativeAdInteractionDelegate`
|
||||||
|
(`didRecordImpression:withAdInfo:`, `didClick:withAdInfo:`), with `ISAdInfo`.
|
||||||
|
|
||||||
|
Findings that shape the API:
|
||||||
|
|
||||||
|
1. **No template views in the SDK on either platform.** There is no `LevelPlayNativeAdTemplate`, template type or
|
||||||
|
template layout resource in the AAR (its `res/` has only `values/`) or in the iOS headers. Unity's Flutter and
|
||||||
|
React Native wrappers ship their own XML (Android) and XIB (iOS) templates (`LevelPlayTemplateType.SMALL` /
|
||||||
|
`MEDIUM`). This plugin does the same: it owns two programmatic layouts per platform, `small` (no media view) and
|
||||||
|
`medium` (with `LevelPlayMediaView`). `nativeAdSupported` is therefore `true` on both platforms, with the
|
||||||
|
rendering being the plugin's code.
|
||||||
|
2. **Native ads have no ad unit id in 9.6.1.** Both builders take a placement name only. The API exposes
|
||||||
|
`placementName`, not `adUnitId`, and says so.
|
||||||
|
3. **One ad object per load.** Unity: "destroy the ad object and create a new one for every new load". So
|
||||||
|
`loadNativeAd` replaces the slot's previous ad.
|
||||||
|
4. **Native ad info is the old `AdInfo` / `ISAdInfo`** (auction id, network, instance, country, revenue, precision,
|
||||||
|
ab, segment, encrypted CPM; iOS adds `conversion_value`). No ad unit, ad id or placement in it. Hence a separate
|
||||||
|
`NativeAdInfo` type instead of reusing `AdInfo` (whose `adUnitId` is required).
|
||||||
|
5. **No per-ad impression-data listener for native ads** (only banners, interstitials and rewarded have
|
||||||
|
`setImpressionDataListener` / `setImpressionDataDelegate:`). See §5 for how `impressionData` still covers them.
|
||||||
|
6. Policy from Unity's guide: the ad must be marked as an ad, and the privacy / AdChoices icon belongs in the bottom
|
||||||
|
left. Both templates draw an "Ad" badge and leave the bottom-left corner free.
|
||||||
|
|
||||||
|
### 4.2 TS API
|
||||||
|
|
||||||
|
```ts
|
||||||
|
loadNativeAd({ nativeAdId, placementName?, template?: 'small'|'medium', style?: NativeAdTemplateStyle }): Promise<void>
|
||||||
|
showNativeAd({ nativeAdId, rect: { x, y, width, height } }): Promise<void>
|
||||||
|
setNativeAdRect({ nativeAdId, rect }): Promise<void>
|
||||||
|
hideNativeAd({ nativeAdId }): Promise<void>
|
||||||
|
destroyNativeAd({ nativeAdId }): Promise<void>
|
||||||
|
// events: nativeAdLoaded, nativeAdLoadFailed, nativeAdImpression, nativeAdClicked (NativeAdEvent / NativeAdErrorEvent)
|
||||||
|
```
|
||||||
|
|
||||||
|
`style`: `backgroundColor`, `titleColor`, `bodyColor`, `callToActionBackgroundColor`, `callToActionTextColor`
|
||||||
|
(`#RRGGBB[AA]`), `cornerRadius` (CSS px). Text uses the system font; the CTA is a native button so the SDK can
|
||||||
|
register it.
|
||||||
|
|
||||||
|
Flow: `loadNativeAd` → `nativeAdLoaded` → measure a placeholder element (`getBoundingClientRect()`) →
|
||||||
|
`showNativeAd({ rect })` → on layout change `setNativeAdRect` → `destroyNativeAd`, or `loadNativeAd` again for a new
|
||||||
|
creative.
|
||||||
|
|
||||||
|
Mapping: build → `loadAd`; on show, inflate the template into a `NativeAdLayout` / `ISNativeAdView`, fill the
|
||||||
|
asset views from the getters, call the `set*View` setters (Android) / assign the outlets (iOS) and
|
||||||
|
`registerNativeAdViews`, then place it in the overlay (§6). `destroyNativeAd` → `destroyAd()` + remove view.
|
||||||
|
|
||||||
|
## 5. Impression-level revenue: `impressionData`
|
||||||
|
|
||||||
|
### 5.1 API
|
||||||
|
|
||||||
|
`addListener('impressionData', (d: ImpressionData) => ...)`. Payload fields map 1:1 to the SDK data classes:
|
||||||
|
|
||||||
|
| `ImpressionData` | Android `LevelPlayImpressionData` | iOS `LPMImpressionData` |
|
||||||
|
|---|---|---|
|
||||||
|
| `auctionId` | `getAuctionId()` | `auctionId` |
|
||||||
|
| `adUnitId` | `getMediationAdUnitId()` | `mediationAdUnitId` |
|
||||||
|
| `adUnitName` | `getMediationAdUnitName()` | `mediationAdUnitName` |
|
||||||
|
| `adFormat` | `getAdFormat()` | `adFormat` |
|
||||||
|
| `adNetwork` | `getAdNetwork()` | `adNetwork` |
|
||||||
|
| `instanceName` | `getInstanceName()` | `instanceName` |
|
||||||
|
| `instanceId` | `getInstanceId()` | `instanceId` |
|
||||||
|
| `country` | `getCountry()` | `country` |
|
||||||
|
| `placement` | `getPlacement()` | `placement` |
|
||||||
|
| `revenue` | `getRevenue()` (`Double`, nullable) | `revenue` (`NSNumber`) |
|
||||||
|
| `precision` | `getPrecision()` | `precision` |
|
||||||
|
| `ab` | `getAb()` | `ab` |
|
||||||
|
| `segmentName` | `getSegmentName()` | `segmentName` |
|
||||||
|
| `encryptedCPM` | `getEncryptedCPM()` | `encryptedCpm` |
|
||||||
|
| `creativeId` | `getCreativeId()` | `creativeId` |
|
||||||
|
| `conversionValue` | not in the class | `conversionValue` (`NSNumber`) |
|
||||||
|
| `allData` | `getAllData()` (`JSONObject`) | `allData` (`NSDictionary`) |
|
||||||
|
|
||||||
|
**Not available: `lifetimeRevenue`.** It is not a property of either 9.6.1 class, not one of the Android
|
||||||
|
`IMPRESSION_DATA_KEY_*` constants (auctionId, adFormat, mediationAdUnitName, mediationAdUnitId, country, ab,
|
||||||
|
segmentName, placement, adNetwork, instanceName, instanceId, revenue, precision, encryptedCPM, creativeId), and the
|
||||||
|
string does not occur in the iOS binary. Apps that need lifetime revenue sum `revenue` themselves. If the server
|
||||||
|
sends it anyway it shows up in `allData`.
|
||||||
|
|
||||||
|
### 5.2 Registration
|
||||||
|
|
||||||
|
9.6.1 deprecates the global listener for publishers:
|
||||||
|
- A: `LevelPlay.addImpressionDataListener` / `removeImpressionDataListener` carry `@kotlin.Deprecated("Publishers:
|
||||||
|
use setImpressionDataListener() on each LevelPlayBannerAdView, LevelPlayInterstitialAd, or LevelPlayRewardedAd ...")`.
|
||||||
|
- I: `+[LevelPlay addImpressionDataDelegate:]` is `DEPRECATED_MSG_ATTRIBUTE` with the same advice
|
||||||
|
(`setImpressionDataDelegate:` on each `LPMBannerAdView`, `LPMInterstitialAd`, `LPMRewardedAd`).
|
||||||
|
- `addImpressionLevelRevenueListener(listener, subscriberId)` is for approved third-party SDKs only (needs a
|
||||||
|
subscriber id from Unity), not for apps.
|
||||||
|
|
||||||
|
Design (recommended, see Q1): the plugin attaches its own impression listener to **every** rewarded, interstitial
|
||||||
|
and banner object it creates (the holders already exist per ad unit). The JS side can add the listener at any time,
|
||||||
|
including before `initialize()`, because events go through `notifyListeners`; nothing can be emitted before the
|
||||||
|
first ad object exists. Native ads have no per-ad listener, so on `onAdImpression` / `didRecordImpression:` the plugin
|
||||||
|
emits an `impressionData` built from the native `AdInfo` (`adFormat: 'nativead'`, no ad unit / placement /
|
||||||
|
creative fields). This avoids deprecated APIs and still covers every format.
|
||||||
|
|
||||||
|
Events are sent with `retainUntilConsumed = false` (as today). Q2 asks whether to retain.
|
||||||
|
|
||||||
|
## 6. Overlay positioning (banners and native ads)
|
||||||
|
|
||||||
|
### 6.1 Coordinate space
|
||||||
|
|
||||||
|
All public geometry is in **CSS px relative to the WebView viewport** (the space of `getBoundingClientRect()` on a
|
||||||
|
non-scrolled page). Capacitor WebViews render at 1 CSS px = 1 dp (Android, default zoom / `initial-scale=1`) and
|
||||||
|
1 CSS px = 1 pt (iOS). Pages that change the viewport scale break this; documented as unsupported.
|
||||||
|
|
||||||
|
### 6.2 Host view
|
||||||
|
|
||||||
|
- **Android**: a plugin-owned `FrameLayout` "overlay host" added to the WebView's parent (`(ViewGroup)
|
||||||
|
bridge.getWebView().getParent()`, the Capacitor `CoordinatorLayout`) right after the WebView, so it draws above it.
|
||||||
|
It is kept equal to the WebView's bounds with an `OnLayoutChangeListener` on the WebView. The host is not clickable
|
||||||
|
and has no touch listener, so touches outside ad views fall through to the WebView below (Android dispatches to
|
||||||
|
siblings in reverse z-order until one consumes). Ad views inside it consume their own touches.
|
||||||
|
- **iOS**: a plugin-owned `UIView` subclass added to `bridge.viewController.view` above `bridge.webView`, frame and
|
||||||
|
`autoresizingMask` following the WebView. Its `hitTest(_:with:)` returns `nil` when the hit view is itself, so only
|
||||||
|
ad subviews receive touches.
|
||||||
|
- Full-screen ads (rewarded / interstitial / expanded banners / test suite) are presented as Activities / modal view
|
||||||
|
controllers and therefore always cover the overlay.
|
||||||
|
|
||||||
|
### 6.3 Safe area
|
||||||
|
|
||||||
|
`safeRect = webViewRect ∩ (window bounds − system insets)`, converted into WebView-local CSS px.
|
||||||
|
|
||||||
|
- Android: insets from `ViewCompat.getRootWindowInsets(webView)` with
|
||||||
|
`WindowInsetsCompat.Type.systemBars() | Type.displayCutout()`. Intersecting with the WebView's on-screen rect
|
||||||
|
(`getLocationInWindow`) makes this correct in every Capacitor mode: Capacitor 7 `android.adjustMarginsForEdgeToEdge`
|
||||||
|
(margins on the WebView), Capacitor 8 `SystemBars` `insetsHandling: 'native'` (padding on the WebView parent) or
|
||||||
|
`'css'` (WebView edge to edge, insets only in CSS). Insets are re-read in the host's layout pass and via
|
||||||
|
`ViewCompat.setOnApplyWindowInsetsListener` on the host (the host returns the insets unconsumed so it never steals
|
||||||
|
them from Capacitor's own listener on the WebView).
|
||||||
|
- iOS: `overlayHost.safeAreaInsets` (same frame as the WebView), updated in `safeAreaInsetsDidChange` /
|
||||||
|
`layoutSubviews`.
|
||||||
|
|
||||||
|
`respectSafeArea: false` uses the raw WebView rect. Native ad rects are taken literally (the page already laid them
|
||||||
|
out against `env(safe-area-inset-*)`), only clamped to the WebView rect.
|
||||||
|
|
||||||
|
### 6.4 Placement maths (banner)
|
||||||
|
|
||||||
|
```
|
||||||
|
x = safe.x + (safe.width − bannerWidth) / 2 + offsetX
|
||||||
|
y = top: safe.y + offsetY
|
||||||
|
bottom: safe.y + safe.height − bannerHeight + offsetY
|
||||||
|
center: safe.y + (safe.height − bannerHeight) / 2 + offsetY
|
||||||
|
```
|
||||||
|
|
||||||
|
Recomputed on every host layout pass (rotation, split screen, multi-window, keyboard resizing the WebView, foldables).
|
||||||
|
Adaptive banners keep the size they were created with; after a rotation the app may destroy and recreate them with a
|
||||||
|
new width (Q4).
|
||||||
|
|
||||||
|
### 6.5 WebView scroll and z-order
|
||||||
|
|
||||||
|
Overlays are fixed to the viewport; they do not scroll with page content. Games normally have no page scroll. For
|
||||||
|
scrolling pages the app calls `setNativeAdRect` on scroll / resize (documented). Z-order inside the host: creation
|
||||||
|
order; a later `showBanner` / `showNativeAd` brings that view to the front.
|
||||||
|
|
||||||
|
### 6.6 Lifecycle
|
||||||
|
|
||||||
|
On `handleOnDestroy` (Android) / plugin deinit the plugin destroys every banner and native ad. On app pause the SDK
|
||||||
|
manages refresh itself; the plugin does not pause banners on `handleOnPause`.
|
||||||
|
|
||||||
|
## 7. `adInfoChanged`
|
||||||
|
|
||||||
|
`addListener('adInfoChanged', (e: AdEvent) => ...)`, same payload as `loaded`. Sources: A
|
||||||
|
`LevelPlayRewardedAdListener.onAdInfoChanged` / `LevelPlayInterstitialAdListener.onAdInfoChanged` (default methods);
|
||||||
|
I `LPMRewardedAdDelegate` / `LPMInterstitialAdDelegate` `didChangeAdInfo(_:)` (optional). The 0.2.x holders already
|
||||||
|
implement these as empty bodies; phase 2 only emits. Banner listener / delegate have no such callback in 9.6.1;
|
||||||
|
native ads neither.
|
||||||
|
|
||||||
|
## 8. Placements, capping and rewards
|
||||||
|
|
||||||
|
| Plugin | Android | iOS |
|
||||||
|
|---|---|---|
|
||||||
|
| `isPlacementCapped({ format: 'rewarded', placementName })` | `LevelPlayRewardedAd.isPlacementCapped(String)` (static) | `+[LPMRewardedAd isPlacementCapped:]` |
|
||||||
|
| `isPlacementCapped({ format: 'interstitial', ... })` | `LevelPlayInterstitialAd.isPlacementCapped(String)` (static) | `+[LPMInterstitialAd isPlacementCapped:]` |
|
||||||
|
| `getReward({ adUnitId, placementName? })` | `LevelPlayRewardedAd.getReward(String)` / `getReward()` (instance) | `-[LPMRewardedAd getRewardWithPlacementName:]` (`getReward(placementName:)`) |
|
||||||
|
|
||||||
|
`getReward` uses the plugin's per-ad-unit `LevelPlayRewardedAd` holder (created on demand, as `loadRewarded` does).
|
||||||
|
iOS documents "an empty reward on failures (`name: ""` and `amount: 0`)"; the plugin returns the same shape on both
|
||||||
|
platforms and the web.
|
||||||
|
|
||||||
|
Not in 9.6.1: the 7.x/8.x `IronSource.getRewardedVideoPlacementInfo` / `Placement` class (absent from
|
||||||
|
`com.ironsource.mediationsdk.IronSource` and `IronSource.h`, which now only hold demand-only and ad-revenue APIs), and
|
||||||
|
any capping API for banners or native ads. `ShowOptions.placementName` (0.1.0) already covers show-time placements.
|
||||||
|
|
||||||
|
## 9. Segments and dynamic user id
|
||||||
|
|
||||||
|
`setSegment(options)`:
|
||||||
|
|
||||||
|
| Field | Android `com.unity3d.mediation.segment.LevelPlaySegment` | iOS `LPMSegment` |
|
||||||
|
|---|---|---|
|
||||||
|
| `segmentName` | `setSegmentName(String)` | `segmentName` |
|
||||||
|
| `level` | `setLevel(int)` | `level` (`int`) |
|
||||||
|
| `isPaying` | `setPaying(boolean)` | `paying` |
|
||||||
|
| `userCreationDate` (ms epoch) | `setUserCreationDate(long)` | `userCreationDate` (`NSDate`, `Date(timeIntervalSince1970: ms / 1000)`) |
|
||||||
|
| `iapTotal` | `setIapTotal(double)` | `iapTotal` |
|
||||||
|
| `customParameters` | `setCustom(String, String)` per pair | `setCustomValue:forKey:` per pair |
|
||||||
|
| apply | `LevelPlay.setSegment(LevelPlaySegment)` | `+[LevelPlay setSegment:]` |
|
||||||
|
|
||||||
|
Custom-parameter limits read from the Android bytecode of `setCustom`: key and value must match `^[a-zA-Z0-9]*$`
|
||||||
|
and be 1-32 characters; at most 5 pairs, the oldest is silently evicted on the 6th. The plugin validates the same
|
||||||
|
rules on both platforms and rejects `INVALID_ARGUMENT` rather than dropping data silently. (The iOS header does not state the
|
||||||
|
limits; phase 2 confirms iOS behaves the same.)
|
||||||
|
|
||||||
|
`setDynamicUserId({ userId })` → `{ valid }`: A `LevelPlay.setDynamicUserId(String): boolean`, I
|
||||||
|
`+[LevelPlay setDynamicUserId:]` returning `BOOL`. There is no `IronSource.setDynamicUserId` in 9.6.1; the LevelPlay
|
||||||
|
class is the only entry point.
|
||||||
|
|
||||||
|
## 10. Errors
|
||||||
|
|
||||||
|
Promise rejections (plugin codes, strings):
|
||||||
|
|
||||||
|
| Code | When |
|
||||||
|
|---|---|
|
||||||
|
| `INVALID_ARGUMENT` | missing / empty ids, bad size or position, bad segment custom parameters, negative rect size |
|
||||||
|
| `NOT_INITIALIZED` | `createBanner`, `loadNativeAd` before `initialize()` resolved |
|
||||||
|
| `ALREADY_EXISTS` | `createBanner` with a `bannerId` in use |
|
||||||
|
| `NOT_FOUND` | `loadBanner`, `showBanner`, `setBannerLayout`, `showNativeAd`, `setNativeAdRect`, `hideNativeAd` with an unknown id (`hideBanner`, `destroy*` resolve instead) |
|
||||||
|
| `NOT_LOADED` | `showNativeAd` before `nativeAdLoaded` |
|
||||||
|
| `UNSUPPORTED` | capability is `false`, or a template not in `nativeAdTemplates` |
|
||||||
|
| `NO_VIEW_CONTROLLER` (iOS) / `NO_ACTIVITY` (Android) | no host to attach or load into |
|
||||||
|
| `UNIMPLEMENTED` | web stubs (Capacitor's `unimplemented()`), and any 0.3.0 method on a native build of phase 1 |
|
||||||
|
|
||||||
|
Ad errors in events (`AdError { code, message }`) pass the SDK code through: A `LevelPlayAdError.getErrorCode()` /
|
||||||
|
`IronSourceError.getErrorCode()` (native), I `NSError.code`. Notable codes: 509 no fill; banner-specific Android
|
||||||
|
constants `ERROR_BN_LOAD_NO_FILL`, `ERROR_BN_UNSUPPORTED_SIZE`, `ERROR_BN_RELOAD_SKIP_INVISIBLE`; native
|
||||||
|
`ERROR_NT_LOAD_NO_FILL`, `ERROR_NT_LOAD_PLACEMENT_CAPPED`.
|
||||||
|
|
||||||
|
## 11. Web
|
||||||
|
|
||||||
|
`getCapabilities` all false; `setSegment` no-op; `setDynamicUserId` → `{ valid: false }`; `isPlacementCapped` →
|
||||||
|
`{ capped: false }`; `getReward` → `{ name: '', amount: 0 }`; `loadBanner`, `hideBanner`, `destroyBanner`,
|
||||||
|
`setNativeAdRect`, `hideNativeAd`, `destroyNativeAd` no-ops; `createBanner`, `showBanner`, `setBannerLayout`,
|
||||||
|
`loadNativeAd`, `showNativeAd` reject `unimplemented` (they would have to return a frame or show a view; same rule as
|
||||||
|
`initialize`).
|
||||||
|
|
||||||
|
## 12. Capacitor 7 compatibility (findings only; `peerDependencies` unchanged)
|
||||||
|
|
||||||
|
Plugin-facing Java and Swift API is identical between 7.6.9 and 8.5.3 for everything this plugin uses:
|
||||||
|
|
||||||
|
- Android: the public members of `Plugin`, `PluginCall`, `Bridge` and `JSObject` diff to zero.
|
||||||
|
`notifyListeners(String, JSObject, boolean)` exists in both.
|
||||||
|
- iOS: `CAPPluginCall` (`.swift`, `.h`) identical; `CAPBridgeProtocol` in 8 only adds deprecations (`presentVC` /
|
||||||
|
`dismissVC` → `bridge.viewController.present/dismiss`, which the plugin already uses); `CAPPlugin` in 8 adds
|
||||||
|
`handleWKWebViewURLAuthenticationChallenge` (not used). `CAPBridgedPlugin` exists in both.
|
||||||
|
|
||||||
|
What must change to support `>=7.0.0` (phase 2 or later, not done now):
|
||||||
|
|
||||||
|
| Item | Today (Cap 8) | Needed for Cap 7 |
|
||||||
|
|---|---|---|
|
||||||
|
| `package.json` peer | `@capacitor/core >=8.0.0` | `>=7.0.0` |
|
||||||
|
| `Package.swift` | `capacitor-swift-pm` `from: "8.0.0"` | `"7.0.0"..<"9.0.0"` (tags 7.0.0 ... 7.6.9 and 8.x exist) |
|
||||||
|
| iOS deployment target | `.iOS(.v15)`, podspec `15.0` | `.v14` / `14.0` (Cap 7 default; `Capacitor.podspec` 7 = 14.0, 8 = 15.0). LevelPlay 9.6.1 needs 12.0, so 14 is fine. SPM refuses a package whose platform is higher than the app target. |
|
||||||
|
| Android `minSdkVersion` default | 24 | 23 (Cap 7 default; LevelPlay AAR needs 19). Only the fallback; apps override from `variables.gradle`. |
|
||||||
|
| Android `compileSdk` / `targetSdk` defaults | 36 | 35 in Cap 7 projects; overridden by the app, so no code change. |
|
||||||
|
| AGP in plugin `buildscript` | `8.13.0` | Cap 7 apps use AGP 8.7.2. The plugin's `buildscript` classpath is only used by the standalone `verify:android` build, but a mismatched AGP in a subproject `buildscript` can trigger "multiple AGP versions"; phase 2 tests it in a Cap 7 app and, if needed, drops the plugin's `buildscript` classpath or keys it off `rootProject`. |
|
||||||
|
| Java | 21 | 21 (same). |
|
||||||
|
| Node / CLI | engines `>=22` | Cap 7 CLI runs on Node 20+; `engines` is advisory, can stay. |
|
||||||
|
| SPM | default in Cap 8 projects | supported in Cap 7 (CapApp-SPM since Cap 6); CocoaPods podspec unchanged. |
|
||||||
|
| LevelPlay SPM package | swift-tools 6.0 | needs Xcode 16+, which Cap 7 already requires. |
|
||||||
|
|
||||||
|
Behavioural difference that matters for overlays: edge-to-edge handling. Cap 7 uses
|
||||||
|
`android.adjustMarginsForEdgeToEdge` (`CapConfig`, margins on `CapacitorWebView`; removed in 8). Cap 8 uses the core
|
||||||
|
`SystemBars` plugin (`insetsHandling: 'css' | 'native' | 'disable'`, padding on the WebView's parent or CSS
|
||||||
|
variables). The overlay design (§6.3) measures the WebView's real on-screen rect and intersects with window insets, so
|
||||||
|
it is correct under every combination without reading either config.
|
||||||
|
|
||||||
|
## 13. Test plan
|
||||||
|
|
||||||
|
Automated (CI-able):
|
||||||
|
- `bun run typecheck`, `bun run build` (docgen + rollup), `verify:ios`, `verify:android` on every change.
|
||||||
|
- Android unit tests (JUnit, no device): pure helpers for placement maths (§6.4), safe-rect intersection, size
|
||||||
|
preset parsing, segment validation, `ImpressionData` → `JSObject` mapping (constructed from a JSON fixture with
|
||||||
|
`new LevelPlayImpressionData(JSONObject)`).
|
||||||
|
- iOS: same helpers as plain Swift functions with XCTest (`swift test` cannot link the binary SDK on macOS; keep the
|
||||||
|
helpers SDK-free).
|
||||||
|
|
||||||
|
Manual on devices (Unity demo app keys from `LEVELPLAY_DEMO` + test suite), Android 8 / 14 / 15 (edge to edge) and
|
||||||
|
iOS 15 / 18 / 26, phone and tablet, portrait and landscape:
|
||||||
|
1. Banner: every preset + adaptive; top / bottom / center with offsets; frame in `BannerResult` matches
|
||||||
|
`document.elementFromPoint` checks; notch and home indicator respected; rotate while shown; hide during gameplay
|
||||||
|
(no `bannerDisplayed` while hidden, refresh paused); two banners at once; destroy and recreate; click → `bannerClicked`
|
||||||
|
and `bannerLeftApplication`; expanded creative → `bannerExpanded` / `bannerCollapsed`.
|
||||||
|
2. Touch passthrough: game input works everywhere outside ad views, ads clickable inside; with keyboard open.
|
||||||
|
3. Native: small and medium templates at several rects; "Ad" badge and AdChoices corner; impression only once visible;
|
||||||
|
`setNativeAdRect` while shown; reload replaces the creative; destroy on screen change; no leaks across 50 loads
|
||||||
|
(Android Studio profiler / Instruments).
|
||||||
|
4. `impressionData` for rewarded, interstitial, banner, native; listener added before `initialize`; values match
|
||||||
|
`adInfo.revenue`; `conversionValue` present on iOS only.
|
||||||
|
5. `adInfoChanged` fires (needs a network that reloads; verify with test suite or logs).
|
||||||
|
6. `isPlacementCapped` with a dashboard placement capped to 1 per session; `getReward` per placement vs ad unit.
|
||||||
|
7. `setSegment` before init, segment name appears in `adInfo.segmentName` / `impressionData.segmentName`; invalid
|
||||||
|
custom parameters reject.
|
||||||
|
8. `setDynamicUserId` value reaches the S2S callback URL.
|
||||||
|
9. Backwards compatibility: the 0.2.1 README quick start and CUT BLAST's integration run unchanged.
|
||||||
|
10. Capacitor 7: a fresh Cap 7 app (SPM and CocoaPods; Android with `adjustMarginsForEdgeToEdge: 'auto'`) after the
|
||||||
|
§12 changes.
|
||||||
|
|
||||||
|
## 14. Open questions for the owner
|
||||||
|
|
||||||
|
- **Q1 Impression data source.** Recommended: per-ad listeners (non-deprecated) + native impressions synthesised from
|
||||||
|
native `AdInfo`. Alternative: the deprecated global `LevelPlay.addImpressionDataListener` /
|
||||||
|
`addImpressionDataDelegate:` (one registration, true SDK impression data for native too, but deprecated and may
|
||||||
|
vanish in 9.x/10). Both at once would duplicate events.
|
||||||
|
- **Q2 Retain impressions?** Send `impressionData` with `retainUntilConsumed = true` so impressions fired before a
|
||||||
|
listener exists are queued? Risk: unbounded queue if the app never listens. Default proposed: no.
|
||||||
|
- **Q3 Android adaptive width unit.** `LevelPlayAdSize.createAdaptiveAdSize(Context, Integer)` does not document the
|
||||||
|
unit; plan treats it as dp and verifies on device.
|
||||||
|
- **Q4 Adaptive banners and rotation.** Auto-recreate adaptive banners on width change (simpler for apps, costs a
|
||||||
|
reload) or leave it to the app (proposed)?
|
||||||
|
- **Q5 Custom banner sizes.** Both SDKs have custom sizes (`LevelPlayAdSize.createCustomSize`,
|
||||||
|
`LPMAdSize.customSizeWithWidth:height:`); left out of 0.3.0 because few networks fill them. Add?
|
||||||
|
- **Q6 Native template styling depth.** Colours + corner radius only (proposed), or fonts / sizes too?
|
||||||
|
- **Q7 Capacitor 7.** Ship the §12 changes in 0.3.0 or a later 0.3.x after a Cap 7 app test?
|
||||||
1100
src/definitions.ts
1100
src/definitions.ts
File diff suppressed because it is too large
Load diff
83
src/web.ts
83
src/web.ts
|
|
@ -2,12 +2,27 @@ import { WebPlugin } from '@capacitor/core';
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
AdUnitOptions,
|
AdUnitOptions,
|
||||||
|
BannerIdOptions,
|
||||||
|
BannerResult,
|
||||||
|
Capabilities,
|
||||||
ConsentOptions,
|
ConsentOptions,
|
||||||
|
CreateBannerOptions,
|
||||||
|
DynamicUserIdOptions,
|
||||||
|
DynamicUserIdResult,
|
||||||
|
GetRewardOptions,
|
||||||
InitOptions,
|
InitOptions,
|
||||||
InitResult,
|
InitResult,
|
||||||
IsReadyResult,
|
IsReadyResult,
|
||||||
LevelPlayPlugin,
|
LevelPlayPlugin,
|
||||||
|
LoadNativeAdOptions,
|
||||||
MetaDataOptions,
|
MetaDataOptions,
|
||||||
|
NativeAdIdOptions,
|
||||||
|
NativeAdRectOptions,
|
||||||
|
PlacementCappedOptions,
|
||||||
|
PlacementCappedResult,
|
||||||
|
Reward,
|
||||||
|
SegmentOptions,
|
||||||
|
SetBannerLayoutOptions,
|
||||||
ShowResult,
|
ShowResult,
|
||||||
TrackingResult,
|
TrackingResult,
|
||||||
} from './definitions';
|
} from './definitions';
|
||||||
|
|
@ -15,6 +30,10 @@ import type {
|
||||||
/**
|
/**
|
||||||
* Web stub. LevelPlay has no web SDK: init rejects with `unimplemented`, ads are never ready and every show resolves
|
* Web stub. LevelPlay has no web SDK: init rejects with `unimplemented`, ads are never ready and every show resolves
|
||||||
* as "not shown" so callers can treat the web like a no-fill platform without special casing.
|
* as "not shown" so callers can treat the web like a no-fill platform without special casing.
|
||||||
|
*
|
||||||
|
* 0.3.0: `getCapabilities()` reports nothing supported. Setters, loads of things that cannot exist, hide and destroy
|
||||||
|
* are no-ops; calls that would have to return a native view (`createBanner`, `showBanner`, `setBannerLayout`,
|
||||||
|
* `loadNativeAd`, `showNativeAd`) reject as unimplemented, like `initialize`.
|
||||||
*/
|
*/
|
||||||
export class LevelPlayWeb extends WebPlugin implements LevelPlayPlugin {
|
export class LevelPlayWeb extends WebPlugin implements LevelPlayPlugin {
|
||||||
private static readonly NO_FILL: ShowResult = {
|
private static readonly NO_FILL: ShowResult = {
|
||||||
|
|
@ -74,4 +93,68 @@ export class LevelPlayWeb extends WebPlugin implements LevelPlayPlugin {
|
||||||
async validateIntegration(): Promise<void> {
|
async validateIntegration(): Promise<void> {
|
||||||
/* nothing to validate */
|
/* nothing to validate */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getCapabilities(): Promise<Capabilities> {
|
||||||
|
return { banner: false, nativeAd: false, nativeAdTemplates: [], impressionData: false, adInfoChanged: false };
|
||||||
|
}
|
||||||
|
|
||||||
|
async setSegment(_options: SegmentOptions): Promise<void> {
|
||||||
|
/* nothing to forward */
|
||||||
|
}
|
||||||
|
|
||||||
|
async setDynamicUserId(_options: DynamicUserIdOptions): Promise<DynamicUserIdResult> {
|
||||||
|
return { valid: false };
|
||||||
|
}
|
||||||
|
|
||||||
|
async isPlacementCapped(_options: PlacementCappedOptions): Promise<PlacementCappedResult> {
|
||||||
|
return { capped: false };
|
||||||
|
}
|
||||||
|
|
||||||
|
async getReward(_options: GetRewardOptions): Promise<Reward> {
|
||||||
|
return { name: '', amount: 0 };
|
||||||
|
}
|
||||||
|
|
||||||
|
async createBanner(_options: CreateBannerOptions): Promise<BannerResult> {
|
||||||
|
throw this.unimplemented('LevelPlay banners are not available on the web.');
|
||||||
|
}
|
||||||
|
|
||||||
|
async loadBanner(_options: BannerIdOptions): Promise<void> {
|
||||||
|
/* never fills */
|
||||||
|
}
|
||||||
|
|
||||||
|
async showBanner(_options: BannerIdOptions): Promise<BannerResult> {
|
||||||
|
throw this.unimplemented('LevelPlay banners are not available on the web.');
|
||||||
|
}
|
||||||
|
|
||||||
|
async hideBanner(_options: BannerIdOptions): Promise<void> {
|
||||||
|
/* nothing shown */
|
||||||
|
}
|
||||||
|
|
||||||
|
async setBannerLayout(_options: SetBannerLayoutOptions): Promise<BannerResult> {
|
||||||
|
throw this.unimplemented('LevelPlay banners are not available on the web.');
|
||||||
|
}
|
||||||
|
|
||||||
|
async destroyBanner(_options: BannerIdOptions): Promise<void> {
|
||||||
|
/* nothing to destroy */
|
||||||
|
}
|
||||||
|
|
||||||
|
async loadNativeAd(_options: LoadNativeAdOptions): Promise<void> {
|
||||||
|
throw this.unimplemented('LevelPlay native ads are not available on the web.');
|
||||||
|
}
|
||||||
|
|
||||||
|
async showNativeAd(_options: NativeAdRectOptions): Promise<void> {
|
||||||
|
throw this.unimplemented('LevelPlay native ads are not available on the web.');
|
||||||
|
}
|
||||||
|
|
||||||
|
async setNativeAdRect(_options: NativeAdRectOptions): Promise<void> {
|
||||||
|
/* nothing shown */
|
||||||
|
}
|
||||||
|
|
||||||
|
async hideNativeAd(_options: NativeAdIdOptions): Promise<void> {
|
||||||
|
/* nothing shown */
|
||||||
|
}
|
||||||
|
|
||||||
|
async destroyNativeAd(_options: NativeAdIdOptions): Promise<void> {
|
||||||
|
/* nothing to destroy */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue