El complemento crea el objeto. webtoappx.admob
Actualmente se admiten los siguientes tipos de códigos de barras:
Features
initialize targeting
global SettingsAppTrackingTransparency (ATT)CMP SDKUMP SDKApp Open AdsBanner AdsInterstitial AdsRewarded AdsMediationimpression-level-ad-revenue
Methods
webtoappx.admob.globalSettings([config_globalSettings]);
webtoappx.admob.targeting([config_Targeting]);
webtoappx.admob.initialize();
webtoappx.admob.getConsentRequest();
webtoappx.admob.consentReset();
webtoappx.admob.showPrivacyOptionsForm();
webtoappx.admob.getIabTfc((IABTFC) => { console.log(JSONstringify(IABTFC)) });
setDebugGeography
La prueba es muy fácil, no se necesita VPN, TEST-DEVICE-HASHED-ID ni nada más, todo se ha realizado mediante programación.
debe ser falso si la aplicación se lanza a Play Store/App Store. Se seguirá llamando al consentimiento de independientemente de su estado 0,1,2,3, hasta que el valor cambie a falso.
setDebugGeography = verdadero | FALSO
Ejemplo
document.addEventListener("deviceready", function(){ const config_globalSettings = [ setAppMuted = false, // default: false setAppVolume = 1, // float: default: 1 enableSameAppKey = false, // default: false npa = "1", // string "0" | "1" enableCollapsible = true, // (BETA) activate the collapsible banner ads responseInfo = false, // default: false setDebugGeography = false // default: false ] webtoappx.admob.getConsentRequest( (ststus) => { console.log("Consent Status: " + ststus) }); webtoappx.admob.globalSettings(config_globalSettings); document.addEventListener('on.get.consent.status', () => { // Regardless of the state, call SDK initialize webtoappx.admob.initialize(); webtoappx.admob.getIabTfc((IABTFC) => { console.log(JSONstringify(IABTFC)) }); }); }, false);
Event UMP SDK
on.get.consent.status
Ejemplo
document.addEventListener('on.get.consent.status', () => { console.log("on get consent status"); });
Event CMP SDK
on.get.consent.status
on.get.consent.status
on.get.consent.status
TCString caduca a los 360 días, el complemento lo elimina automáticamente después de 360 días. llamar al consentimientoRest()
document.addEventListener('on.TCString.expired', () => { console.log("on TCString expires 360 days"); webtoappx.admob.consentReset(); });
Global Variable adunitId
<script> // Ad format Demo ad unit ID // https://developers.google.com/admob/android/test-ads var App_Open_ID; var Banner_ID; var Interstitial_ID; var Rewarded_ID; var Rewarded_Interstitial_ID; App_Open_ID = 'ca-app-pub-3940256099942544/9257395921'; Banner_ID = 'ca-app-pub-3940256099942544/6300978111'; Interstitial_ID = 'ca-app-pub-3940256099942544/1033173712'; Rewarded_ID = 'ca-app-pub-3940256099942544/5224354917'; Rewarded_Interstitial_ID = 'ca-app-pub-3940256099942544/5354046379'; </script>
AppOpenAd ADS
Methods
webtoappx.admob.loadAppOpenAd([config_AppOpenAd]);
webtoappx.admob.showAppOpenAd();
Ejemplo
// WARNING config must be an array[] not an object{} // adUnitId = call Global Variable webtoappx.admob.loadAppOpenAd([ adUnitId = App_Open_ID, autoShow = true ]);
Events
on.appOpenAd.loaded
on.appOpenAd.failed.loaded
on.appOpenAd.dismissed
on.appOpenAd.failed.show
on.appOpenAd.show
on.appOpenAd.revenue
Ejemplo
document.addEventListener('on.appOpenAd.loaded', () => { console.log("On App Open Ad loaded"); });
BANNER ADS
Methods
webtoappx.admob.loadBannerAd([bannerConfig]);
webtoappx.admob.showBannerAd();
webtoappx.admob.hideBannerAd();
webtoappx.admob.removeBannerAd();
Ejemplo
// WARNING config must be an array[] not an object{} // adUnitId = call Global Variable const bannerConfig = [ adUnitId = Banner_ID, position = "bottom-center", size = "BANNER", collapsible = "bottom", // (BETA) enable in globalSettings adaptive_Width = 320, // Ignored autoShow = true // boolean ] webtoappx.admob.loadBannerAd(bannerConfig);
Position type string
top-right
top-center
left
center
right
bottom-center
bottom-right
Size type string
ANCHORED
IN_LINE
FULL_WIDTH
BANNER
FLUID
LARGE_BANNER
MEDIUM_RECTANGLE
FULL_BANNER
LEADERBOARD
adaptive_Width = number
Events
on.banner.load
on.banner.failed.load
on.banner.click
on.banner.close
on.banner.impression
on.banner.open
on.banner.revenue
on.banner.remove
on.banner.hide
Ejemplo
document.addEventListener('on.banner.load', () => { console.log("on banner load"); });
Interstitial ADS
Methods
webtoappx.admob.loadInterstitialAd([config_Interstitial]);
webtoappx.admob.showInterstitialAd();
Ejemplo
// WARNING config must be an array[] not an object{} // adUnitId = call Global Variable webtoappx.admob.loadInterstitialAd([ adUnitId = Interstitial_ID, autoShow = true ])
Events
on.interstitial.loaded
on.interstitial.failed.load
on.interstitial.click
on.interstitial.dismissed
on.interstitial.failed.show
on.interstitial.impression
on.interstitial.show
on.interstitial.revenue
Ejemplo
document.addEventListener('on.interstitial.loaded', () => { console.log("on interstitial Ad loaded"); });
Rewarded Interstitial ADS
Methods
webtoappx.admob.loadRewardedInterstitialAd([config_rewardedInt]);
webtoappx.admob.showRewardedInterstitialAd();
Ejemplo
// WARNING config must be an array[] not an object{} // adUnitId = call Global Variable webtoappx.admob.loadRewardedInterstitialAd([ adUnitId = Rewarded_Interstitial_ID, autoShow = true ]);
Events
on.rewardedInt.loaded
on.rewardedInt.failed.load
on.rewardedInt.click
on.rewardedInt.dismissed
on.rewardedInt.failed.show
on.rewardedInt.impression
on.rewardedInt.showed
on.rewardedInt.userEarnedReward
on.rewardedInt.revenue
on.rewardedInt.ad.skip
Ejemplo
document.addEventListener('on.rewardedInt.loaded', () => { console.log("on rewarded Interstitial load"); });
Rewarded ADS
Methods
webtoappx.admob.loadRewardedAd([config_rewarded]);
webtoappx.admob.showRewardedAd();
Ejemplo
// adUnitId = call Global Variable webtoappx.admob.loadRewardedAd([ adUnitId = Rewarded_ID, autoShow = true ]);
Events
on.rewarded.loaded
on.rewarded.failed.load
on.rewarded.click
on.rewarded.dismissed
on.rewarded.failed.show
on.rewarded.impression
on.rewarded.show
on.reward.userEarnedReward
on.rewarded.revenue
on.rewarded.ad.skip
Ejemplo
document.addEventListener('on.rewarded.loaded', () => { console.log("on rewarded Ad loaded"); });
IAB Europe Transparency & Consent Framework
Example How to read consent choices
Ejemplo
// >>>>>>>> New features (UMP) SDK v2.1.0 // https://developers.google.com/admob/android/privacy/gdpr /* If the user chooses not to display ads, you can restrict access to the app, or ban it, until they change their decision back, Just call showPrivacyOptionsForm(); */ webtoappx.admob.getIabTfc( (info) => { // How to read consent choices console.log("IABTCF_gdprApplies: " + info.IABTCF_gdprApplies); console.log("IABTCF_PurposeConsents: " + info.IABTCF_PurposeConsents); console.log("IABTCF_TCString: " + info.IABTCF_TCString); // A small example var fundingChoices; fundingChoices = info.IABTCF_PurposeConsents; if (fundingChoices === "1111111111"){ // Enable app features. loadRewardedAd(); } else if (fundingChoices === "") { // disable app features. } else { // You have to test everything yourself. console.log(info); } }, (error) => { console.log("Error: " + error); } );;