# rmp::ads

> rmp::ads — interstitial and rewarded ads.

Source: https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-ads.html

namespace `#include <rmp/ads.h>`

`rmp::ads` — interstitial and rewarded ads.

Real calls on Android, no-ops everywhere else, so ad code compiles on every target without a single #ifdef. And when `[android.admob] enabled` = false in raylib_multiplatform.toml, the Google Mobile Ads SDK is not in the build at all and these still compile and still do nothing.

The chain behind them: thirdparty/raymob/admob.c (JNI) -> NativeLoader.java -> AdmobBridge.java. The ad unit ids come from [android.admob].

A wrapper, not a layer: src/rmp/ads/ads.cpp forwards these to the C functions in <admob.h>, and that header stays out of yours. Those stay C because they are the real JNI boundary, and because a game in plain C — the shape of examples/plain_c/src/main.c — has no namespace to call into and can call them directly: #include <admob.h>, which is on a plain C game's include path on every target and compiles to no-ops off Android, as these do. examples/ads/01_interstitial and examples/ads/02_rewarded are both kinds of ad, end to end.

Typical use:

```cpp
rmp::ads::request_rewarded();               // preload, e.g. in on_ready()
...
if (rmp::ads::is_rewarded_loaded()) rmp::ads::show_rewarded();
if (rmp::ads::take_reward_earned()) grant(rmp::ads::reward_amount());
```

Before shipping with ads on, read the consent (UMP) warning in README.md.

## Interstitial

### `request_interstitial`

void request_interstitial()

function [include/rmp/ads.h:39](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/ads.h#L39)

Start preloading one. Do it early; loading takes seconds.

### `is_interstitial_loaded`

bool is_interstitial_loaded()

function [include/rmp/ads.h:42](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/ads.h#L42)

Has one finished loading?

### `show_interstitial`

void show_interstitial()

function [include/rmp/ads.h:45](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/ads.h#L45)

Show it. The ad is consumed: request another one to show again.

## Rewarded

### `request_rewarded`

void request_rewarded()

function [include/rmp/ads.h:51](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/ads.h#L51)

Start preloading a rewarded ad, from `[android.admob] rewarded_id`. Do it early, and again after each one is shown: loading takes seconds.

### `is_rewarded_loaded`

bool is_rewarded_loaded()

function [include/rmp/ads.h:54](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/ads.h#L54)

Has one finished loading? A button that shows it should be live only then.

### `show_rewarded`

void show_rewarded()

function [include/rmp/ads.h:59](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/ads.h#L59)

Show it. The ad is consumed: request another one to show again. Nothing happens when none has loaded, and the reward is not here: it arrives through `take_reward_earned()`, and only if the player watched enough of the ad.

### `take_reward_earned`

bool take_reward_earned()

function [include/rmp/ads.h:63](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/ads.h#L63)

True once per earned reward, and clears the flag. Poll it from the game loop; the amount is then in `reward_amount()`.

### `reward_amount`

int reward_amount()

function [include/rmp/ads.h:67](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/ads.h#L67)

The amount of the last reward earned, as set on the ad unit in AdMob. 0 until one is earned, and always 0 off Android.
