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
- 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 thegetPackages()
method
- 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')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:implementation project(':react-native-gdt')
Usage
- Splash 广告示例
; <GDTSplash style=flex: 1 onFailToReceived= { console; } onNextAction= { //下一步路由动作 } showLogo=true appInfo=appId: '1101152570' posId: '8863364436303842593' fetchDelay=4000/>
- Banner 广告示例
<GDTBanner style=height: 64 onReceived= { } onViewWillExposure= { } onFailToReceived= console showCloseBtn=false appInfo=appId: '1101152570' posId: '9079537218417626401'/>
- Banner2.0 广告示例
<GDTUnifiedBanner style=height: 66 onReceived= { } onViewWillExposure= { } onFailToReceived= console interval=50 appInfo=appId: '1101152570' posId: '4080052898050840' />
- 插屏 广告示例
<TouchableOpacity activeOpacity=09 onPress= { GDTModule; }> <Text style=color: 'black' fontSize: 12>插屏广告</Text></TouchableOpacity>
- 插屏2.0 广告示例
<TouchableOpacity activeOpacity=09 onPress= { GDTModule; }> <Text style=color: 'black' fontSize: 12>插屏20广告</Text></TouchableOpacity>
- HYBRID广告示例
<TouchableOpacity activeOpacity=09 onPress= { GDTModule; }> <Text style=color: 'black' fontSize: 12>HYBRID广告</Text></TouchableOpacity>
License
MIT