@@ -42,7 +42,7 @@ void max_unity_dispatch_on_main_thread(dispatch_block_t block)
42
42
}
43
43
#endif
44
44
45
- @interface MAUnityAdManager ()<MAAdDelegate, MAAdViewAdDelegate, MARewardedAdDelegate, MAAdRevenueDelegate, MAAdReviewDelegate>
45
+ @interface MAUnityAdManager ()<MAAdDelegate, MAAdViewAdDelegate, MARewardedAdDelegate, MAAdRevenueDelegate, MAAdReviewDelegate, MAAdExpirationDelegate >
46
46
47
47
// Parent Fields
48
48
@property (nonatomic , weak ) ALSdk *sdk;
@@ -51,7 +51,6 @@ @interface MAUnityAdManager()<MAAdDelegate, MAAdViewAdDelegate, MARewardedAdDele
51
51
@property (nonatomic , strong ) NSMutableDictionary <NSString *, MAInterstitialAd *> *interstitials;
52
52
@property (nonatomic , strong ) NSMutableDictionary <NSString *, MAAppOpenAd *> *appOpenAds;
53
53
@property (nonatomic , strong ) NSMutableDictionary <NSString *, MARewardedAd *> *rewardedAds;
54
- @property (nonatomic , strong ) NSMutableDictionary <NSString *, MARewardedInterstitialAd *> *rewardedInterstitialAds;
55
54
56
55
// AdView Fields
57
56
@property (nonatomic , strong ) NSMutableDictionary <NSString *, MAAdView *> *adViews;
@@ -112,7 +111,6 @@ - (instancetype)init
112
111
self.interstitials = [NSMutableDictionary dictionaryWithCapacity: 2 ];
113
112
self.appOpenAds = [NSMutableDictionary dictionaryWithCapacity: 2 ];
114
113
self.rewardedAds = [NSMutableDictionary dictionaryWithCapacity: 2 ];
115
- self.rewardedInterstitialAds = [NSMutableDictionary dictionaryWithCapacity: 2 ];
116
114
self.adViews = [NSMutableDictionary dictionaryWithCapacity: 2 ];
117
115
self.adViewAdFormats = [NSMutableDictionary dictionaryWithCapacity: 2 ];
118
116
self.adViewPositions = [NSMutableDictionary dictionaryWithCapacity: 2 ];
@@ -518,44 +516,6 @@ - (void)setRewardedAdLocalExtraParameterForAdUnitIdentifier:(nullable NSString *
518
516
[rewardedAd setLocalExtraParameterForKey: key value: value];
519
517
}
520
518
521
- #pragma mark - Rewarded Interstitials
522
-
523
- - (void )loadRewardedInterstitialAdWithAdUnitIdentifier : (nullable NSString *)adUnitIdentifier
524
- {
525
- MARewardedInterstitialAd *rewardedInterstitialAd = [self retrieveRewardedInterstitialAdForAdUnitIdentifier: adUnitIdentifier];
526
- [rewardedInterstitialAd loadAd ];
527
- }
528
-
529
- - (BOOL )isRewardedInterstitialAdReadyWithAdUnitIdentifier : (nullable NSString *)adUnitIdentifier
530
- {
531
- MARewardedInterstitialAd *rewardedInterstitialAd = [self retrieveRewardedInterstitialAdForAdUnitIdentifier: adUnitIdentifier];
532
- return [rewardedInterstitialAd isReady ];
533
- }
534
-
535
- - (void )showRewardedInterstitialAdWithAdUnitIdentifier : (nullable NSString *)adUnitIdentifier placement : (nullable NSString *)placement customData : (nullable NSString *)customData
536
- {
537
- MARewardedInterstitialAd *rewardedInterstitialAd = [self retrieveRewardedInterstitialAdForAdUnitIdentifier: adUnitIdentifier];
538
- [rewardedInterstitialAd showAdForPlacement: placement customData: customData];
539
- }
540
-
541
- - (void )setRewardedInterstitialAdExtraParameterForAdUnitIdentifier : (nullable NSString *)adUnitIdentifier key : (nullable NSString *)key value : (nullable NSString *)value
542
- {
543
- MARewardedInterstitialAd *rewardedInterstitialAd = [self retrieveRewardedInterstitialAdForAdUnitIdentifier: adUnitIdentifier];
544
- [rewardedInterstitialAd setExtraParameterForKey: key value: value];
545
- }
546
-
547
- - (void )setRewardedInterstitialAdLocalExtraParameterForAdUnitIdentifier : (nullable NSString *)adUnitIdentifier key : (nullable NSString *)key value : (nullable id )value
548
- {
549
- if ( !key )
550
- {
551
- [self log : @" Failed to set local extra parameter: No key specified" ];
552
- return ;
553
- }
554
-
555
- MARewardedInterstitialAd *rewardedInterstitialAd = [self retrieveRewardedInterstitialAdForAdUnitIdentifier: adUnitIdentifier];
556
- [rewardedInterstitialAd setLocalExtraParameterForKey: key value: value];
557
- }
558
-
559
519
#pragma mark - Event Tracking
560
520
561
521
- (void )trackEvent : (nullable NSString *)event parameters : (nullable NSString *)parameters
@@ -627,6 +587,7 @@ - (NSString *)adInfoForAdUnitIdentifier:(nullable NSString *)adUnitIdentifier
627
587
networkInfoObject[@" adapterClassName" ] = response.mediatedNetwork .adapterClassName ;
628
588
networkInfoObject[@" adapterVersion" ] = response.mediatedNetwork .adapterVersion ;
629
589
networkInfoObject[@" sdkVersion" ] = response.mediatedNetwork .sdkVersion ;
590
+ networkInfoObject[@" initializationStatus" ] = @(response.mediatedNetwork .initializationStatus );
630
591
631
592
networkResponseDict[@" mediatedNetwork" ] = networkInfoObject;
632
593
}
@@ -705,10 +666,6 @@ - (void)didLoadAd:(MAAd *)ad
705
666
{
706
667
name = @" OnRewardedAdLoadedEvent" ;
707
668
}
708
- else if ( MAAdFormat.rewardedInterstitial == adFormat )
709
- {
710
- name = @" OnRewardedInterstitialAdLoadedEvent" ;
711
- }
712
669
else
713
670
{
714
671
[self logInvalidAdFormat: adFormat];
@@ -762,10 +719,6 @@ - (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withErro
762
719
{
763
720
name = @" OnRewardedAdLoadFailedEvent" ;
764
721
}
765
- else if ( self.rewardedInterstitialAds [adUnitIdentifier] )
766
- {
767
- name = @" OnRewardedInterstitialAdLoadFailedEvent" ;
768
- }
769
722
else
770
723
{
771
724
[self log : @" invalid adUnitId from %@ " , [NSThread callStackSymbols ]];
@@ -813,10 +766,6 @@ - (void)didClickAd:(MAAd *)ad
813
766
{
814
767
name = @" OnRewardedAdClickedEvent" ;
815
768
}
816
- else if ( MAAdFormat.rewardedInterstitial == adFormat )
817
- {
818
- name = @" OnRewardedInterstitialAdClickedEvent" ;
819
- }
820
769
else
821
770
{
822
771
[self logInvalidAdFormat: adFormat];
@@ -850,14 +799,10 @@ - (void)didDisplayAd:(MAAd *)ad
850
799
{
851
800
name = @" OnAppOpenAdDisplayedEvent" ;
852
801
}
853
- else if ( MAAdFormat. rewarded == adFormat )
802
+ else // rewarded
854
803
{
855
804
name = @" OnRewardedAdDisplayedEvent" ;
856
805
}
857
- else // rewarded inters
858
- {
859
- name = @" OnRewardedInterstitialAdDisplayedEvent" ;
860
- }
861
806
862
807
NSDictionary <NSString *, id > *args = [self defaultAdEventParametersForName: name withAd: ad];
863
808
[self forwardUnityEventWithArgs: args];
@@ -881,14 +826,10 @@ - (void)didFailToDisplayAd:(MAAd *)ad withError:(MAError *)error
881
826
{
882
827
name = @" OnAppOpenAdFailedToDisplayEvent" ;
883
828
}
884
- else if ( MAAdFormat. rewarded == adFormat )
829
+ else // rewarded
885
830
{
886
831
name = @" OnRewardedAdFailedToDisplayEvent" ;
887
832
}
888
- else // rewarded inters
889
- {
890
- name = @" OnRewardedInterstitialAdFailedToDisplayEvent" ;
891
- }
892
833
893
834
NSMutableDictionary <NSString *, id > *args = [self defaultAdEventParametersForName: name withAd: ad];
894
835
args[@" errorCode" ] = [@(error.code) stringValue ];
@@ -932,14 +873,10 @@ - (void)didHideAd:(MAAd *)ad
932
873
{
933
874
name = @" OnAppOpenAdHiddenEvent" ;
934
875
}
935
- else if ( MAAdFormat. rewarded == adFormat )
876
+ else // rewarded
936
877
{
937
878
name = @" OnRewardedAdHiddenEvent" ;
938
879
}
939
- else // rewarded inters
940
- {
941
- name = @" OnRewardedInterstitialAdHiddenEvent" ;
942
- }
943
880
944
881
NSDictionary <NSString *, id > *args = [self defaultAdEventParametersForName: name withAd: ad];
945
882
[self forwardUnityEventWithArgs: args];
@@ -1022,7 +959,7 @@ - (void)didRewardUserForAd:(MAAd *)ad withReward:(MAReward *)reward
1022
959
dispatch_async (dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
1023
960
1024
961
MAAdFormat *adFormat = ad.format ;
1025
- if ( adFormat != MAAdFormat.rewarded && adFormat != MAAdFormat. rewardedInterstitial )
962
+ if ( adFormat != MAAdFormat.rewarded )
1026
963
{
1027
964
[self logInvalidAdFormat: adFormat];
1028
965
return ;
@@ -1031,10 +968,8 @@ - (void)didRewardUserForAd:(MAAd *)ad withReward:(MAReward *)reward
1031
968
NSString *rewardLabel = reward ? reward.label : @" " ;
1032
969
NSInteger rewardAmountInt = reward ? reward.amount : 0 ;
1033
970
NSString *rewardAmount = [@(rewardAmountInt) stringValue ];
1034
-
1035
- NSString *name = (adFormat == MAAdFormat.rewarded ) ? @" OnRewardedAdReceivedRewardEvent" : @" OnRewardedInterstitialAdReceivedRewardEvent" ;
1036
-
1037
-
971
+ NSString *name = @" OnRewardedAdReceivedRewardEvent" ;
972
+
1038
973
NSMutableDictionary <NSString *, id > *args = [self defaultAdEventParametersForName: name withAd: ad];
1039
974
args[@" rewardLabel" ] = rewardLabel;
1040
975
args[@" rewardAmount" ] = rewardAmount;
@@ -1068,10 +1003,6 @@ - (void)didPayRevenueForAd:(MAAd *)ad
1068
1003
{
1069
1004
name = @" OnRewardedAdRevenuePaidEvent" ;
1070
1005
}
1071
- else if ( MAAdFormat.rewardedInterstitial == adFormat )
1072
- {
1073
- name = @" OnRewardedInterstitialAdRevenuePaidEvent" ;
1074
- }
1075
1006
else
1076
1007
{
1077
1008
[self logInvalidAdFormat: adFormat];
@@ -1084,6 +1015,43 @@ - (void)didPayRevenueForAd:(MAAd *)ad
1084
1015
});
1085
1016
}
1086
1017
1018
+ - (void )didReloadExpiredAd : (MAAd *)expiredAd withNewAd : (MAAd *)newAd ;
1019
+ {
1020
+ dispatch_async (dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
1021
+
1022
+ NSString *name;
1023
+ MAAdFormat *adFormat = newAd.format ;
1024
+ if ( MAAdFormat.interstitial == adFormat )
1025
+ {
1026
+ name = @" OnExpiredInterstitialAdReloadedEvent" ;
1027
+ }
1028
+ else if ( MAAdFormat.appOpen == adFormat )
1029
+ {
1030
+ name = @" OnExpiredAppOpenAdReloadedEvent" ;
1031
+ }
1032
+ else if ( MAAdFormat.rewarded == adFormat )
1033
+ {
1034
+ name = @" OnExpiredRewardedAdReloadedEvent " ;
1035
+ }
1036
+ else
1037
+ {
1038
+ [self logInvalidAdFormat: adFormat];
1039
+ return ;
1040
+ }
1041
+
1042
+ @synchronized ( self.adInfoDictLock )
1043
+ {
1044
+ self.adInfoDict [newAd.adUnitIdentifier] = newAd;
1045
+ }
1046
+
1047
+ NSMutableDictionary <NSString *, NSObject *> *args = [NSMutableDictionary dictionary ];
1048
+ args[@" expiredAdInfo" ] = [self adInfoForAd: expiredAd];
1049
+ args[@" newAdInfo" ] = [self adInfoForAd: newAd];
1050
+ args[@" name" ] = name;
1051
+ [self forwardUnityEventWithArgs: args];
1052
+ });
1053
+ }
1054
+
1087
1055
- (void )didGenerateCreativeIdentifier : (NSString *)creativeIdentifier forAd : (MAAd *)ad
1088
1056
{
1089
1057
dispatch_async (dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
@@ -1106,10 +1074,6 @@ - (void)didGenerateCreativeIdentifier:(NSString *)creativeIdentifier forAd:(MAAd
1106
1074
{
1107
1075
name = @" OnRewardedAdReviewCreativeIdGeneratedEvent" ;
1108
1076
}
1109
- else if ( MAAdFormat.rewardedInterstitial == adFormat )
1110
- {
1111
- name = @" OnRewardedInterstitialAdReviewCreativeIdGeneratedEvent" ;
1112
- }
1113
1077
else
1114
1078
{
1115
1079
[self logInvalidAdFormat: adFormat];
@@ -1577,6 +1541,7 @@ - (MAInterstitialAd *)retrieveInterstitialForAdUnitIdentifier:(NSString *)adUnit
1577
1541
result.delegate = self;
1578
1542
result.revenueDelegate = self;
1579
1543
result.adReviewDelegate = self;
1544
+ result.expirationDelegate = self;
1580
1545
1581
1546
self.interstitials [adUnitIdentifier] = result;
1582
1547
}
@@ -1592,6 +1557,7 @@ - (MAAppOpenAd *)retrieveAppOpenAdForAdUnitIdentifier:(NSString *)adUnitIdentifi
1592
1557
result = [[MAAppOpenAd alloc ] initWithAdUnitIdentifier: adUnitIdentifier sdk: self .sdk];
1593
1558
result.delegate = self;
1594
1559
result.revenueDelegate = self;
1560
+ result.expirationDelegate = self;
1595
1561
1596
1562
self.appOpenAds [adUnitIdentifier] = result;
1597
1563
}
@@ -1608,29 +1574,14 @@ - (MARewardedAd *)retrieveRewardedAdForAdUnitIdentifier:(NSString *)adUnitIdenti
1608
1574
result.delegate = self;
1609
1575
result.revenueDelegate = self;
1610
1576
result.adReviewDelegate = self;
1577
+ result.expirationDelegate = self;
1611
1578
1612
1579
self.rewardedAds [adUnitIdentifier] = result;
1613
1580
}
1614
1581
1615
1582
return result;
1616
1583
}
1617
1584
1618
- - (MARewardedInterstitialAd *)retrieveRewardedInterstitialAdForAdUnitIdentifier : (NSString *)adUnitIdentifier
1619
- {
1620
- MARewardedInterstitialAd *result = self.rewardedInterstitialAds [adUnitIdentifier];
1621
- if ( !result )
1622
- {
1623
- result = [[MARewardedInterstitialAd alloc ] initWithAdUnitIdentifier: adUnitIdentifier sdk: self .sdk];
1624
- result.delegate = self;
1625
- result.revenueDelegate = self;
1626
- result.adReviewDelegate = self;
1627
-
1628
- self.rewardedInterstitialAds [adUnitIdentifier] = result;
1629
- }
1630
-
1631
- return result;
1632
- }
1633
-
1634
1585
- (MAAdView *)retrieveAdViewForAdUnitIdentifier : (NSString *)adUnitIdentifier adFormat : (MAAdFormat *)adFormat
1635
1586
{
1636
1587
return [self retrieveAdViewForAdUnitIdentifier: adUnitIdentifier adFormat: adFormat atPosition: nil withOffset: CGPointZero ];
0 commit comments