@freddixx/react-native-ad-manager

中文文档
1.4.6发布于 2022/04/12MITCommonJS近 30 天下载 1.6万

用于Google Ad Manager旗下,互通和本土广告的反应-内在组件.

中文使用文档
文档目录6 节
  1. 安装
  2. 开始
  3. 主要自动安装
  4. iOS系统
  5. 机器人
  6. 使用量

反应-内在-管理

一个针对Google Ad Manager Banners,Interstitials和原生广告的反应-本土模块.

横幅类型是作为组件执行的,而间歇和受奖视频则具有必须的API.

原生广告作为包装来被原生取景所执行.

安装

您可以使用 npm 或 Yarn 安装最新的 beta 版本 :

开始

无 :

npm i --save @freddixx/react-native-ad-manager

亚伦:

yarn add @freddixx/react-native-ad-manager

主要自动安装

$ react-native link @freddixx/react-native-ad-manager

或者,对于iOS,您可以通过添加行到您的 cocoaPods 中来安装库 Podfile· ;

pod 'react-native-ad-manager', path: '../node_modules/@freddixx/react-native-ad-manager'

iOS系统

对于iOS,您需要添加 谷歌移动广告 SDK 您的 Xcode 项目 .

机器人

在Android上,Ad Manager库代码是Play Services的一部分,当此库链接时会自动添加.

但你还是要手动更新 AndroidManifest.xml如本报告所述 Google 移动ads SDK 文档。 。 。 .

使用量

import {
  Banner,
  Interstitial,
  PublisherBanner,
  NativeAdsManager,
} from "@freddixx/react-native-ad-manager";

// Display a DFP Publisher banner
<Banner
  adSize="fullBanner"
  adUnitID="your-ad-unit-id"
  testDevices={[PublisherBanner.simulatorId]}
  onAdFailedToLoad={(error) => console.error(error)}
  onAppEvent={(event) => console.log(event.name, event.info)}
/>;

// Display an interstitial
Interstitial.setAdUnitID("your-ad-unit-id");
Interstitial.setTestDevices([Interstitial.simulatorId]);
Interstitial.requestAd().then(() => Interstitial.showAd());

// Native ad
import NativeAdView from "./NativeAdView";
const adsManager = new NativeAdsManager("your-ad-unit-id", [
  Interstitial.simulatorId,
]);
<NativeAdView
  targeting={{
    customTargeting: { group: "user_test" },
    categoryExclusions: ["media"],
    contentURL: "test://",
    publisherProvidedID: "provider_id",
  }}
  style={{ width: "100%" }}
  adsManager={adsManager}
  validAdTypes={["native", "template"]}
  customTemplateIds={["your-template-id-1", "your-template-id-2"]}
  onAdLoaded={(ad) => {
    console.log(ad);
  }}
  onAdFailedToLoad={(error) => {
    console.log(error);
  }}
/>;

版本与发布记录

@freddixx/react-native-ad-manager 共发布 8 个版本,首次发布于 2022/02/09;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.4.6latest2022/04/124 年前
1.4.52022/03/044 年前
1.4.42022/02/214 年前
1.4.32022/02/184 年前
1.4.22022/02/174 年前
1.4.12022/02/174 年前

关于 @freddixx/react-native-ad-manager 的常见问题

@freddixx/react-native-ad-manager 是什么?

用于Google Ad Manager旗下,互通和本土广告的反应-内在组件.

如何安装 @freddixx/react-native-ad-manager?

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

@freddixx/react-native-ad-manager 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/freddixx__react-native-ad-manager 是否存在。

@freddixx/react-native-ad-manager 支持 ESM 还是 CommonJS?

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

@freddixx/react-native-ad-manager 可以商用吗?

@freddixx/react-native-ad-manager 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@freddixx/react-native-ad-manager 的下载量有多少?

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

@freddixx/react-native-ad-manager 还在维护吗?

最新版本 1.4.6 发布于 2022/04/12(4 年前);至今共发布 8 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/02/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。