Reputation: 3075
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
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
Reputation: 8959
The steps to use Admob with Ionic framework would be:
Add com.admob.google plugin:
ionic plugin add com.admob.google
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>
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