@amos-sdk/react-native-admob

中文文档
2.2.1发布于 2026/11/03TypeScriptCommonJS近 30 天下载 1746

React Native AdMob wrapper bindings and hooks for AMOS managed ads.

原始使用文档

AMOS React Native AdMob

AdMob paid-event revenue is captured automatically by the native AMOS wrapper. Use getRevenueHealth() from the native module or useAmos() context to inspect privacy-safe pending, retry, acknowledgement, and queue-capacity diagnostics.

React Native bindings for AMOS-managed AdMob ads plus AMOS core decisions, events, and metrics.

Use this package when AMOS should configure, preload, request, and show AdMob placements.

import {
  AmosBannerAd,
  AmosProvider,
  BannerAdSize,
  useAmosRewardedAd,
} from '@amos-sdk/react-native-admob';

export function Root() {
  return (
    <AmosProvider
      config={{
        apiKey: 'AMOS_API_KEY',
        appId: 'app_example',
        userId: 'publisher-user-123',
        lifecycle: {
          automatic: true,
          sessionTimeoutSeconds: 1800,
          configRefreshIntervalSeconds: 300,
        },
        admob: {
          rewardedGroups: {
            default: { unitIds: ['ca-app-pub-xxx/111'], preloadOnInit: true },
            watermark_remove: {
              unitIds: ['ca-app-pub-xxx/222'],
              preloadOnInit: true,
              allowFallbackToDefault: true,
            },
          },
        },
      }}
    >
      <App />
    </AmosProvider>
  );
}

function RemoveWatermarkButton() {
  const rewarded = useAmosRewardedAd('watermark_remove');
  return <Button title="Watch ad" onPress={() => rewarded.show()} />;
}

function HomeBanner() {
  return <AmosBannerAd size={BannerAdSize.ANCHORED_ADAPTIVE_BANNER} />;
}

The lifecycle block is optional; the values above are the defaults. Android lifecycle handling is automatic, including stale policy refresh and inactivity-based session rollover. Do not end the AMOS session from a React Native AppState listener. Call refreshConfiguration() from useAmos() only for an immediate QA or critical-policy refresh.

Google Play purchases

The provider context also exposes recordGooglePlayPurchase. Call it after Play Billing reports a successful purchase, using a deterministic event ID for retries:

await useAmos().recordGooglePlayPurchase({
  clientEventId: `gplay:${purchase.productId}:${purchase.transactionId}`,
  packageName: 'com.example.app',
  productId: purchase.productId,
  productType: 'ONE_TIME',
  purchaseToken: purchase.purchaseToken,
});

The result confirms durable local queueing; RTDN and Developer API verification determine the final purchase lifecycle.

Exported AdMob helpers:

  • AmosBannerAd
  • AmosNativeAdCard
  • AmosAppOpenAdGate
  • useAmosInterstitialAd
  • useAmosRewardedAd
  • useAmosAppOpenAd
  • useAmosAdMobRequest
  • BannerAdSize

The Android wrapper resolves the AdMob Maven artifact from this package's amosSdkVersion field:

implementation("com.amostack:amos-sdk-admob:<amosSdkVersion>")

For decisions and tracking without AMOS-managed ads, install @amos-sdk/react-native.

The native package namespace remains com.amostack.amos... for Android compatibility.

版本与发布记录

@amos-sdk/react-native-admob 共发布 23 个版本,首次发布于 2026/10/03;过去 12 个月发布了 23 个版本。

版本发布日期距今
2.2.1latest2026/11/037 天前
2.2.02026/11/018 天前
2.1.02026/10/2813 天前
2.0.02026/10/2119 天前
1.0.192026/10/1724 天前
1.0.182026/10/1624 天前

关于 @amos-sdk/react-native-admob 的常见问题

@amos-sdk/react-native-admob 是什么?

React Native AdMob wrapper bindings and hooks for AMOS managed ads.

如何安装 @amos-sdk/react-native-admob?

在项目目录运行 npm install @amos-sdk/react-native-admob,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(*)、react-native(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@amos-sdk/react-native-admob 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@amos-sdk/react-native-admob 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@amos-sdk/react-native-admob 可以商用吗?

@amos-sdk/react-native-admob 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@amos-sdk/react-native-admob 的下载量有多少?

根据 npm 官方下载统计,@amos-sdk/react-native-admob 在 2026/10/06 – 2026/11/04 这 30 天内被下载 1,746 次,日均约 58 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@amos-sdk/react-native-admob 还在维护吗?

最新版本 2.2.1 发布于 2026/11/03(7 天前);至今共发布 23 个版本,其中过去 12 个月发布了 23 个;首次发布于 2026/10/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。