Giter VIP home page Giter VIP logo

react-native-ad-manager's Introduction

react-native-ad-manager (Fork of react-native-admob - only supports ad manager)

A react-native module for Google DFP Banners.

Installation

You can use npm or Yarn to install the latest beta version:

Yarn:

yarn add react-native-admob@next

In order to use this library, you have to link it to your project first. There's excellent documentation on how to do this in the React Native Docs.

iOS

For iOS you will have to add the Google Mobile Ads SDK to your Xcode project.

Android

On Android the AdMob library code is part of Play Services, which is automatically added when this library is linked.

Usage

import { PublisherBanner } from 'react-native-ad-manager'

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

For a full example reference to the example project.

Reference

AdMobBanner

Properties

adSize

Corresponding to iOS framework banner size constants

Value Description Availability Size (WxH)
banner Standard Banner Phones and Tablets 320x50
largeBanner Large Banner Phones and Tablets 320x100
mediumRectangle IAB Medium Rectangle Phones and Tablets 300x250
fullBanner IAB Full-Size Banner Tablets 468x60
leaderboard IAB Leaderboard Tablets 728x90
smartBannerPortrait
smartBannerLandscape
Smart Banner Phones and Tablets Screen width x 32|50|90

Note: There is no smartBannerPortrait and smartBannerLandscape on Android. Both prop values will map to smartBanner

onAdLoaded

Accepts a function. Called when an ad is received.

onAdFailedToLoad

Accepts a function. Called when an ad request failed.

onAdOpened

Accepts a function. Called when an ad opens an overlay that covers the screen.

onAdClosed

Accepts a function. Called when the user is about to return to the application after clicking on an ad.

onAdLeftApplication

Accepts a function. Called when a user click will open another app (such as the App Store), backgrounding the current app.

onSizeChange

Accepts a function. Called when the size of the banner changes. The function is called with an object containing the width and the height.

Above names correspond to the Ad lifecycle event callbacks

PublisherBanner

Properties

Same as AdMobBanner, with the addition of 2 extra properties:

onAppEvent

Accepts a function. Called when DFP sends an event back to the app.

These events may occur at any time during the ad's lifecycle, even before onAdLoaded is called. The function is called with an object, containing the name of the event and an info property, containing additional information.

More info here: https://developers.google.com/mobile-ads-sdk/docs/dfp/ios/banner#app_events

validAdSizes

An array of ad sizes which may be eligible to be served.

react-native-ad-manager's People

Contributors

almostintuitive avatar alvaromb avatar andriniaina avatar cbrevik avatar dkolba avatar eranbes avatar gorangajic avatar izakvandermerwe avatar jeongjuwon avatar jerson avatar koenpunt avatar lebedev avatar lucianomlima avatar maraujop avatar mars-lan avatar mayashaddad avatar ndbroadbent avatar oliviachang29 avatar patw0929 avatar rizzomichaelg avatar sbugert avatar thomashenrissat avatar xing-zheng avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.