Skip to content

feat(ads): admob adapter - #2023

Merged
peterporfy merged 19 commits into
mainfrom
porfy/react-native-admob-adapter
Oct 16, 2026
Merged

peterporfy merged 19 commits into
mainfrom
porfy/react-native-admob-adapter

Conversation

@peterporfy

@peterporfy peterporfy commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds react-native-purchases-admob, a new automatic ad tracking package covering the 3rd party react-native-google-mobile-ads package. This is the most commonly used admob package available for admob

The adsTester example changes that exercise it are in the stacked PR.

Changes

Adapter

  • RevenueCatAdMob.create{Interstitial,AppOpen,Rewarded,RewardedInterstitial}Ad(adUnitId, options) creates the ad and tracks loaded, failed-to-load, displayed, opened and revenue.
  • trackAd(ad, options) does the same for an ad the app created.
  • showAndTrack(ad, { placement }) for show-time placement overrides.
  • useTrackingBannerAdProps(...) (hook) / trackingBannerAdProps(...) for <BannerAd>, trackNativeAd(nativeAd) for native ads, impressionIdOf(ad).
  • Reward verification: createRewardedAd(id, { enableRewardVerification: true }) attaches the token as SSV options at creation. The library only accepts them there. showWithRewardVerification(ad, callbacks) polls and returns a VerifiedReward.
  • Events are stamped with AdCaptureMethod.reactNativeAdMobAdapter.

Example usage

import { RevenueCatAdMob, useTrackingBannerAdProps } from 'react-native-purchases-admob';

const rewarded = await RevenueCatAdMob.createRewardedAd(adUnitId, {
  placement: 'level_complete',
  enableRewardVerification: true,
});
rewarded.load();
await RevenueCatAdMob.showWithRewardVerification(rewarded, {
  onRewardVerificationCompleted: result => grant(result),
});

function HomeBanner() {
  const props = useTrackingBannerAdProps({ unitId, size: BannerAdSize.BANNER, placement: 'home_bottom' });
  return <BannerAd {...props} />;
}

Why 17.x

17.0.0 added ResponseInfo on loaded events, the IMPRESSION event, PaidEvent.valueMicros and error.reason.

The adapter needs all four. Verified on 17.0.0, 17.1.0 and 17.2.0.

The only exception is rewarded ad ssv, where we are using our custom impression id, because it is not available properly yet in the API. We might change it in the future.

Core SDK

  • added an optional captureMethod so the new adapter can pass in the new capture method type

Examples

  • adsTester rewritten to use the adapter in the stacked PR

Release wiring

  • Fastfile: adapter in the version-bump map, fourth npm publish in release.
  • CircleCI: prepare, API tests and unit tests for the adapter in analyse_js.
  • Repo-wide tslint already crashes on main under TypeScript 5.4.5; not addressed.

Tests

  • unit tests, api tests
  • full e2e simulator test with all ad formats, against production system, both with android and ios builds, using the adsTester from the stacked PR
  • full e2e for manual integration to catch regression issues

Note

Medium Risk
New monetization surface (ad events and server-side reward verification) with complex lifecycle edge cases, though failures are mostly logged and tracking calls are non-throwing.

Overview
Introduces react-native-purchases-admob, a new workspace package that bridges react-native-google-mobile-ads (17+) to RevenueCat’s Purchases.adTracker and reward-verification APIs.

The RevenueCatAdMob API replaces or wraps ad creation (createInterstitialAd, createAppOpenAd, async rewarded variants), attaches listeners for load/display/revenue/failure events, and forwards them with placement overrides and AdCaptureMethod.reactNativeAdMobAdapter. Banners use useTrackingBannerAdProps / trackingBannerAdProps; native ads use trackNativeAd. Optional enableRewardVerification pins a pre-request impression id, injects AdMob SSV options, blocks unsafe reloads, and showWithRewardVerification polls RevenueCat after the user earns a reward.

Core react-native-purchases gains AdCaptureMethod and an optional captureMethod on ad tracking / reward metadata types (marked @internal for official adapters).

