@@ -396,11 +396,21 @@ GADUTypeRewardedAdPreloaderRef GADUCreateRewardedAdPreloader(
396396}
397397
398398GADUTypeInterstitialAdPreloaderRef GADUCreateInterstitialAdPreloader (
399- GADUTypeInterstitialAdPreloaderClientRef *interstitialAdPreloaderClient) {
399+ GADUTypeInterstitialAdPreloaderClientRef *interstitialAdPreloaderClient,
400+ GADUAdAvailableForPreloadIDCallback adAvailableForPreloadIDCallback,
401+ GADUAdFailedToPreloadForPreloadIDCallback adFailedToPreloadForPreloadIDCallback,
402+ GADUAdsExhaustedForPreloadIDCallback adsExhaustedForPreloadIDCallback) {
400403 GADUInterstitialAdPreloader *interstitialAdPreloader = [[GADUInterstitialAdPreloader alloc ]
401404 initWithInterstitialAdPreloaderClientReference: interstitialAdPreloaderClient];
405+ if (!interstitialAdPreloader) {
406+ return nil ;
407+ }
402408 GADUObjectCache *cache = GADUObjectCache.sharedInstance ;
403409 cache[interstitialAdPreloader.gadu_referenceKey] = interstitialAdPreloader;
410+ interstitialAdPreloader.adAvailableForPreloadIDCallback = adAvailableForPreloadIDCallback;
411+ interstitialAdPreloader.adFailedToPreloadForPreloadIDCallback =
412+ adFailedToPreloadForPreloadIDCallback;
413+ interstitialAdPreloader.adsExhaustedForPreloadIDCallback = adsExhaustedForPreloadIDCallback;
404414 return (__bridge GADUTypeInterstitialAdPreloaderRef)interstitialAdPreloader;
405415}
406416
@@ -654,20 +664,6 @@ void GADUSetRewardedAdPreloaderCallbacks(
654664 internalRewardedAdPreloader.adsExhaustedForPreloadIDCallback = adsExhaustedForPreloadIDCallback;
655665}
656666
657- // / Sets the interstitial ad preloader callback methods to be invoked during preload events.
658- void GADUSetInterstitialAdPreloaderCallbacks (
659- GADUTypeInterstitialAdPreloaderRef interstitialAdPreloader,
660- GADUAdAvailableForPreloadIDCallback adAvailableForPreloadIDCallback,
661- GADUAdFailedToPreloadForPreloadIDCallback adFailedToPreloadForPreloadIDCallback,
662- GADUAdsExhaustedForPreloadIDCallback adsExhaustedForPreloadIDCallback) {
663- GADUInterstitialAdPreloader *internalInterstitialAdPreloader =
664- (__bridge GADUInterstitialAdPreloader *)interstitialAdPreloader;
665- internalInterstitialAdPreloader.adAvailableForPreloadIDCallback = adAvailableForPreloadIDCallback;
666- internalInterstitialAdPreloader.adFailedToPreloadForPreloadIDCallback =
667- adFailedToPreloadForPreloadIDCallback;
668- internalInterstitialAdPreloader.adsExhaustedForPreloadIDCallback = adsExhaustedForPreloadIDCallback;
669- }
670-
671667// / Sets the app open ad callback methods to be invoked during app open ad events.
672668void GADUSetAppOpenAdCallbacks (
673669 GADUTypeAppOpenAdRef appOpenAd, GADUAppOpenAdLoadedCallback adLoadedCallback,
@@ -1023,10 +1019,13 @@ void GADURewardedAdPreloaderDestroyAll(
10231019}
10241020
10251021BOOL GADUInterstitialAdPreloaderPreload (
1026- GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloaderClient , const char *preloadId,
1022+ GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloader , const char *preloadId,
10271023 GADUTypePreloadConfigurationV2Ref preloadConfiguration) {
10281024 GADUInterstitialAdPreloader *internalInterstitialAdPreloader =
1029- (__bridge GADUInterstitialAdPreloader *)interstitialAdPreloaderClient;
1025+ (__bridge GADUInterstitialAdPreloader *)interstitialAdPreloader;
1026+ if (!internalInterstitialAdPreloader) {
1027+ return NO ;
1028+ }
10301029 GADUPreloadConfigurationV2 *internalPreloadConfiguration =
10311030 (__bridge GADUPreloadConfigurationV2 *_Nonnull)(preloadConfiguration);
10321031 return [internalInterstitialAdPreloader
@@ -1035,18 +1034,24 @@ BOOL GADUInterstitialAdPreloaderPreload(
10351034}
10361035
10371036BOOL GADUInterstitialAdPreloaderIsAdAvailable (
1038- GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloaderClient , const char *preloadId) {
1037+ GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloader , const char *preloadId) {
10391038 GADUInterstitialAdPreloader *internalInterstitialAdPreloader =
1040- (__bridge GADUInterstitialAdPreloader *)interstitialAdPreloaderClient;
1039+ (__bridge GADUInterstitialAdPreloader *)interstitialAdPreloader;
1040+ if (!internalInterstitialAdPreloader) {
1041+ return NO ;
1042+ }
10411043 return [internalInterstitialAdPreloader
10421044 isAdAvailableWithPreloadID: GADUStringFromUTF8String (preloadId)];
10431045}
10441046
10451047GADUTypeInterstitialRef GADUInterstitialAdPreloaderGetPreloadedAd (
1046- GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloaderClient , const char *preloadId,
1048+ GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloader , const char *preloadId,
10471049 GADUTypeInterstitialClientRef *interstitialAdClient) {
10481050 GADUInterstitialAdPreloader *internalInterstitialAdPreloader =
1049- (__bridge GADUInterstitialAdPreloader *)interstitialAdPreloaderClient;
1051+ (__bridge GADUInterstitialAdPreloader *)interstitialAdPreloader;
1052+ if (!internalInterstitialAdPreloader) {
1053+ return nil ;
1054+ }
10501055 GADInterstitialAd *interstitialAd =
10511056 [internalInterstitialAdPreloader adWithPreloadID: GADUStringFromUTF8String (preloadId)
10521057 interstitialAdClient: interstitialAdClient];
@@ -1059,40 +1064,55 @@ GADUTypeInterstitialRef GADUInterstitialAdPreloaderGetPreloadedAd(
10591064}
10601065
10611066unsigned long GADUInterstitialAdPreloaderGetNumAdsAvailable (
1062- GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloaderClient , const char *preloadId) {
1067+ GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloader , const char *preloadId) {
10631068 GADUInterstitialAdPreloader *internalInterstitialAdPreloader =
1064- (__bridge GADUInterstitialAdPreloader *)interstitialAdPreloaderClient;
1069+ (__bridge GADUInterstitialAdPreloader *)interstitialAdPreloader;
1070+ if (!internalInterstitialAdPreloader) {
1071+ return 0 ;
1072+ }
10651073 return [internalInterstitialAdPreloader
10661074 numberOfAdsAvailableWithPreloadID: GADUStringFromUTF8String (preloadId)];
10671075}
10681076
10691077GADUTypePreloadConfigurationV2Ref GADUInterstitialAdPreloaderGetConfiguration (
1070- GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloaderClient , const char *preloadId) {
1078+ GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloader , const char *preloadId) {
10711079 GADUInterstitialAdPreloader *internalInterstitialAdPreloader =
1072- (__bridge GADUInterstitialAdPreloader *)interstitialAdPreloaderClient;
1080+ (__bridge GADUInterstitialAdPreloader *)interstitialAdPreloader;
1081+ if (!internalInterstitialAdPreloader) {
1082+ return nil ;
1083+ }
10731084 return (__bridge GADUTypePreloadConfigurationV2Ref)([internalInterstitialAdPreloader
10741085 configurationWithPreloadID: GADUStringFromUTF8String (preloadId)]);
10751086}
10761087
10771088GADUTypeRef GADUInterstitialAdPreloaderGetConfigurations (
1078- GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloaderClient ) {
1089+ GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloader ) {
10791090 GADUInterstitialAdPreloader *internalInterstitialAdPreloader =
1080- (__bridge GADUInterstitialAdPreloader *)interstitialAdPreloaderClient;
1091+ (__bridge GADUInterstitialAdPreloader *)interstitialAdPreloader;
1092+ if (!internalInterstitialAdPreloader) {
1093+ return nil ;
1094+ }
10811095 return (__bridge GADUTypeRef)([internalInterstitialAdPreloader configurations ]);
10821096}
10831097
10841098void GADUInterstitialAdPreloaderDestroy (
1085- GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloaderClient , const char *preloadId) {
1099+ GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloader , const char *preloadId) {
10861100 GADUInterstitialAdPreloader *internalInterstitialAdPreloader =
1087- (__bridge GADUInterstitialAdPreloader *)interstitialAdPreloaderClient;
1101+ (__bridge GADUInterstitialAdPreloader *)interstitialAdPreloader;
1102+ if (!internalInterstitialAdPreloader) {
1103+ return ;
1104+ }
10881105 [internalInterstitialAdPreloader
10891106 stopPreloadingAndRemoveAdsForPreloadID: GADUStringFromUTF8String (preloadId)];
10901107}
10911108
10921109void GADUInterstitialAdPreloaderDestroyAll (
1093- GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloaderClient ) {
1110+ GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloader ) {
10941111 GADUInterstitialAdPreloader *internalInterstitialAdPreloader =
1095- (__bridge GADUInterstitialAdPreloader *)interstitialAdPreloaderClient;
1112+ (__bridge GADUInterstitialAdPreloader *)interstitialAdPreloader;
1113+ if (!internalInterstitialAdPreloader) {
1114+ return ;
1115+ }
10961116 [internalInterstitialAdPreloader stopPreloadingAndRemoveAllAds ];
10971117}
10981118
0 commit comments