Jsncrdnl
Jsncrdnl

Reputation: 3075

ngCordova AdMob Plugin implemention

I would like to implement adMob in my ionic projet.

Therefore I'm having a look at the ngCordova projet which is including an adMob plugin. But there aren't any implementation sample available yet...

Did anyone already use that plugin from ngCordova and show me a working code sample ?

Upvotes: 2

Views: 1054

Answers (2)

Jsncrdnl
Jsncrdnl

Reputation: 3075

I used the tutorial from https://www.thepolyglotdeveloper.com/2014/06/using-admob-ionicframework/ to implement admob. This wasn't working in my project.

So I started a brand new (clean) workspace before implementing the admob network.
And that simply did it !

Upvotes: 3

Miquel
Miquel

Reputation: 8959

The steps to use Admob with Ionic framework would be:

  1. Add com.admob.google plugin:

    ionic plugin add com.admob.google

  2. Add the following script to www/index.html (you will not find the angular-admob.js file in development, as it is added after preparing each platform):

    <script src="lib/angular-admob/angular-admob.js"></script>

  3. Show admob ads:

-

angular.module('myApp', ['admobModule'])
.run(['admobSvc', function (admobSvc) {
  admobSvc.createBannerView({ publisherId: "YOUR_PUBLISHER_ID" });

  // Handle events:
  $rootScope.$on('admob:' + admobSvc.events.onAdOpened, function onAdOpened(evt, e) {
    console.log('adOpened: type of ad:' + e.adType);
  });
}]);

Here you can find the complete example: admob with ionic framework.

Upvotes: 2

Related Questions