1.4.0 • Published 9 years ago

react-native-adbannerview v1.4.0

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

react-native-adbannerview

Build Status 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 LibrariesAdd 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 PhasesLink Binary With Libraries (libADBannerViewManager.a)

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

Usage

import ADBannerView from '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

EventDescription
didFailToReceiveAdWithErrorError loading banner
willLoadAdBefore a new banner ad is loaded
didLoadAdWhen a new banner ad is loaded
actionDidFinishAfter banner view finishes executing an action

Example

npm.io

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 */
import React, {
  Component,
}
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
} from 'react-native';

import ADBannerView from 'react-native-adbannerview';

class Example extends Component {
  didLoadAd () {
    console.log('Ad loaded')
  }
  didFailToReceiveAdWithError() {
    console.log('Error loading ad')
  }
  render() {
    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={this.didLoadAd} didFailToReceiveAdWithError={this.didFailToReceiveAdWithError} willLoadAd={() => {}}/>
      </View>
    );
  }
};

const 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('example', () => Example);

Run example

  1. Clone repo
  2. cd example
  3. npm i
  4. Xcode: hit build and run
1.4.0

9 years ago

1.3.0

10 years ago

1.2.0

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago