Giter Site home page Giter Site logo

react-native-gdt's Introduction

react-native-gdt

Getting started

$ npm install react-native-gdt-ad --save

Mostly automatic installation

$ react-native link react-native-gdt-ad

Manual installation

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import cn.cnlee.commons.CommonPackage; to the imports at the top of the file
  • Add new CommonPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-gdt'
    project(':react-native-gdt').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-gdt/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      implementation project(':react-native-gdt')
    

Usage

  1. Splash 广告示例
import GDT from 'react-native-gdt-ad';

<GDT.Splash style={{flex: 1}}
   onFailToReceived={(error) => {
       console.log(error);
   }}
   onNextAction={() => {
       //下一步路由动作
   }}
   showLogo={true}
   appInfo={{appId: '1101152570', posId: '8863364436303842593'}}
   fetchDelay={4000}
/>
  1. Banner 广告示例
<GDT.Banner style={{height: 64}}
   onReceived={() => {
   }}
   onViewWillExposure={() => {
   }}
   onFailToReceived={(err) => console.log(err)}
   showCloseBtn={false}
   appInfo={{appId: '1101152570', posId: '9079537218417626401'}}
/>
  1. Banner2.0 广告示例
<GDT.UnifiedBanner style={{height: 66}}
   onReceived={() => {
   }}
   onViewWillExposure={() => {
   }}
   onFailToReceived={(err) => console.log(err)}
   interval={50}
   appInfo={{appId: '1101152570', posId: '4080052898050840'}}
 />
  1. 插屏 广告示例
<TouchableOpacity
    activeOpacity={0.9}
    onPress={() => {
        GDT.Module.showInterstitialAD('1101152570', '8575134060152130849', true);
    }}>
    <Text style={{color: 'black', fontSize: 12,}}>插屏广告</Text>
</TouchableOpacity>
  1. 插屏2.0 广告示例
<TouchableOpacity
    activeOpacity={0.9}
    onPress={() => {
        GDT.Module.showUnifiedInterstitialAD('1101152570', '3040652898151811', true);
    }}>
    <Text style={{color: 'black', fontSize: 12,}}>插屏2.0广告</Text>
</TouchableOpacity>
  1. HYBRID广告示例
<TouchableOpacity
    activeOpacity={0.9}
    onPress={() => {
        GDT.Module.openWeb('1101152570', 'http://m.baidu.com', {title: '测试标题', titleBarHeight: 45, titleSize: 20, titleColor: '#ff0000ff'});
    }}>
    <Text style={{color: 'black', fontSize: 12,}}>HYBRID广告</Text>
</TouchableOpacity>

License

MIT

react-native-gdt's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-native-gdt's Issues

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.