# @poponl/capacitor-ads

pop.onl ad mediation for Capacitor and Ionic (Capacitor 6+). Rewarded and interstitial ads from the ad networks' own
SDKs, in the waterfall order set on [pop.onl](https://pop.onl). Wraps the pop.onl Android and iOS SDKs.

## Install

```bash
npm install @poponl/capacitor-ads
npx cap sync
```

- Android, `android/gradle.properties`: `poponl.networks=admob,unityads,pangle`; add `maven { url "https://maven.pop.onl" }`
  (and the network repositories from the pop.onl Android SDK README) to the project repositories.
- iOS, `ios/App/Podfile`: `pod 'PopOnlAds/AdMob'`, one line per network, then `npx cap sync ios`.
- AdMob also needs its app id: AndroidManifest `com.google.android.gms.ads.APPLICATION_ID`, Info.plist `GADApplicationIdentifier`.

## Use

```ts
import { PopOnlAds } from '@poponl/capacitor-ads';

await PopOnlAds.setConsent(true);                   // from your consent prompt
await PopOnlAds.initialize('po_app_XXXXXXXXXXXXXXXXXXXX');

if (await PopOnlAds.isRewardedReady('revive')) {
  const earned = await PopOnlAds.showRewarded('revive');
  if (earned) giveReward();
}
await PopOnlAds.showInterstitial('level_end');
```

Networks: Android has all 17; iOS has admob, unityads, pangle, liftoff, inmobi so far.
