From 163ab4fc190c6bcc641487450e0dfa8f0ece76ef Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 26 Sep 2019 13:11:28 +0100 Subject: [PATCH] Calling `showAd` or `showVideoAd` will now check to see if the ad has already been displayed, and skip it when iterating the ads array, allowing you to display an ad with the same Placement ID without preloading it again. Fix #4728 --- CHANGELOG.md | 4 ++++ plugins/fbinstant/src/FacebookInstantGamesPlugin.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 306c7130b..80cadd19c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Version 3.20.0 - Fitoria - in dev +### Facebook Instant Games Plugin + +* Calling `showAd` or `showVideoAd` will now check to see if the ad has already been displayed, and skip it when iterating the ads array, allowing you to display an ad with the same Placement ID without preloading it again. Fix #4728 (thanks @NokFrt) + ### New Features * `GameConfig.antialiasGL` is a new boolean that allows you to set the `antialias` property of the WebGL context during creation, without impacting any subsequent textures or the canvas CSS. diff --git a/plugins/fbinstant/src/FacebookInstantGamesPlugin.js b/plugins/fbinstant/src/FacebookInstantGamesPlugin.js index d65701d1f..ce6755cb9 100644 --- a/plugins/fbinstant/src/FacebookInstantGamesPlugin.js +++ b/plugins/fbinstant/src/FacebookInstantGamesPlugin.js @@ -2087,7 +2087,7 @@ var FacebookInstantGamesPlugin = new Class({ { var ad = this.ads[i]; - if (ad.placementID === placementID) + if (ad.placementID === placementID && !ad.shown) { ad.instance.showAsync().then(function () { @@ -2136,7 +2136,7 @@ var FacebookInstantGamesPlugin = new Class({ { var ad = this.ads[i]; - if (ad.placementID === placementID && ad.video) + if (ad.placementID === placementID && ad.video && !ad.shown) { ad.instance.showAsync().then(function () {