@@ -1871,6 +1871,8 @@ var FacebookInstantGamesPlugin = new Class({
18711871 *
18721872 * If the instance is created successfully then the ad is preloaded ready for display in-game via the method `showAd()`.
18731873 *
1874+ * If the ad loads it will emit the `adloaded` event, passing the AdInstance as the only parameter.
1875+ *
18741876 * If the ad cannot be displayed because there was no inventory to fill it, it will emit the `adsnofill` event.
18751877 *
18761878 * @method Phaser.FacebookInstantGamesPlugin#preloadAds
@@ -1924,17 +1926,21 @@ var FacebookInstantGamesPlugin = new Class({
19241926
19251927 } ) . then ( function ( )
19261928 {
1927- _this . ads . push ( AdInstance ( id , data , false ) ) ;
1929+ var ad = AdInstance ( id , data , false ) ;
1930+
1931+ _this . ads . push ( ad ) ;
1932+
1933+ _this . emit ( 'adloaded' , ad ) ;
19281934
19291935 } ) . catch ( function ( e )
19301936 {
19311937 if ( e . code === 'ADS_NO_FILL' )
19321938 {
1933- _this . emit ( 'adsnofill' ) ;
1939+ _this . emit ( 'adsnofill' , id ) ;
19341940 }
19351941 else if ( e . code === 'ADS_FREQUENT_LOAD' )
19361942 {
1937- _this . emit ( 'adsfrequentload' ) ;
1943+ _this . emit ( 'adsfrequentload' , id ) ;
19381944 }
19391945 else
19401946 {
@@ -1947,10 +1953,12 @@ var FacebookInstantGamesPlugin = new Class({
19471953 } ,
19481954
19491955 /**
1950- * Attempt to create an instance of an interstitial video ad.
1956+ * Attempt to create an instance of an rewarded video ad.
19511957 *
19521958 * If the instance is created successfully then the ad is preloaded ready for display in-game via the method `showVideo()`.
19531959 *
1960+ * If the ad loads it will emit the `adloaded` event, passing the AdInstance as the only parameter.
1961+ *
19541962 * If the ad cannot be displayed because there was no inventory to fill it, it will emit the `adsnofill` event.
19551963 *
19561964 * @method Phaser.FacebookInstantGamesPlugin#preloadVideoAds
@@ -2004,17 +2012,21 @@ var FacebookInstantGamesPlugin = new Class({
20042012
20052013 } ) . then ( function ( )
20062014 {
2007- _this . ads . push ( AdInstance ( id , data , true ) ) ;
2015+ var ad = AdInstance ( id , data , true ) ;
2016+
2017+ _this . ads . push ( ad ) ;
2018+
2019+ _this . emit ( 'adloaded' , ad ) ;
20082020
20092021 } ) . catch ( function ( e )
20102022 {
20112023 if ( e . code === 'ADS_NO_FILL' )
20122024 {
2013- _this . emit ( 'adsnofill' ) ;
2025+ _this . emit ( 'adsnofill' , id ) ;
20142026 }
20152027 else if ( e . code === 'ADS_FREQUENT_LOAD' )
20162028 {
2017- _this . emit ( 'adsfrequentload' ) ;
2029+ _this . emit ( 'adsfrequentload' , id ) ;
20182030 }
20192031 else
20202032 {
@@ -2029,7 +2041,7 @@ var FacebookInstantGamesPlugin = new Class({
20292041 /**
20302042 * Displays a previously loaded interstitial ad.
20312043 *
2032- * If the ad is successfully displayed this plugin will emit the `showad ` event, with the AdInstance object as its parameter.
2044+ * If the ad is successfully displayed this plugin will emit the `adfinished ` event, with the AdInstance object as its parameter.
20332045 *
20342046 * If the ad cannot be displayed, it will emit the `adsnotloaded` event.
20352047 *
@@ -2054,18 +2066,20 @@ var FacebookInstantGamesPlugin = new Class({
20542066 {
20552067 ad . shown = true ;
20562068
2057- _this . emit ( 'showad ' , ad ) ;
2069+ _this . emit ( 'adfinished ' , ad ) ;
20582070
20592071 } ) . catch ( function ( e )
20602072 {
20612073 if ( e . code === 'ADS_NOT_LOADED' )
20622074 {
2063- _this . emit ( 'adsnotloaded' ) ;
2075+ _this . emit ( 'adsnotloaded' , ad ) ;
20642076 }
2065- else
2077+ else if ( e . code === 'RATE_LIMITED' )
20662078 {
2067- console . warn ( e ) ;
2079+ _this . emit ( 'adratelimited' , ad ) ;
20682080 }
2081+
2082+ _this . emit ( 'adshowerror' , e , ad ) ;
20692083 } ) ;
20702084 }
20712085 }
@@ -2076,7 +2090,7 @@ var FacebookInstantGamesPlugin = new Class({
20762090 /**
20772091 * Displays a previously loaded interstitial video ad.
20782092 *
2079- * If the ad is successfully displayed this plugin will emit the `showad ` event, with the AdInstance object as its parameter.
2093+ * If the ad is successfully displayed this plugin will emit the `adfinished ` event, with the AdInstance object as its parameter.
20802094 *
20812095 * If the ad cannot be displayed, it will emit the `adsnotloaded` event.
20822096 *
@@ -2101,18 +2115,20 @@ var FacebookInstantGamesPlugin = new Class({
21012115 {
21022116 ad . shown = true ;
21032117
2104- _this . emit ( 'showad ' , ad ) ;
2118+ _this . emit ( 'adfinished ' , ad ) ;
21052119
21062120 } ) . catch ( function ( e )
21072121 {
21082122 if ( e . code === 'ADS_NOT_LOADED' )
21092123 {
2110- _this . emit ( 'adsnotloaded' ) ;
2124+ _this . emit ( 'adsnotloaded' , ad ) ;
21112125 }
2112- else
2126+ else if ( e . code === 'RATE_LIMITED' )
21132127 {
2114- console . warn ( e ) ;
2128+ _this . emit ( 'adratelimited' , ad ) ;
21152129 }
2130+
2131+ _this . emit ( 'adshowerror' , e , ad ) ;
21162132 } ) ;
21172133 }
21182134 }
0 commit comments