Skip to content

06. How To Use with Meteor

Kyle Pierce edited this page Nov 29, 2015 · 7 revisions

Tools Required

  • Cordova, [sudo] npm install -g cordova
  • Meteor, [sudo] npm install -g meteor

Add Plugin

Add plugin: meteor add cordova:[email protected]

Replace x.x.x with current version number, see the version here: https://www.npmjs.com/package/cordova-plugin-admobpro

Run the simluator (iOS): meteor run ios

or (Android), meteor run android

Example Code

Also, make sure that your code is in Meteor.startup(), to ensure that the Cordova plugin is available.

Meteor.startup(function () {
  if (Meteor.isCordova) {
    if (AdMob) {
      AdMob.createBanner( {
        adId: 'ca-app-pub-xxx/xxx',
        position: AdMob.AD_POSITION.BOTTOM_CENTER,
        isTesting: true,
        autoShow: true,
        success: function() {
          console.log("Received ad");
        },
        error: function() {
          console.log("No ad received");
        }
      });
    } else {
      console.log("No Admob");
    }
  } else {
    console.log("No Cordova ");
  }
});