diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d54921..b202ad4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# [0.6.1] - 2020-02-13 +### Added +- Added AD_PROVIDER_LOADED event to every provider. + # [0.6.0] - 2020-01-30 ### Added - Gamedock cordova ad provider diff --git a/package-lock.json b/package-lock.json index fba170d..cc7d127 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@azerion/h5-ad-wrapper", - "version": "0.6.0", + "version": "0.6.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index d93b4b9..849fdd8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@azerion/h5-ad-wrapper", "author": "Azerion", - "version": "0.6.0", + "version": "0.6.1", "description": "Advertisement provider wrapper, similar to @azerion/phaser-ads but not tied into Phaser :)", "contributors": [ { diff --git a/src/Providers/cocoon.ts b/src/Providers/cocoon.ts index a5afb66..0a76b5a 100644 --- a/src/Providers/cocoon.ts +++ b/src/Providers/cocoon.ts @@ -31,12 +31,13 @@ export class CocoonAds implements IProvider { constructor(provider: CocoonProvider, config?: any) { // TODO: Add cordova check - if (Cocoon && Cocoon.Ad) { - this.adsEnabled = true - } else { + if (!Cocoon || !Cocoon.Ad) { + this.adManager.emit(AdEvents.AD_PROVIDER_LOADED) return } + this.adsEnabled = true + switch (provider) { default: case CocoonProvider.AdMob: @@ -54,6 +55,7 @@ export class CocoonAds implements IProvider { } this.cocoonProvider.configure(config) + this.adManager.emit(AdEvents.AD_PROVIDER_LOADED) } public setManager(manager: H5AdWrapper): void { diff --git a/src/Providers/cordova-gamedistribution.ts b/src/Providers/cordova-gamedistribution.ts index 1e347de..f500de4 100644 --- a/src/Providers/cordova-gamedistribution.ts +++ b/src/Providers/cordova-gamedistribution.ts @@ -14,6 +14,7 @@ export class CordovaGamedistribution implements IProvider { (cordova.plugins !== undefined && cordova.plugins.gdApi === undefined) ) { console.log('gdApi not available!') + this.adManager.emit(AdEvents.AD_PROVIDER_LOADED) return } @@ -31,6 +32,8 @@ export class CordovaGamedistribution implements IProvider { console.log('API init error!', error) } ) + + this.adManager.emit(AdEvents.AD_PROVIDER_LOADED) } private setAdListeners(): void { diff --git a/src/Providers/cordova-gamedock.ts b/src/Providers/cordova-gamedock.ts index 90f9f49..3e25453 100644 --- a/src/Providers/cordova-gamedock.ts +++ b/src/Providers/cordova-gamedock.ts @@ -21,6 +21,7 @@ export class CordovaGamedock implements IProvider { */ constructor() { if (typeof gamedockSDK === 'undefined') { + this.adManager.emit(AdEvents.AD_PROVIDER_LOADED) return } @@ -33,7 +34,7 @@ export class CordovaGamedock implements IProvider { // Calls AD_PROVIDER_LOADED on PrivacyPolicyStatus with flag accepted. gamedockSDK.on('PrivacyPolicyStatus', (data: any) => { - this.adManager.emit(AdEvents.AD_PROVIDER_LOADED, data.accepted) + this.adManager.emit(AdEvents.AD_PROVIDER_LOADED) }) // Initialize the gamedockSDK. diff --git a/src/Providers/cordova-heyzap.ts b/src/Providers/cordova-heyzap.ts index c594cd8..2619251 100644 --- a/src/Providers/cordova-heyzap.ts +++ b/src/Providers/cordova-heyzap.ts @@ -21,6 +21,8 @@ export class CordovaHeyzap implements IProvider { this.adsEnabled = false } ) + + this.adManager.emit(AdEvents.AD_PROVIDER_LOADED) } public setManager(manager: H5AdWrapper): void { diff --git a/src/Providers/cordova-ironsource.ts b/src/Providers/cordova-ironsource.ts index fe83f2b..be04230 100644 --- a/src/Providers/cordova-ironsource.ts +++ b/src/Providers/cordova-ironsource.ts @@ -18,6 +18,7 @@ export class CordovaIronSource implements IProvider { constructor(appKey: string) { if (typeof IronSourceAds === 'undefined') { + this.adManager.emit(AdEvents.AD_PROVIDER_LOADED) return } @@ -41,6 +42,7 @@ export class CordovaIronSource implements IProvider { window.addEventListener('rewardedVideoAvailabilityChanged', (event: any) => this.rewardedChanged(event.available) ) + this.adManager.emit(AdEvents.AD_PROVIDER_LOADED) } public setManager(manager: H5AdWrapper): void { diff --git a/src/Providers/gamedistribution.ts b/src/Providers/gamedistribution.ts index 652de2b..718959a 100644 --- a/src/Providers/gamedistribution.ts +++ b/src/Providers/gamedistribution.ts @@ -280,6 +280,8 @@ export class GameDistribution implements IProvider { fjs.parentNode.insertBefore(js, fjs) } })(document, 'script', 'gamedistribution-jssdk') + + this.adManager.emit(AdEvents.AD_PROVIDER_LOADED) } public setManager(manager: H5AdWrapper): void { @@ -290,7 +292,6 @@ export class GameDistribution implements IProvider { this.areAdsEnabled().then((enabled: boolean) => { if (enabled) { this.adsEnabled = true - this.adManager.emit(AdEvents.AD_PROVIDER_LOADED) } }) } diff --git a/src/Providers/ima3.ts b/src/Providers/ima3.ts index 9a99fb5..d1a8c4d 100644 --- a/src/Providers/ima3.ts +++ b/src/Providers/ima3.ts @@ -42,6 +42,7 @@ export class Ima3 implements IProvider { this.areAdsEnabled() if (typeof google === 'undefined') { + this.adManager.emit(AdEvents.AD_PROVIDER_LOADED) return } @@ -257,6 +258,8 @@ export class Ima3 implements IProvider { console.log('Adsmanager error:', adError) this.onAdError(adError) } + + this.adManager.emit(AdEvents.AD_PROVIDER_LOADED) } /**