项目作者: MoAsmar

项目描述 :
Ionic app with google admob integration (cordova admob plugin free)
高级语言: CSS
项目地址: git://github.com/MoAsmar/ionic-admob-demo.git
创建时间: 2018-08-11T07:23:27Z
项目社区:https://github.com/MoAsmar/ionic-admob-demo

开源协议:

下载


ionic-admob-demo

A demo ionic app with Google AdMob Advertisements integrated.

Getting Started

  1. Download as zip or clone the project using:
    1. git clone https://github.com/MoAsmar/ionic-admob-demo.git
  2. cd to your project and run npm install .
  3. Run the following commands to install the AdMob Free plugin:
    1. cordova plugin add cordova-plugin-admob-free --save
    2. cordova plugin add cordova-admob-sdk
    3. npm install @ionic-native/admob-free --save
  4. add the platform for the app to run on your device: ionic cordova platform add android for android devices.
    Use ionic cordova platform add ios for ios devices.

Prerequisites

-Ionic version 3.1.0.

-cordova (built with version 8.0.0).

Installing

connect your device and run the command:

  1. ionic cordova run android

then the app will start you will see two buttons.

Show Banner will popup the banner:

Show Interstitial will show the full screen interstital:

Prepare for production

set property isTesting to false and copy the banner Ad Unit ID from your admob and past it under id property as below example:

  1. showBanner() {
  2. let bannerConfig: AdMobFreeBannerConfig = {
  3. isTesting: false, // Remove in production
  4. autoShow: true,
  5. id: 'ca-app-pub-xxxxxxxxx'
  6. };
  7. this.admob.banner.config(bannerConfig);
  8. this.admob.banner.prepare().then(() => {
  9. // success
  10. }).catch(e => console.log(e));
  11. }

note: for interstital ads do the same but copy the interstitial id from admob and add it under launchInterstitial() method.

for more options and settings, check the admob free plugin documentation

Acknowledgments