From bb6976845c47ce6f7f3849f29fb92f49616c155a Mon Sep 17 00:00:00 2001 From: Bram Willem van der Kuip Date: Thu, 13 Feb 2020 15:56:55 +0100 Subject: [PATCH 1/5] Added provider loaded event to providers --- src/Providers/cocoon.ts | 2 ++ src/Providers/cordova-gamedistribution.ts | 3 +++ src/Providers/cordova-gamedock.ts | 2 +- src/Providers/cordova-heyzap.ts | 2 ++ src/Providers/cordova-ironsource.ts | 2 ++ src/Providers/gamedistribution.ts | 2 ++ src/Providers/ima3.ts | 3 +++ 7 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Providers/cocoon.ts b/src/Providers/cocoon.ts index a5afb66..1d15cc0 100644 --- a/src/Providers/cocoon.ts +++ b/src/Providers/cocoon.ts @@ -34,6 +34,7 @@ export class CocoonAds implements IProvider { if (Cocoon && Cocoon.Ad) { this.adsEnabled = true } else { + this.adManager.emit(AdEvents.AD_PROVIDER_LOADED) return } @@ -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..e00b6c3 100644 --- a/src/Providers/cordova-gamedock.ts +++ b/src/Providers/cordova-gamedock.ts @@ -33,7 +33,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..15cd50a 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 { 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) } /** From 26c44b6063b7d9345ac48f2245241052710c4d6c Mon Sep 17 00:00:00 2001 From: Bram Willem van der Kuip Date: Thu, 13 Feb 2020 15:57:25 +0100 Subject: [PATCH 2/5] Version bump to 0.6.1 --- CHANGELOG.md | 4 ++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) 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": [ { From e55c860741d5bead11e3f4268709dca617f7391f Mon Sep 17 00:00:00 2001 From: Bram Willem van der Kuip Date: Thu, 13 Feb 2020 17:10:48 +0100 Subject: [PATCH 3/5] Removed double emit of AdEvents.AD_PROVIDER_LOADED --- src/Providers/gamedistribution.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Providers/gamedistribution.ts b/src/Providers/gamedistribution.ts index 15cd50a..718959a 100644 --- a/src/Providers/gamedistribution.ts +++ b/src/Providers/gamedistribution.ts @@ -292,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) } }) } From 9e282a578bd9c357d5ecaffdcea1d73890509ff0 Mon Sep 17 00:00:00 2001 From: Bram Willem van der Kuip Date: Thu, 13 Feb 2020 17:13:07 +0100 Subject: [PATCH 4/5] Added AD_PROVIDER_LOADED to gamedockSDK being undefined --- src/Providers/cordova-gamedock.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Providers/cordova-gamedock.ts b/src/Providers/cordova-gamedock.ts index e00b6c3..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 } From d3f05c42ed993897503376f4ddcaf1efd91cf69d Mon Sep 17 00:00:00 2001 From: Bram Willem van der Kuip Date: Thu, 13 Feb 2020 17:17:08 +0100 Subject: [PATCH 5/5] Inverted cocoon adsEnabled check --- src/Providers/cocoon.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Providers/cocoon.ts b/src/Providers/cocoon.ts index 1d15cc0..0a76b5a 100644 --- a/src/Providers/cocoon.ts +++ b/src/Providers/cocoon.ts @@ -31,13 +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: