简体   繁体   中英

cordova-plugin-ad-admob via phonegap build,unable to load and show ads

I am using this plugin: https://github.com/cranberrygame/cordova-plugin-ad-admob

Hi, I'm a total newbie - just to warn you, my level of understanding beyond javascript/html is minimal and I have no native experience. I'm building through the phonegap build service.

I have the plugin loaded onto my phonegap app.

it's building okay, I've checked that.

In the javascript it's setting all the bannerAdUnit+interstitialAdUnit+rewardedVideoAdUnit+isOverlap+isTest variables correctly

it doesnt throw up an error doing the

window.admob.setUp(bannerAdUnit, interstitialAdUnit, rewardedVideoAdUnit, 
isOverlap, isTest)

but using try-catches to alert me, it's throwing up errors with:

window.admob.preloadInterstitialAd();
window.admob.showInterstitialAd();
window.admob.preloadRewardedVideoAd();
window.admob.showRewardedVideoAd();

because i'm doing all the build through phonegap (i have zero android native experience or knowledge) all i know is that there is an error, but not where it's coming from.

Does anyone have any pointers as to where the issues might be coming from, things i could try to rule out?

Thanks in advance,

I advice you not to use third party plugins for services like admob/in-App Purchase.

use official admob plugin for cordova/phonegap. https://github.com/admob-google/admob-cordova

It is easy and well documented.

I fixed this by:

1) adding an explicit reference to cordova.js in my index.html

<script src="cordova.js"></script>

and also I had to remove my content declaration

<meta http-equiv="Content-Security-Policy" content="default-src * data: gap: 'unsafe-inline' 'unsafe-eval'; style-src * 'unsafe-inline'; media-src *" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM