Closed Kaybarax closed 8 years ago
Is this an error or a warning? Eg does it compile and run? It looks like a problem with the Cordova lib, not our plugin.
Yes, I think it's a problem with Cordova lib. It compiles some time and at others it doesn't. Also, even when it compiles, it does not pull the ads. Can you please provide a full working example, it would be helpful. On 9 Jul 2016 22:04, "Sunny Cupertino" notifications@github.com wrote:
Is this an error or a warning? Eg does it compile and run? It looks like a problem with the Cordova lib, not our plugin.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sunnycupertino/cordova-plugin-admob-simple/issues/4#issuecomment-231550325, or mute the thread https://github.com/notifications/unsubscribe/ANr57qEo2xguR6c-bLd2LWgQ7r5tE7Acks5qT_C1gaJpZM4JIorh .
Are you using Android Studio or Eclipse? Also with Cordova do you have the latest version from npm? Also is this Android or iOS?
I'm using Cordova CLI 6.2.0 (the latest), android SDK (I've fully updated it), JDK 1.8.0_72/4, and Genymotion emulator, as well my android phone device (lollipop 5.1)for on device testing, and yes I also have good internet. So, perhaps the only other problem could be that I'm implementing the plugin wrongly? On 9 Jul 2016 23:03, "Sunny Cupertino" notifications@github.com wrote:
Are you using Android Studio or Eclipse? Also with Cordova do you have the latest version from npm? Also is this Android or iOS?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sunnycupertino/cordova-plugin-admob-simple/issues/4#issuecomment-231553093, or mute the thread https://github.com/notifications/unsubscribe/ANr57q22a3N0SomDC7xBzsI6kq791_yOks5qT_52gaJpZM4JIorh .
Do you use test ads or normal ads? Maybe you can share your .js file here I can check it.
The "ca-app-pub" is mine from my created test from admob
function initAd(){
if ( window.plugins && window.plugins.AdMob ) {
var ad_units = {
ios : {
banner: 'ca-app-pub-4464528421559840/6460817214',
interstitial: 'ca-app-pub-4464528421559840/6460817214'
},
android : {
banner: 'ca-app-pub-4464528421559840/6460817214',
interstitial: 'ca-app-pub-4464528421559840/6460817214'
}
};
var admobid = ( /(android)/i.test(navigator.userAgent) ) ? ad_units.android : ad_units.ios;
window.plugins.AdMob.setOptions( {
publisherId: admobid.banner,
interstitialAdId: admobid.interstitial,
bannerAtTop: false, // set to true, to put banner at top
overlap: false, // set to true, to allow banner overlap webview
offsetTopBar: false, // set to true to avoid ios7 status bar overlap
isTesting: false, // receiving test ad
autoShow: true // auto show interstitial ad when loaded
});
} else {
//alert( 'admob plugin not ready' );
}
}
function registerAdEvents() {
document.addEventListener('onReceiveAd', function(){});
document.addEventListener('onFailedToReceiveAd', function(data){});
document.addEventListener('onPresentAd', function(){});
document.addEventListener('onDismissAd', function(){ });
document.addEventListener('onLeaveToAd', function(){ });
document.addEventListener('onReceiveInterstitialAd', function(){ });
document.addEventListener('onPresentInterstitialAd', function(){ });
document.addEventListener('onDismissInterstitialAd', function(){ });
}
function showAdsFunc(){
//alert("show ads");
if ( window.plugins && window.plugins.AdMob )
window.plugins.AdMob.createBannerView();
}
function showInterstitialFunc(){
//alert("interstitial");
if ( window.plugins && window.plugins.AdMob )
window.plugins.AdMob.createInterstitialView();
}
function onDeviceReady()
{
initAd();
showAdsFunc();
showInterstitialFunc();
}
document.addEventListener('deviceready' onDeviceReady, false);
It looks fine to me. Try set isTesting to true and see how it goes. I noticed sometimes when you are testing your own ads, if you request real ads and google realizes you are not a real customer, they sometimes do not serve them. If it gets test ads ok, it should be fine.
Even then it is still not working. Can you maybe provide with a working sample example?
Sure. If you make a new app from scratch, add the plugin, and then replace the index.js with this
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
initAd();
showBannerFunc();
showInterstitialFunc();
console.log('Received Event: ' + id);
}
};
//display the banner
function showBannerFunc(){
window.plugins.AdMob.createBannerView();
}
//display the interstitial
function showInterstitialFunc(){
window.plugins.AdMob.createInterstitialView(); //get the interstitials ready to be shown and show when it's loaded.
window.plugins.AdMob.requestInterstitialAd();
}
//initialize the goodies
function initAd(){
if ( window.plugins && window.plugins.AdMob ) {
var ad_units = {
ios : {
banner: 'ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx', //PUT ADMOB ADCODE HERE
interstitial: 'ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx' //PUT ADMOB ADCODE HERE
},
android : {
banner: 'ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx', //PUT ADMOB ADCODE HERE
interstitial: 'ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx' //PUT ADMOB ADCODE HERE
}
};
var admobid = ( /(android)/i.test(navigator.userAgent) ) ? ad_units.android : ad_units.ios;
window.plugins.AdMob.setOptions( {
publisherId: admobid.banner,
interstitialAdId: admobid.interstitial,
adSize: window.plugins.AdMob.AD_SIZE.SMART_BANNER, //use SMART_BANNER, BANNER, IAB_MRECT, IAB_BANNER, IAB_LEADERBOARD
bannerAtTop: false, // set to true, to put banner at top
overlap: true, // banner will overlap webview
offsetTopBar: false, // set to true to avoid ios7 status bar overlap
isTesting: false, // receiving test ad
autoShow: true // auto show interstitial ad when loaded
});
registerAdEvents();
} else {
//alert( 'admob plugin not ready' );
}
}
//functions to allow you to know when ads are shown, etc.
function registerAdEvents() {
document.addEventListener('onReceiveAd', function(){});
document.addEventListener('onFailedToReceiveAd', function(data){});
document.addEventListener('onPresentAd', function(){});
document.addEventListener('onDismissAd', function(){ });
document.addEventListener('onLeaveToAd', function(){ });
document.addEventListener('onReceiveInterstitialAd', function(){ });
document.addEventListener('onPresentInterstitialAd', function(){ });
document.addEventListener('onDismissInterstitialAd', function(){ });
}
app.initialize();
It has totally refused, so I'm gonna try out other options
CordovaLib:compileReleaseJavaWithJavacNote: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details