Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting "Admob plugin not ready" #48

Closed
chinyart opened this issue Apr 23, 2019 · 9 comments
Closed

Getting "Admob plugin not ready" #48

chinyart opened this issue Apr 23, 2019 · 9 comments

Comments

@chinyart
Copy link

chinyart commented Apr 23, 2019

Hi, i am getting this alert from the plugin, that the plugin is not ready
AndriodManifest.xml:
`

    <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-4671871274849807~5196675847" />
    <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:name="com.google.android.gms.ads.AdActivity" android:theme="@android:style/Theme.Translucent" />
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
`

index.js:

    initAd()
showBannerFunc()
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-4671871274849807/8704622113',		//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, LARGE_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(){ });
}

//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();
}

I would appreciate any assistance or idea on how to tackle this issue

@sunnycupertino
Copy link
Owner

I would try put an interstitial add id in there as well.

@chinyart
Copy link
Author

okay.....let me give that a try....thanks

@chinyart
Copy link
Author

chinyart commented Apr 23, 2019

i have added the interstitial id to the app
i am still getting the message "Admob plugin is not ready"

below is a screenshot:
https://nedumstudios.com/vghdhfufdygifydgkh_images/admob.png

is there something i am missing?
This app is not yet on google play though, could that be the reason for the message?

@sunnycupertino
Copy link
Owner

Where is initAd() being called? You have to call it after the cordovaready event.

@chinyart
Copy link
Author

chinyart commented Apr 23, 2019

Below are snapshots of my html and js code:

this one is the arrangement of my libraries
cordova.js is above a file custom.js where i kept the function and called initAd()
https://nedumstudios.com/vghdhfufdygifydgkh_images/bug4.PNG

this one is the image of the function calling the banner ads
https://nedumstudios.com/vghdhfufdygifydgkh_images/bug5.PNG

while this one is the image of the custom.js file where i call the initAd()
https://nedumstudios.com/vghdhfufdygifydgkh_images/custom.PNG

@sunnycupertino
Copy link
Owner

Initad() needs to be called when the document is ready, and not before. That is why it's failing.

@chinyart
Copy link
Author

Hi @sunnycupertino i called the initAd() after document is ready not before
below is the link with the updated screenshot

https://nedumstudios.com/vghdhfufdygifydgkh_images/custom.PNG

i would appreciate if you would help resolve this issue.

@sunnycupertino
Copy link
Owner

I'm sorry it's not up to us to debug your code. But at a glance it looks odd what you have done. You have multiple document ready calls, and even functions defined within functions, all if this is out of the ordinary and I have no idea how this kind of thing will behave.

@chinyart
Copy link
Author

chinyart commented Apr 24, 2019

yeah i noticed that too, got that fixed though
i opened a new issue, that is the latest bug/issue i am facing, i got everything in place

checked if the app recognizes the plugin, it does but no ads displaying at all

here is the link to the newly opened issue
#50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants