Skip to main content

Module ads

Module ads 

Source
Expand description

Google AdMob ads as Bevy resources + messages.

Flow:

  1. Insert AdmobConfig with your per-format ad unit ids (or AdmobConfig::test_ads to use Google’s official sample units). The plugin calls into the backend once to start the Mobile Ads SDK.
  2. Wait until AdmobState::can_request_ads is true, presenting RequestConsent first when consent is required.
  3. Send LoadAd to preload a full-screen format; read AdInventoryis_loaded(format) — to know when it’s ready to present.
  4. Send ShowAd to present it, or ShowBanner / HideBanner for the banner.
  5. React to AdLoaded / AdLoadFailed / AdShown / AdDismissed / AdShowFailed / RewardEarned / AdClicked.

Consent: read AdmobState::consent; send RequestConsent to present the initial UMP form when required. If the PrivacyOptionsRequirement resource is PrivacyOptionsRequirement::Required, keep a visible action that sends PresentPrivacyOptions so the user can revisit their choices. AdMob requires a valid consent state before serving personalized ads in regulated regions.

§Desktop fake (non-iOS)

On cargo run off-device the bridge is a deterministic in-memory fake so the full ad UX is exercisable with no SDK. It’s env-tunable:

  • BEVY_ADMOB_FAKE_NO_FILL=interstitial,rewarded — those formats fail to load.
  • BEVY_ADMOB_FAKE_SHOW_FAIL=interstitial — those formats fail to present.
  • BEVY_ADMOB_FAKE_REWARD_AMOUNT=10 / BEVY_ADMOB_FAKE_REWARD_TYPE=coins — reward granted by rewarded formats (default 1 / Reward).
  • BEVY_ADMOB_FAKE_CONSENT=required — consent starts Required instead of Obtained; a RequestConsent then resolves it to Obtained.
  • BEVY_ADMOB_FAKE_CAN_REQUEST_ADS=true — override authoritative UMP ad readiness independently of its coarse consent status.
  • BEVY_ADMOB_FAKE_CONSENT_UPDATE=failed|fail_once — surface a persistent or one-shot ConsentInfoUpdateFailed.
  • BEVY_ADMOB_FAKE_PRIVACY_OPTIONS=required — the privacy-options entry point is required for the session.

Structs§

AdClicked
The user tapped the ad.
AdDismissed
A full-screen ad was dismissed and control returned to the app.
AdInventory
Per-format readiness. Read is_loaded(format) before sending ShowAd.
AdLoadFailed
A load failed (no fill, network, or configuration).
AdLoaded
A load completed and a creative is ready to present.
AdShowFailed
Presentation failed (e.g. nothing loaded, or the OS refused).
AdShown
A full-screen ad began presenting (good moment to pause gameplay/audio).
AdmobConfig
Ad configuration. Insert before or after adding the plugin; the SDK starts on the first frame this resource exists.
AdmobState
Coarse SDK + consent + banner state, for UI that needs the big picture.
AdsPlugin
ConsentInfoUpdateFailed
The latest UMP consent-info update failed.
ConsentUpdated
The consent state changed; read AdmobState::consent for the new value.
HideBanner
Hide and release the banner.
LoadAd
Preload a full-screen ad of format after AdmobState::can_request_ads is true. No-op for AdFormat::Banner (use ShowBanner).
PresentPrivacyOptions
Present the UMP privacy-options form in response to a visible user action.
RequestConsent
Present the UMP consent form if one is required/available.
RewardEarned
The user earned a reward from a rewarded / rewarded-interstitial ad. Grant it idempotently — this fires once per completed view.
ShowAd
Present a previously-loaded full-screen ad. If it isn’t loaded an AdShowFailed is emitted.
ShowBanner
Show (or move) the banner after AdmobState::can_request_ads is true. Loads and displays in one step.
UmpTestConfig
Explicit UMP test overrides. Insert before AdsPlugin initializes.

Enums§

AdFormat
An AdMob ad format. The discriminants are the stable wire values shared with the Swift bridge; do not reorder.
AdLoadState
Per-format load state, owned by AdInventory and advanced by events.
BannerPosition
Where a banner is pinned on screen.
ConsentStatus
UMP (User Messaging Platform) consent state for personalized ads.
PrivacyOptionsRequirement
Whether UMP requires a visible privacy-options entry point.
UmpDebugGeography
Test-only geography override for UMP consent flows.

Constants§

TEST_APP_ID
Google’s official iOS test app id (set as GADApplicationIdentifier in Info.plist while developing). Real ad ids only serve in production.

Functions§

test_unit_id
Google’s official iOS test ad unit id for format. Always safe to request; returns fillable test creatives without risking policy strikes. https://developers.google.com/admob/ios/test-ads