-
Notifications
You must be signed in to change notification settings - Fork 122
Angular.js, Ionic apps
Miquel Martín edited this page Jan 7, 2015
·
17 revisions
This plugin is designed to support Ionic apps, which are based in Angular.js.
Include the following script in your index.html (just it, no need to copy any file: the plugin is in charge to copy the script when the app is prepared):
<script src="lib/angular-admob/angular-admob.js"></script>Here is a quick example on how to use Admob plugin with Angular.js based apps, for example Ionic:
var app = angular.module('myApp', ['admobModule']);
app.config(['admobSvcProvider', function (admobSvcProvider) {
// Optionally you can configure the options here:
admobSvcProvider.setOptions({
publisherId: "ca-app-pub-8440343014846849/3119840614", // Required
interstitialAdId: "ca-app-pub-8440343014846849/4596573817", // Optional
tappxIdiOs: "/120940746/Pub-2702-iOS-8226", // Optional
tappxIdAndroid: "/120940746/Pub-2700-Android-8171", // Optional
tappxShare: 0.5 // Optional
});
// Optionally configure the events prefix (by default set to 'admob:')
admobSvcProvider.setPrefix('myTag~');
}]);
app.run(['admobSvc', function (admobSvc) {
// Also you could configure the options here (or in any controller):
// admobSvcProvider.setOptions({ ... });
admobSvc.createBannerView();
// You could also call admobSvc.createBannerView(options);
// Handle events:
$rootScope.$on('myTag~' + admobSvc.events.onAdOpened, function onAdOpened(evt, e) {
console.log('adOpened: type of ad:' + e.adType);
});
// The default prefix for events is 'admob:'
// $rootScope.$on('admob:' + admobSvc.events...
}]);