Release and CI: the adapter is added to yarn workspaces, root publish exclusions, Jest ignore paths, CircleCI prepare/API/unit steps, and Fastlane version bumps plus a fourth npm publish in the release lane.

Reviewed by Cursor Bugbot for commit 567b4fb. Bugbot is set up for automated code reviews on this repo. Configure here.

peterporfy commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Comment thread react-native-purchases-admob/LICENSE
@peterporfy peterporfy added the pr:feat A new feature label Oct 12, 2026
@peterporfy
peterporfy requested a review from polmiro October 12, 2026 12:40
@peterporfy
peterporfy marked this pull request as ready for review October 12, 2026 12:40
@peterporfy
peterporfy requested a review from a team as a code owner October 12, 2026 12:40

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread react-native-purchases-admob/src/index.ts Outdated
Comment thread react-native-purchases-admob/src/index.ts Outdated

@polmiro polmiro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@peterporfy
peterporfy force-pushed the porfy/react-native-admob-adapter branch from a8e25d1 to bbc0f36 Compare October 14, 2026 13:09

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread react-native-purchases-admob/package.json Outdated
Comment thread react-native-purchases-admob/src/index.ts

@tonidero tonidero left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good I think. My only main concern is whether we are not clearing ads in the kept state at all... Not sure what the best way to fix that is though... Will approve for now, since I think that it shouldn't be a huge leak... Looks great!

Comment thread react-native-purchases-admob/package.json Outdated
Comment thread react-native-purchases-admob/tsconfig.json
Comment thread react-native-purchases-admob/src/tracker.ts Outdated
Comment thread src/purchases.ts
Comment thread react-native-purchases-admob/src/state.ts
Comment thread react-native-purchases-admob/src/state.ts
Comment thread react-native-purchases-admob/src/index.ts
Comment thread react-native-purchases-admob/src/index.ts
Comment thread react-native-purchases-admob/src/state.ts Outdated

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread react-native-purchases-admob/package.json
@peterporfy
peterporfy force-pushed the porfy/react-native-admob-adapter branch from ff5ef82 to ed74ab0 Compare October 15, 2026 14:34

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread react-native-purchases-admob/src/index.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1d2639c. Configure here.

Comment thread react-native-purchases-admob/src/tracker.ts
@peterporfy
peterporfy merged commit 58360bc into main Oct 16, 2026
17 checks passed
@peterporfy
peterporfy deleted the porfy/react-native-admob-adapter branch October 16, 2026 08:58
peterporfy added a commit that referenced this pull request Oct 16, 2026
## Description

Rewrites the `adsTester` example to use the
`react-native-purchases-admob` adapter from #2023, split out so the
adapter PR stays reviewable on its own. Stacked on #2023.

## Changes

### Examples
- `adsTester` rewritten to use the adapter

## Tests
- full e2e simulator test with all ad formats, against production
system, both with android and ios builds

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Changes are limited to the example app and its bundler/tsconfig
wiring; no production SDK behavior is modified in this diff.
> 
> **Overview**
> **Rewrites the `adsTester` sample** so it exercises
`react-native-purchases-admob` instead of hand-rolling AdMob SSV tokens,
polling, and a single rewarded-interstitial flow.
> 
> The UI becomes a scrollable dashboard: reusable **FormatCard**
load/show cards for interstitial, rewarded, rewarded interstitial, and
app open (plain `showAndTrack` vs `showWithRewardVerification` on
rewarded formats), plus a bottom **banner** wired through
`useTrackingBannerAdProps`. Manual `uuid` /
`generateRewardVerificationToken` / `pollRewardVerification` code is
removed in favor of adapter factories and show helpers.
> 
> **Monorepo wiring** mirrors `react-native-purchases`: Babel alias,
TypeScript paths, and Metro `watchFolders` / `extraNodeModules` resolve
the adapter from source and dedupe `react-native-google-mobile-ads`
(including blocking the adapter workspace’s `node_modules`).
Dependencies drop `uuid` and `react-native-get-random-values` and bump
**react-native-google-mobile-ads** to ^17.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
f3a852d. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants