@cardsjd/portal 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/AdMobPortal.js +0 -46
- package/lib/BasePortal.js +71 -4
- package/lib/CrazyGamesPortal.js +0 -46
- package/lib/FacebookPortal.js +1 -47
- package/lib/GameDistributionPortal.js +0 -46
- package/lib/PokiPortal.js +0 -46
- package/lib/WebPortal.js +2 -53
- package/package.json +1 -1
package/lib/AdMobPortal.js
CHANGED
|
@@ -153,53 +153,7 @@ export class AdMobPortal extends BasePortal {
|
|
|
153
153
|
adId: this.appConfig?.interstitialAdId,
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
|
-
async tryShowInterstitialAd(options) {
|
|
157
|
-
//only load/show if ads enabled
|
|
158
|
-
if (this.isSetup === false) { return; }
|
|
159
|
-
|
|
160
|
-
const config = this.config;
|
|
161
|
-
const offsetStartdelay = options?.offsetStartdelay || config.offsetStartdelay || 120; //start with 1 min passed to get the first ad to show faster
|
|
162
|
-
const delayBetweenAds = options?.delayBetweenAds || config.delayBetweenAds || 240; //check for 240 (4 min) seconds passed was 180
|
|
163
|
-
const awayResetTime = options?.awayResetTime || config.awayResetTime || 1200; //check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
164
|
-
|
|
165
|
-
//1. only allow ad to be shown/loaded once every 150 second (Advertisement.delayBetweenAds)
|
|
166
|
-
//2. check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
167
|
-
//3. load ad ether way
|
|
168
|
-
//4. show ad if conditions met
|
|
169
|
-
|
|
170
|
-
let readyToShowAd = false;
|
|
171
|
-
|
|
172
|
-
//reset timer
|
|
173
|
-
if (!this.lastShownInterstitial) {
|
|
174
|
-
this.lastShownInterstitial = Date.now();//now
|
|
175
|
-
//add start offset delay
|
|
176
|
-
const newDate = new Date();
|
|
177
|
-
newDate.setSeconds(newDate.getSeconds() - offsetStartdelay);
|
|
178
|
-
this.lastShownInterstitial = newDate;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const secondsSinceLastAd = (Date.now() - this.lastShownInterstitial) / 1000;
|
|
182
|
-
|
|
183
|
-
//check for delayBetweenAds seconds passed
|
|
184
|
-
if (secondsSinceLastAd > delayBetweenAds) {
|
|
185
|
-
readyToShowAd = true;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
//check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
189
|
-
if (secondsSinceLastAd > awayResetTime) {
|
|
190
|
-
readyToShowAd = false;
|
|
191
|
-
this.lastShownInterstitial = Date.now();//now, reset
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
console.log('readyToShowInterstitialAd: ' + readyToShowAd + ' : ' + secondsSinceLastAd + ' of ' + delayBetweenAds);
|
|
195
156
|
|
|
196
|
-
// show ad or just load ad (not load and show)
|
|
197
|
-
if (readyToShowAd) {
|
|
198
|
-
await this.showInterstitialAd();
|
|
199
|
-
} else {
|
|
200
|
-
await this.loadInterstitialAd();
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
157
|
async showInterstitialAd() {
|
|
204
158
|
if (!this.isAdLoaded()) {
|
|
205
159
|
await this.loadInterstitialAd();
|
package/lib/BasePortal.js
CHANGED
|
@@ -50,10 +50,77 @@ export class BasePortal {
|
|
|
50
50
|
|
|
51
51
|
createShortCut() { }
|
|
52
52
|
|
|
53
|
-
async tryShowInterstitialAd(
|
|
54
|
-
|
|
53
|
+
async tryShowInterstitialAd(options) {
|
|
54
|
+
//only load/show if ads enabled
|
|
55
|
+
if (this.isSetup === false) { return; }
|
|
56
|
+
|
|
57
|
+
const config = this.config || {};
|
|
58
|
+
const offsetStartdelay = options?.offsetStartdelay || config.offsetStartdelay || 120; //start with 1 min passed to get the first ad to show faster
|
|
59
|
+
const delayBetweenAds = options?.delayBetweenAds || config.delayBetweenAds || 240; //check for 240 (4 min) seconds passed was 180
|
|
60
|
+
const awayResetTime = options?.awayResetTime || config.awayResetTime || 1200; //check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
61
|
+
|
|
62
|
+
//1. only allow ad to be shown/loaded once every 150 second (Advertisement.delayBetweenAds)
|
|
63
|
+
//2. check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
64
|
+
//3. load ad ether way
|
|
65
|
+
//4. show ad if conditions met
|
|
66
|
+
|
|
67
|
+
let readyToShowAd = false;
|
|
68
|
+
|
|
69
|
+
//reset timer
|
|
70
|
+
if (!this.lastShownInterstitial) {
|
|
71
|
+
this.lastShownInterstitial = Date.now();//now
|
|
72
|
+
//add start offset delay
|
|
73
|
+
const newDate = new Date();
|
|
74
|
+
newDate.setSeconds(newDate.getSeconds() - offsetStartdelay);
|
|
75
|
+
this.lastShownInterstitial = newDate;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const secondsSinceLastAd = (Date.now() - this.lastShownInterstitial) / 1000;
|
|
79
|
+
|
|
80
|
+
//check for delayBetweenAds seconds passed
|
|
81
|
+
if (secondsSinceLastAd > delayBetweenAds) {
|
|
82
|
+
readyToShowAd = true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
//check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
86
|
+
if (secondsSinceLastAd > awayResetTime) {
|
|
87
|
+
readyToShowAd = false;
|
|
88
|
+
this.lastShownInterstitial = Date.now();//now, reset
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
console.log('readyToShowInterstitialAd: ' + readyToShowAd + ' : ' + secondsSinceLastAd + ' of ' + delayBetweenAds);
|
|
92
|
+
|
|
93
|
+
// show ad or just load ad (not load and show)
|
|
94
|
+
if (readyToShowAd) {
|
|
95
|
+
await this.showInterstitialAd();
|
|
96
|
+
} else {
|
|
97
|
+
await this.loadInterstitialAd();
|
|
98
|
+
}
|
|
55
99
|
}
|
|
56
|
-
async showAppOpenAdWithMaxDelay(
|
|
57
|
-
|
|
100
|
+
async showAppOpenAdWithMaxDelay(maxDelay) {
|
|
101
|
+
if (this.isSetUp === false) { return; }
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
if (!maxDelay) {
|
|
105
|
+
maxDelay = 4000;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//get start time
|
|
109
|
+
const startTime = Date.now();
|
|
110
|
+
if (this.loadAppOpenAd) {
|
|
111
|
+
await this.loadAppOpenAd();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//this wont work...
|
|
115
|
+
//is timer over maxDelay
|
|
116
|
+
const timePassed = Date.now() - startTime;
|
|
117
|
+
if (timePassed > maxDelay) {
|
|
118
|
+
console.log(`showAppOpenAdWithMaxDelay took too long to load [${timePassed}ms/${maxDelay}ms], skipping ad`);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (this.showAppOpenAd) {
|
|
123
|
+
await this.showAppOpenAd();
|
|
124
|
+
}
|
|
58
125
|
}
|
|
59
126
|
}
|
package/lib/CrazyGamesPortal.js
CHANGED
|
@@ -256,53 +256,7 @@ export class CrazyGamesPortal extends BasePortal {
|
|
|
256
256
|
await this.setupAds();
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
-
async tryShowInterstitialAd(options) {
|
|
260
|
-
//only load/show if ads enabled
|
|
261
|
-
if (this.isSetup === false) { return; }
|
|
262
259
|
|
|
263
|
-
const config = this.config;
|
|
264
|
-
const offsetStartdelay = options?.offsetStartdelay || config.offsetStartdelay || 120; //start with 1 min passed to get the first ad to show faster
|
|
265
|
-
const delayBetweenAds = options?.delayBetweenAds || config.delayBetweenAds || 240; //check for 240 (4 min) seconds passed was 180
|
|
266
|
-
const awayResetTime = options?.awayResetTime || config.awayResetTime || 1200; //check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
267
|
-
|
|
268
|
-
//1. only allow ad to be shown/loaded once every 150 second (Advertisement.delayBetweenAds)
|
|
269
|
-
//2. check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
270
|
-
//3. load ad ether way
|
|
271
|
-
//4. show ad if conditions met
|
|
272
|
-
|
|
273
|
-
let readyToShowAd = false;
|
|
274
|
-
|
|
275
|
-
//reset timer
|
|
276
|
-
if (!this.lastShownInterstitial) {
|
|
277
|
-
this.lastShownInterstitial = Date.now();//now
|
|
278
|
-
//add start offset delay
|
|
279
|
-
const newDate = new Date();
|
|
280
|
-
newDate.setSeconds(newDate.getSeconds() - offsetStartdelay);
|
|
281
|
-
this.lastShownInterstitial = newDate;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
const secondsSinceLastAd = (Date.now() - this.lastShownInterstitial) / 1000;
|
|
285
|
-
|
|
286
|
-
//check for delayBetweenAds seconds passed
|
|
287
|
-
if (secondsSinceLastAd > delayBetweenAds) {
|
|
288
|
-
readyToShowAd = true;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
//check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
292
|
-
if (secondsSinceLastAd > awayResetTime) {
|
|
293
|
-
readyToShowAd = false;
|
|
294
|
-
this.lastShownInterstitial = Date.now();//now, reset
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
console.log('readyToShowInterstitialAd: ' + readyToShowAd + ' : ' + secondsSinceLastAd + ' of ' + delayBetweenAds);
|
|
298
|
-
|
|
299
|
-
// show ad or just load ad (not load and show)
|
|
300
|
-
if (readyToShowAd) {
|
|
301
|
-
await this.showInterstitialAd();
|
|
302
|
-
} else {
|
|
303
|
-
await this.loadInterstitialAd();
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
260
|
async showInterstitialAd() {
|
|
307
261
|
console.log('CrazyGames.showAd');
|
|
308
262
|
|
package/lib/FacebookPortal.js
CHANGED
|
@@ -227,53 +227,7 @@ export class FacebookPortal extends BasePortal {
|
|
|
227
227
|
console.error('FB_Ads.getInterstitialAdAsync error: ' + ex);
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
-
|
|
231
|
-
//only load/show if ads enabled
|
|
232
|
-
if (this.isSetup === false) { return; }
|
|
233
|
-
|
|
234
|
-
const config = this.config;
|
|
235
|
-
const offsetStartdelay = options?.offsetStartdelay || config.offsetStartdelay || 120; //start with 1 min passed to get the first ad to show faster
|
|
236
|
-
const delayBetweenAds = options?.delayBetweenAds || config.delayBetweenAds || 240; //check for 240 (4 min) seconds passed was 180
|
|
237
|
-
const awayResetTime = options?.awayResetTime || config.awayResetTime || 1200; //check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
238
|
-
|
|
239
|
-
//1. only allow ad to be shown/loaded once every 150 second (Advertisement.delayBetweenAds)
|
|
240
|
-
//2. check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
241
|
-
//3. load ad ether way
|
|
242
|
-
//4. show ad if conditions met
|
|
243
|
-
|
|
244
|
-
let readyToShowAd = false;
|
|
245
|
-
|
|
246
|
-
//reset timer
|
|
247
|
-
if (!this.lastShownInterstitial) {
|
|
248
|
-
this.lastShownInterstitial = Date.now();//now
|
|
249
|
-
//add start offset delay
|
|
250
|
-
const newDate = new Date();
|
|
251
|
-
newDate.setSeconds(newDate.getSeconds() - offsetStartdelay);
|
|
252
|
-
this.lastShownInterstitial = newDate;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const secondsSinceLastAd = (Date.now() - this.lastShownInterstitial) / 1000;
|
|
256
|
-
|
|
257
|
-
//check for delayBetweenAds seconds passed
|
|
258
|
-
if (secondsSinceLastAd > delayBetweenAds) {
|
|
259
|
-
readyToShowAd = true;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
//check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
263
|
-
if (secondsSinceLastAd > awayResetTime) {
|
|
264
|
-
readyToShowAd = false;
|
|
265
|
-
this.lastShownInterstitial = Date.now();//now, reset
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
console.log('readyToShowInterstitialAd: ' + readyToShowAd + ' : ' + secondsSinceLastAd + ' of ' + delayBetweenAds);
|
|
269
|
-
|
|
270
|
-
// show ad or just load ad (not load and show)
|
|
271
|
-
if (readyToShowAd) {
|
|
272
|
-
await this.showInterstitialAd();
|
|
273
|
-
} else {
|
|
274
|
-
await this.loadInterstitialAd();
|
|
275
|
-
}
|
|
276
|
-
}
|
|
230
|
+
|
|
277
231
|
showInterstitialAd() {
|
|
278
232
|
console.log('FB_Ads.showInterstitialAd');
|
|
279
233
|
|
|
@@ -63,53 +63,7 @@ export class GameDistribution extends BasePortal {
|
|
|
63
63
|
this.isInterstitialAdReady = false;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
async tryShowInterstitialAd(options) {
|
|
67
|
-
//only load/show if ads enabled
|
|
68
|
-
if (this.isSetup === false) { return; }
|
|
69
|
-
|
|
70
|
-
const config = this.config;
|
|
71
|
-
const offsetStartdelay = options?.offsetStartdelay || config.offsetStartdelay || 120; //start with 1 min passed to get the first ad to show faster
|
|
72
|
-
const delayBetweenAds = options?.delayBetweenAds || config.delayBetweenAds || 240; //check for 240 (4 min) seconds passed was 180
|
|
73
|
-
const awayResetTime = options?.awayResetTime || config.awayResetTime || 1200; //check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
74
|
-
|
|
75
|
-
//1. only allow ad to be shown/loaded once every 150 second (Advertisement.delayBetweenAds)
|
|
76
|
-
//2. check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
77
|
-
//3. load ad ether way
|
|
78
|
-
//4. show ad if conditions met
|
|
79
|
-
|
|
80
|
-
let readyToShowAd = false;
|
|
81
|
-
|
|
82
|
-
//reset timer
|
|
83
|
-
if (!this.lastShownInterstitial) {
|
|
84
|
-
this.lastShownInterstitial = Date.now();//now
|
|
85
|
-
//add start offset delay
|
|
86
|
-
const newDate = new Date();
|
|
87
|
-
newDate.setSeconds(newDate.getSeconds() - offsetStartdelay);
|
|
88
|
-
this.lastShownInterstitial = newDate;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const secondsSinceLastAd = (Date.now() - this.lastShownInterstitial) / 1000;
|
|
92
66
|
|
|
93
|
-
//check for delayBetweenAds seconds passed
|
|
94
|
-
if (secondsSinceLastAd > delayBetweenAds) {
|
|
95
|
-
readyToShowAd = true;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
//check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
99
|
-
if (secondsSinceLastAd > awayResetTime) {
|
|
100
|
-
readyToShowAd = false;
|
|
101
|
-
this.lastShownInterstitial = Date.now();//now, reset
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
console.log('readyToShowInterstitialAd: ' + readyToShowAd + ' : ' + secondsSinceLastAd + ' of ' + delayBetweenAds);
|
|
105
|
-
|
|
106
|
-
// show ad or just load ad (not load and show)
|
|
107
|
-
if (readyToShowAd) {
|
|
108
|
-
await this.showInterstitialAd();
|
|
109
|
-
} else {
|
|
110
|
-
await this.loadInterstitialAd();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
67
|
async showInterstitialAd() {
|
|
114
68
|
if (!this.isReady()) {
|
|
115
69
|
return false;
|
package/lib/PokiPortal.js
CHANGED
|
@@ -185,53 +185,7 @@ export class PokiPortal extends BasePortal {
|
|
|
185
185
|
async loadInterstitialAd() {
|
|
186
186
|
// Poki commercial breaks do not require manual preloading
|
|
187
187
|
}
|
|
188
|
-
async tryShowInterstitialAd(options) {
|
|
189
|
-
//only load/show if ads enabled
|
|
190
|
-
if (this.isSetup === false) { return; }
|
|
191
|
-
|
|
192
|
-
const config = this.config;
|
|
193
|
-
const offsetStartdelay = options?.offsetStartdelay || config.offsetStartdelay || 120; //start with 1 min passed to get the first ad to show faster
|
|
194
|
-
const delayBetweenAds = options?.delayBetweenAds || config.delayBetweenAds || 240; //check for 240 (4 min) seconds passed was 180
|
|
195
|
-
const awayResetTime = options?.awayResetTime || config.awayResetTime || 1200; //check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
196
|
-
|
|
197
|
-
//1. only allow ad to be shown/loaded once every 150 second (Advertisement.delayBetweenAds)
|
|
198
|
-
//2. check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
199
|
-
//3. load ad ether way
|
|
200
|
-
//4. show ad if conditions met
|
|
201
|
-
|
|
202
|
-
let readyToShowAd = false;
|
|
203
|
-
|
|
204
|
-
//reset timer
|
|
205
|
-
if (!this.lastShownInterstitial) {
|
|
206
|
-
this.lastShownInterstitial = Date.now();//now
|
|
207
|
-
//add start offset delay
|
|
208
|
-
const newDate = new Date();
|
|
209
|
-
newDate.setSeconds(newDate.getSeconds() - offsetStartdelay);
|
|
210
|
-
this.lastShownInterstitial = newDate;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const secondsSinceLastAd = (Date.now() - this.lastShownInterstitial) / 1000;
|
|
214
188
|
|
|
215
|
-
//check for delayBetweenAds seconds passed
|
|
216
|
-
if (secondsSinceLastAd > delayBetweenAds) {
|
|
217
|
-
readyToShowAd = true;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
//check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
221
|
-
if (secondsSinceLastAd > awayResetTime) {
|
|
222
|
-
readyToShowAd = false;
|
|
223
|
-
this.lastShownInterstitial = Date.now();//now, reset
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
console.log('readyToShowInterstitialAd: ' + readyToShowAd + ' : ' + secondsSinceLastAd + ' of ' + delayBetweenAds);
|
|
227
|
-
|
|
228
|
-
// show ad or just load ad (not load and show)
|
|
229
|
-
if (readyToShowAd) {
|
|
230
|
-
await this.showInterstitialAd();
|
|
231
|
-
} else {
|
|
232
|
-
await this.loadInterstitialAd();
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
189
|
async showInterstitialAd() {
|
|
236
190
|
if (!this.isReady()) {
|
|
237
191
|
return false;
|
package/lib/WebPortal.js
CHANGED
|
@@ -49,7 +49,7 @@ export class WebPortal extends BasePortal {
|
|
|
49
49
|
|
|
50
50
|
async setupAds() {
|
|
51
51
|
if (this.isSetup) {
|
|
52
|
-
console.log('
|
|
52
|
+
console.log('GoogleH5.isSetup is already done');
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
if (this.isSetupLoading) {
|
|
@@ -58,11 +58,6 @@ export class WebPortal extends BasePortal {
|
|
|
58
58
|
|
|
59
59
|
this.isSetupLoading = true; //prevent async loading
|
|
60
60
|
|
|
61
|
-
if (this.isSetup) {
|
|
62
|
-
console.log('GoogleH5.isSetup is already done');
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
61
|
try {
|
|
67
62
|
await this.loadScript();
|
|
68
63
|
console.log('adsbygoogle loaded');
|
|
@@ -122,53 +117,6 @@ export class WebPortal extends BasePortal {
|
|
|
122
117
|
loadInterstitialAd() {
|
|
123
118
|
console.log('GoogleH5.loadAd');
|
|
124
119
|
}
|
|
125
|
-
async tryShowInterstitialAd(options) {
|
|
126
|
-
//only load/show if ads enabled
|
|
127
|
-
if (this.isSetup === false) { return; }
|
|
128
|
-
|
|
129
|
-
const config = this.config;
|
|
130
|
-
const offsetStartdelay = options?.offsetStartdelay || config.offsetStartdelay || 120; //start with 1 min passed to get the first ad to show faster
|
|
131
|
-
const delayBetweenAds = options?.delayBetweenAds || config.delayBetweenAds || 240; //check for 240 (4 min) seconds passed was 180
|
|
132
|
-
const awayResetTime = options?.awayResetTime || config.awayResetTime || 1200; //check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
133
|
-
|
|
134
|
-
//1. only allow ad to be shown/loaded once every 150 second (Advertisement.delayBetweenAds)
|
|
135
|
-
//2. check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
136
|
-
//3. load ad ether way
|
|
137
|
-
//4. show ad if conditions met
|
|
138
|
-
|
|
139
|
-
let readyToShowAd = false;
|
|
140
|
-
|
|
141
|
-
//reset timer
|
|
142
|
-
if (!this.lastShownInterstitial) {
|
|
143
|
-
this.lastShownInterstitial = Date.now();//now
|
|
144
|
-
//add start offset delay
|
|
145
|
-
const newDate = new Date();
|
|
146
|
-
newDate.setSeconds(newDate.getSeconds() - offsetStartdelay);
|
|
147
|
-
this.lastShownInterstitial = newDate;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const secondsSinceLastAd = (Date.now() - this.lastShownInterstitial) / 1000;
|
|
151
|
-
|
|
152
|
-
//check for delayBetweenAds seconds passed
|
|
153
|
-
if (secondsSinceLastAd > delayBetweenAds) {
|
|
154
|
-
readyToShowAd = true;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
//check if over 20 min, may have not been in the app and reopened it with out restarting
|
|
158
|
-
if (secondsSinceLastAd > awayResetTime) {
|
|
159
|
-
readyToShowAd = false;
|
|
160
|
-
this.lastShownInterstitial = Date.now();//now, reset
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
console.log('readyToShowInterstitialAd: ' + readyToShowAd + ' : ' + secondsSinceLastAd + ' of ' + delayBetweenAds);
|
|
164
|
-
|
|
165
|
-
// show ad or just load ad (not load and show)
|
|
166
|
-
if (readyToShowAd) {
|
|
167
|
-
await this.showInterstitialAd();
|
|
168
|
-
} else {
|
|
169
|
-
await this.loadInterstitialAd();
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
120
|
showInterstitialAd() {
|
|
173
121
|
console.log('GoogleH5.showAd');
|
|
174
122
|
|
|
@@ -304,4 +252,5 @@ export class WebPortal extends BasePortal {
|
|
|
304
252
|
|
|
305
253
|
return adStatus;
|
|
306
254
|
}
|
|
255
|
+
|
|
307
256
|
}
|