I am trying to add this admob plugin https://github.com/Dharmoslap/ng-cordova in my ionic app but i can’t really find a step by step guide to get it work.
Have someone ever successfuly used this plugin?
please help me if possible.
I am trying to add this admob plugin https://github.com/Dharmoslap/ng-cordova in my ionic app but i can’t really find a step by step guide to get it work.
Have someone ever successfuly used this plugin?
please help me if possible.
Did you wrap your plugin call with deviceready
event? http://ngcordova.com/docs/common-issues/
I tried it like this in app.js after i added plugin with cordova plugin add com.google.cordova.admob
$ionicPlatform.ready(function() {
$cordovaAdMobPro.setOptions({
adId: 'ca-app-pub-6869992474017983/4806197152',
position:8,
autoShow:true,
isTesting: true
});
});
but i get
Uncaught ReferenceError: $cordovaAdMobPro is not defined
First off its $cordovaAdMob
not $cordovaAdMobPro
Are you injecting $cordovaAdMob
into your .run
or .controller
?
Thank you all for your reply. i managed to get it work. here is how i processed for developers facing same problem.
I started dig into the ionic project plugin file (assets/www/cordova_plugins.js) and find out i could access the plugin by calling window.AdMob inside my app.js
NOTE : i only used it for the android platform, therefore it’ll only work with android platform but i think it’s easy to add ios and windowsphone support.
i simply added the following code to my app.js inside a deviceReady event Listener the code is from the official AdMob Pro Cordova plugin https://github.com/floatinghotpot/cordova-admob-pro
the code is inside the .config(function($cordovaAppRateProvider, $ionicConfigProvider, $stateProvider, $urlRouterProvider) {....
here is the code
//admob
document.addEventListener("deviceready", function () {
admobid = {
banner: 'ca-app-pub-XXXXXXXXXXXXXX/XXXXXXXXX',
interstitial: 'ca-app-pub-XXXXXXXXXXXX/XXXXXXXXXXXX'
};
window.AdMob.createBanner( {
adId: admobid.banner,
position: window.AdMob.AD_POSITION.BOTTOM_CENTER,
autoShow: true } );
window.AdMob.prepareInterstitial( {adId:admobid.interstitial, autoShow:false} );
window.AdMob.showInterstitial();
}, false);
with this i get the banner and the interstitial ads work perfectly in my app. It’s not as much as elegant i would like but it works.
Thank U all.
Hi,
I follow http://pointdeveloper.com/ionic-2-banner-ads-with-admob-pro-plugin/ step by step but stick in step two.
error whenionic plugin add com.google.cordova.admob
D:\GitHub\ionic2Banner>ionic plugin add com.google.cordova.admob
Error: Registry returned 404 for GET on https://registry.npmjs.org/com.google.cordova.admob
D:\GitHub\ionic2Banner>