# pop.onl Ads for Godot 4

pop.onl ad mediation for Godot 4.2+ (Android). 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 SDK.

## Install

1. Copy `addons/poponl_ads` into your project, with `bin/poponl-godot-release.aar` (build it from `android/`:
   `gradle assembleRelease`, then copy `build/outputs/aar/*-release.aar` to `addons/poponl_ads/bin/poponl-godot-release.aar`).
2. Project > Project Settings > Plugins: enable "pop.onl Ads". It adds the `PopOnlAds` autoload.
3. Project Settings > `pop_onl/android/networks`: the networks you turned on at pop.onl, comma separated
   (`admob,unityads,pangle`). All 17 Android networks are available.
4. Android export: enable "Use Gradle Build". AdMob also needs its app id in the Android manifest
   (`com.google.android.gms.ads.APPLICATION_ID`).

## Use

```gdscript
func _ready():
    PopOnlAds.set_consent(true)                       # from your consent prompt
    PopOnlAds.initialize("po_app_XXXXXXXXXXXXXXXXXXXX")

func _on_revive_pressed():
    if PopOnlAds.is_rewarded_ready("revive"):
        var earned: bool = await PopOnlAds.show_rewarded("revive")
        if earned:
            give_reward()

func _on_level_end():
    await PopOnlAds.show_interstitial("level_end")
```

iOS is not supported yet (Godot iOS plugins need a native build of their own).
