Giter Site home page Giter Site logo

react-native-adbannerview's Introduction

react-native-adbannerview

npm version

This component serves as a bridge for ADBannerview. Feel free to contribute :-)

Installation

  1. npm install react-native-adbannerview --save
  2. Xcode: Right click Libraries โžœ Add Files to [project]
  3. Choose node_modules/react-native-adbannerview/lib/ADBannerViewManager.xcodeproj
  4. Xcode: Select the project in the navigator and add the library to the Build Phases โžœ Link Binary With Libraries (libADBannerViewManager.a)

See: http://facebook.github.io/react-native/docs/linking-libraries-ios.html#content (Step 1 + 2)

Usage

var ADBannerView = require('react-native-adbannerview');

...

<ADBannerView />

The bannerview only appears, when an ad has been loaded successfully. Check the example below, where an additional View-Component is used to display the ADBannerView properly.

Props

Event Description
didFailToReceiveAdWithError Error loading banner
willLoadAd Before a new banner ad is loaded
didLoadAd When a new banner ad is loaded
actionDidFinish After banner view finishes executing an action

Example

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 */
'use strict';

var React = require('react-native');
var ADBannerView = require('react-native-adbannerview');
var {
  AppRegistry,
  StyleSheet,
  Text,
  View,
} = React;

class helloworld extends React.Component {

  render() {
    var didLoadAd = function() { console.log('Ad loaded') };
    var didFailToReceiveAdWithError = function() { console.log('Error loading ad') };

    return (
      <View style={styles.stage}>
        <View style={styles.container}>
          <Text style={styles.welcome}>
            Welcome to React Native!
          </Text>
          <Text style={styles.instructions}>
          To get started, edit index.ios.js
          </Text>
          <Text style={styles.instructions}>
            Press Cmd+R to reload,{'\n'}
            Cmd+D or shake for dev menu
          </Text>
        </View>
        <ADBannerView didLoadAd={didLoadAd} didFailToReceiveAdWithError={didFailToReceiveAdWithError} />
      </View>
    );
  }
};

var styles = StyleSheet.create({
  stage: {
    flex: 1,
  },
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },

});

AppRegistry.registerComponent('helloworld', () => helloworld);

Known Issues

  • The component doesn't resize after a device orientation change

react-native-adbannerview's People

Contributors

catalinmiron avatar purii avatar

Watchers

 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.