File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import secureAdRewardState from "./secureAdRewardState";
44
55const ONE_HOUR = 60 * 60 * 1000 ;
66const MAX_TIMEOUT = 2_147_483_647 ;
7+ const REWARDED_RESULT_TIMEOUT_MS = 90 * 1000 ;
78
89const OFFERS = [
910 {
@@ -219,16 +220,25 @@ function waitForRewardedResult(ad) {
219220 return new Promise ( ( resolve , reject ) => {
220221 let earned = false ;
221222 let settled = false ;
223+ const timeoutId = setTimeout ( ( ) => {
224+ fail (
225+ new Error (
226+ "Rewarded ad timed out before completion. Please try again." ,
227+ ) ,
228+ ) ;
229+ } , REWARDED_RESULT_TIMEOUT_MS ) ;
222230
223231 const finish = ( result ) => {
224232 if ( settled ) return ;
225233 settled = true ;
234+ clearTimeout ( timeoutId ) ;
226235 resolve ( result ) ;
227236 } ;
228237
229238 const fail = ( error ) => {
230239 if ( settled ) return ;
231240 settled = true ;
241+ clearTimeout ( timeoutId ) ;
232242 reject (
233243 error instanceof Error
234244 ? error
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ export default async function startAd() {
1111
1212 if ( BuildInfo . type === "debug" ) {
1313 adUnitIdBanner = "ca-app-pub-3940256099942544/6300978111" ; // Test
14- adUnitIdInterstitial = "ca-app-pub-3940256099942544/5224354917 " ; // Test
14+ adUnitIdInterstitial = "ca-app-pub-3940256099942544/1033173712 " ; // Test
1515 adUnitIdRewarded = "ca-app-pub-3940256099942544/5224354917" ; // Test
1616 }
1717 }
You can’t perform that action at this time.
0 commit comments