Hi, sorry for my English I speak (Spanish).
I’ve tried all ways and do not get it, so now I ask for help.
What I am doing is the following…
The ad appears, but 2 seconds and disappears and is not seen again, only appears when you start the Application, then falls back to.
hope you can help me, thanks.
The plugin is https://github.com/floatinghotpot/cordova-plugin-admob
But also has a pro version with more options, but not how it works https://github.com/floatinghotpot/cordova-admob-pro
Steps I followed
- ionic platform add android
- cordova plugin add https://github.com/MobileChromeApps/google-play-services.git
- cordova plugin add https://github.com/floatinghotpot/cordova-plugin-admob.git
Code the controller - >> function controller ($ionicPlatform, $ionicPopup) info
$ionicPlatform.ready(function() {
if(window.plugins && window.plugins.AdMob) {
var admob_key = device.platform == "Android" ? "ANDROID_PUBLISHER_KEY" : "IOS_PUBLISHER_KEY";
var admob = window.plugins.AdMob;
admob.createBannerView(
{
'publisherId': admob_key,
'adSize': admob.AD_SIZE.BANNER,
'bannerAtTop': false
},
function() {
admob.requestAd(
{ 'isTesting': false },
function() {
admob.showAd(true);
},
function() { console.log('failed to request ad'); }
);
},
function() { console.log('failed to create banner view'); }
);
}
});
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="lib/dist/ng-cordova.js"></script>
<script src="cordova.js"></script>
<script src="js/app.js"></script>
</head>
<body ng-app="starter" on-swipe-right="" on-swipe-left="" >
<ion-nav-view name="appView" animation="slide-left-right"></ion-nav-view>
</body>
<script id="app" type="text/ng-template">
<ion-view title="app">
</ion-view>
</script>
<script id="img1.html" type="text/ng-template">
<ion-content ng-init="ini(1)" class="content">
<img src="{{img1}}">
</ion-content>
</script>
<script id="img2.html" type="text/ng-template">
<ion-content ng-init="ini(2)" class="content">
<img src="{{img2}}">
</ion-content>
</script>
<script id="img3.html" type="text/ng-template">
<ion-content ng-init="ini(3)" class="content">
<img src="{{img3}}">
</ion-content>
</script>
</html>