反应-内在-管理
一个针对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);
}}
/>;