message:
Unity 3.4.2 adapter updates
Unity 3.4.2 adapter updates

diff:
/// Unity Ads Banner wrapper
GADMAdapterUnityBannerAd *_bannerAd;
-
- /// YES if the adapter is loading.
- BOOL _isLoading;
}
@end
}
- (void)stopBeingDelegate {
- [[GADMAdapterUnitySingleton sharedInstance] stopTrackingDelegate:self];
+ if (_bannerAd != nil) {
[_bannerAd stopBeingDelegate];
}
+ [UnityAds removeDelegate:self];
+}
#pragma mark Interstitial Methods
[strongConnector adapter:self didFailAd:error];
return;
}
- _isLoading = YES;
- [[GADMAdapterUnitySingleton sharedInstance] requestInterstitialAdWithDelegate:self];
+
+ [[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:_gameID];
+ [UnityAds addDelegate:self];
+ [UnityAds load:_placementID];
}
- (void)presentInterstitialFromRootViewController:(UIViewController *)rootViewController {
- // We will send adapterWillPresentInterstitial callback before presenting unity ad because the ad
- // has already loaded.
- [_networkConnector adapterWillPresentInterstitial:self];
- [[GADMAdapterUnitySingleton sharedInstance]
- presentInterstitialAdForViewController:rootViewController
- delegate:self];
+ [UnityAds show:rootViewController placementId:_placementID];
}
#pragma mark Banner Methods
#pragma mark - Unity Delegate Methods
-- (void)unityAdsPlacementStateChanged:(NSString *)placementId
+- (void)unityAdsPlacementStateChanged:(NSString *)placementID
oldState:(UnityAdsPlacementState)oldState
newState:(UnityAdsPlacementState)newState {
- // This callback is not forwarded to the adapter by the GADMAdapterUnitySingleton and the adapter
- // should use the unityAdsReady: and unityAdsDidError: callbacks to forward Unity Ads SDK state to
- // Google Mobile Ads SDK.
+ id<GADMAdNetworkConnector> strongNetworkConnector = _networkConnector;
+ if (strongNetworkConnector && [placementID isEqualToString:_placementID]) {
+ if (newState == kUnityAdsPlacementStateNoFill){
+ NSError *errorWithDescription = GADUnityErrorWithDescription(@"NO_FILL");
+ [strongNetworkConnector adapter:self didFailAd:errorWithDescription];
+ }
+ }
}
- (void)unityAdsDidFinish:(NSString *)placementID withFinishState:(UnityAdsFinishState)state {
id<GADMAdNetworkConnector> strongNetworkConnector = _networkConnector;
- if (strongNetworkConnector) {
+ if (strongNetworkConnector && [placementID isEqualToString:_placementID]) {
[strongNetworkConnector adapterWillDismissInterstitial:self];
[strongNetworkConnector adapterDidDismissInterstitial:self];
+ [UnityAds removeDelegate:self];
}
}
- (void)unityAdsReady:(NSString *)placementID {
id<GADMAdNetworkConnector> strongNetworkConnector = _networkConnector;
- if (!_isLoading) {
- return;
- }
-
- if (strongNetworkConnector) {
+ if (strongNetworkConnector && [placementID isEqualToString:_placementID]) {
[strongNetworkConnector adapterDidReceiveInterstitial:self];
}
- _isLoading = NO;
}
- (void)unityAdsDidClick:(NSString *)placementID {
// The Unity Ads SDK doesn't provide an event for leaving the application, so the adapter assumes
// that a click event indicates the user is leaving the application for a browser or deeplink, and
// notifies the Google Mobile Ads SDK accordingly.
- if (strongNetworkConnector) {
+ if (strongNetworkConnector && [placementID isEqualToString:_placementID]) {
[strongNetworkConnector adapterDidGetAdClick:self];
[strongNetworkConnector adapterWillLeaveApplication:self];
}
- (void)unityAdsDidError:(UnityAdsError)error withMessage:(NSString *)message {
id<GADMAdNetworkConnector> strongNetworkConnector = _networkConnector;
- if (!_isLoading) {
- // Unity Ads show error will only happen after the ad has been loaded. So, we will send
- // dismiss/close callbacks.
- if (error == kUnityAdsErrorShowError) {
if (strongNetworkConnector) {
+ NSError *errorWithDescription = GADUnityErrorWithDescription(message);
+ [strongNetworkConnector adapter:self didFailAd:errorWithDescription];
+ if (error == kUnityAdsErrorShowError) {
[strongNetworkConnector adapterWillDismissInterstitial:self];
[strongNetworkConnector adapterDidDismissInterstitial:self];
}
+ [UnityAds removeDelegate:self];
}
return;
}
- NSError *errorWithDescription = GADUnityErrorWithDescription(message);
- if (strongNetworkConnector) {
- [strongNetworkConnector adapter:self didFailAd:errorWithDescription];
- }
- _isLoading = NO;
+- (void)unityAdsDidStart:(nonnull NSString *)placementID {
+ id<GADMAdNetworkConnector> strongNetworkConnector = _networkConnector;
+ if (strongNetworkConnector && [placementID isEqualToString:_placementID]) {
+ [strongNetworkConnector adapterWillPresentInterstitial:self];
}
-
-- (void)unityAdsDidStart:(nonnull NSString *)placementId {
- // nothing to do
}
@end

diff:
_placementID = [_adConfiguration.credentials.settings objectForKey:kGADMAdapterUnityPlacementID];
NSLog(@"Requesting unity rewarded ad with placement: %@", _placementID);
- GADMAdapterUnityRewardedAd __weak *weakSelf = self;
-
if (!_gameID || !_placementID) {
if (_adLoadCompletionHandler) {
NSError *error = GADUnityErrorWithDescription(@"Game ID and Placement ID cannot be nil.");
return;
}
- if ([UnityAds isReady:_placementID]) {
- if (_adLoadCompletionHandler) {
- _adEventDelegate = _adLoadCompletionHandler(self, nil);
- _adLoadCompletionHandler = nil;
- }
- _isLoading = NO;
- } else {
- _isLoading = YES;
- }
-
- [[GADMAdapterUnitySingleton sharedInstance] requestRewardedAdWithDelegate:weakSelf];
+ [[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:_gameID];
+ [UnityAds addDelegate:self];
+ [UnityAds load:_placementID];
}
- (void)presentFromViewController:(nonnull UIViewController *)viewController {
- if (_isLoading) {
- NSError *presentError = GADUnityErrorWithDescription(@"Ad has not finished loading.");
- [_adEventDelegate didFailToPresentWithError:presentError];
- } else {
- [[GADMAdapterUnitySingleton sharedInstance] presentRewardedAdForViewController:viewController
- delegate:self];
- }
+ [UnityAds show:viewController placementId:_placementID];
}
#pragma mark GADMAdapterUnityDataProvider Methods
#pragma mark - Unity Delegate Methods
- (void)unityAdsDidError:(UnityAdsError)error withMessage:(nonnull NSString *)message {
- if (!_isLoading) {
- if (error == kUnityAdsErrorShowError) {
+ id<GADMediationRewardedAdEventDelegate> strongDelegate = _adEventDelegate;
+ if (strongDelegate && error == kUnityAdsErrorShowError) {
NSError *presentError = GADUnityErrorWithDescription(message);
[_adEventDelegate didFailToPresentWithError:presentError];
}
- return;
- }
if (_adLoadCompletionHandler) {
NSError *errorWithDescription = GADUnityErrorWithDescription(message);
_adLoadCompletionHandler(nil, errorWithDescription);
_adLoadCompletionHandler = nil;
}
- _isLoading = NO;
}
-- (void)unityAdsDidFinish:(nonnull NSString *)placementId
+- (void)unityAdsDidFinish:(nonnull NSString *)placementID
withFinishState:(UnityAdsFinishState)state {
id<GADMediationRewardedAdEventDelegate> strongDelegate = _adEventDelegate;
+ if (strongDelegate && [placementID isEqualToString:_placementID]) {
if (state == kUnityAdsFinishStateCompleted) {
[strongDelegate didEndVideo];
// Unity Ads doesn't provide a way to set the reward on their front-end. Default to a reward
}
[strongDelegate willDismissFullScreenView];
[strongDelegate didDismissFullScreenView];
+ [UnityAds removeDelegate:self];
+ }
}
-- (void)unityAdsDidStart:(nonnull NSString *)placementId {
+- (void)unityAdsDidStart:(nonnull NSString *)placementID {
id<GADMediationRewardedAdEventDelegate> strongDelegate = _adEventDelegate;
+ if (strongDelegate && [placementID isEqualToString:_placementID]) {
[strongDelegate willPresentFullScreenView];
[strongDelegate didStartVideo];
}
-
-- (void)unityAdsReady:(nonnull NSString *)placementId {
- if (!_isLoading) {
- return;
}
- if (_adLoadCompletionHandler) {
+- (void)unityAdsReady:(nonnull NSString *)placementID {
+ if (_adLoadCompletionHandler && [placementID isEqualToString:_placementID]) {
_adEventDelegate = _adLoadCompletionHandler(self, nil);
_adLoadCompletionHandler = nil;
}
- _isLoading = NO;
}
-- (void)unityAdsDidClick:(nonnull NSString *)placementId {
+- (void)unityAdsDidClick:(nonnull NSString *)placementID {
// The Unity Ads SDK doesn't provide an event for leaving the application, so the adapter assumes
// that a click event indicates the user is leaving the application for a browser or deeplink, and
// notifies the Google Mobile Ads SDK accordingly.
id<GADMediationRewardedAdEventDelegate> strongDelegate = _adEventDelegate;
+ if (strongDelegate && [placementID isEqualToString:_placementID]) {
[strongDelegate reportClick];
}
+}
-- (void)unityAdsPlacementStateChanged:(nonnull NSString *)placementId
+- (void)unityAdsPlacementStateChanged:(nonnull NSString *)placementID
oldState:(UnityAdsPlacementState)oldState
newState:(UnityAdsPlacementState)newState {
// This callback is not forwarded to the adapter by the GADMAdapterUnitySingleton and the adapter
// should use the unityAdsReady: and unityAdsDidError: callbacks to forward Unity Ads SDK state to
// Google Mobile Ads SDK.
+ //id<GADMediationRewardedAdEventDelegate> strongDelegate = _adEventDelegate;
+ if (_adLoadCompletionHandler && [placementID isEqualToString:_placementID] && newState == kUnityAdsPlacementStateNoFill) {
+ NSError *errorWithDescription = GADUnityErrorWithDescription(@"NO_FILL");
+ _adLoadCompletionHandler(nil, errorWithDescription);
+ _adLoadCompletionHandler = nil;
+ }
}
@end

diff:
- (void)initializeWithGameID:(NSString *)gameID;
-/// Requests a reward-based video ad with |adapterDelegate|.
-- (void)requestRewardedAdWithDelegate:
- (id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)adapterDelegate;
-
-/// Presents a reward-based video ad for |viewController| with |adapterDelegate|.
-- (void)presentRewardedAdForViewController:(UIViewController *)viewController
- delegate:
- (id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)
- adapterDelegate;
-
-/// Configures an interstitial ad with provided |gameID| and |adapterDelegate|.
-- (void)requestInterstitialAdWithDelegate:
- (id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)adapterDelegate;
-
-/// Presents an interstitial ad for |viewController| with |adapterDelegate|.
-- (void)presentInterstitialAdForViewController:(UIViewController *)viewController
- delegate:(id<GADMAdapterUnityDataProvider,
- UnityAdsExtendedDelegate>)adapterDelegate;
-
-/// Tells the adapter to remove itself as a |adapterDelegate|.
-- (void)stopTrackingDelegate:
- (id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)adapterDelegate;
-
@end

diff:
#import "GADMAdapterUnityConstants.h"
#import "GADMAdapterUnityUtils.h"
-@interface GADMAdapterUnitySingleton () <UnityAdsExtendedDelegate> {
+@interface GADMAdapterUnitySingleton () {
/// Array to hold all adapter delegates.
NSMapTable *_adapterDelegates;
[mediationMetaData commit];
// Initializing Unity Ads with |gameID|.
- [UnityAds initialize:gameID delegate:self testMode:false enablePerPlacementLoad:true];
-}
-
-- (void)addAdapterDelegate:
- (id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)adapterDelegate {
- @synchronized(_adapterDelegates) {
- [_adapterDelegates setObject:adapterDelegate forKey:[adapterDelegate getPlacementID]];
- }
-}
-
-#pragma mark - Rewardbased video ad methods
-
-- (void)requestRewardedAdWithDelegate:
- (id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)adapterDelegate {
- NSString *gameID = [adapterDelegate getGameID];
- NSString *placementID = [adapterDelegate getPlacementID];
-
- @synchronized(_adapterDelegates) {
- if ([_adapterDelegates objectForKey:placementID]) {
- NSString *message = @"An ad is already loading for placement ID %@";
- [adapterDelegate unityAdsDidError:kUnityAdsErrorInternalError
- withMessage:[NSString stringWithFormat:message, placementID]];
- return;
- }
- }
-
- [self addAdapterDelegate:adapterDelegate];
-
- if (![UnityAds isInitialized]) {
- [self initializeWithGameID:gameID];
- }
-
- [UnityAds load:placementID];
- if ([UnityAds isReady:placementID]) {
- [adapterDelegate unityAdsReady:placementID];
- }
-}
-
-- (void)presentRewardedAdForViewController:(UIViewController *)viewController
- delegate:
- (id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)
- adapterDelegate {
- _currentShowingUnityDelegate = adapterDelegate;
-
- NSString *placementID = [adapterDelegate getPlacementID];
- if ([UnityAds isReady:placementID]) {
- UADSMediationMetaData *mediationMetaData = [[UADSMediationMetaData alloc] init];
- [mediationMetaData setOrdinal:impressionOrdinal++];
- [mediationMetaData commit];
- [UnityAds show:viewController placementId:placementID];
- } else {
- UADSMediationMetaData *mediationMetaData = [[UADSMediationMetaData alloc] init];
- [mediationMetaData setMissedImpressionOrdinal:missedImpressionOrdinal++];
- [mediationMetaData commit];
- }
-}
-
-#pragma mark - Interstitial ad methods
-
-- (void)requestInterstitialAdWithDelegate:
- (id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)adapterDelegate {
- NSString *gameID = [adapterDelegate getGameID];
- NSString *placementID = [adapterDelegate getPlacementID];
-
- @synchronized(_adapterDelegates) {
- if ([_adapterDelegates objectForKey:placementID]) {
- NSString *message = @"An ad is already loading for placement ID %@";
- [adapterDelegate unityAdsDidError:kUnityAdsErrorInternalError
- withMessage:[NSString stringWithFormat:message, placementID]];
- return;
- }
- }
-
- [self addAdapterDelegate:adapterDelegate];
-
- if (![UnityAds isInitialized]) {
- [self initializeWithGameID:gameID];
- }
-
- [UnityAds load:placementID];
- if ([UnityAds isReady:placementID]) {
- [adapterDelegate unityAdsReady:placementID];
- }
-}
-
-- (void)presentInterstitialAdForViewController:(UIViewController *)viewController
- delegate:(id<GADMAdapterUnityDataProvider,
- UnityAdsExtendedDelegate>)adapterDelegate {
- _currentShowingUnityDelegate = adapterDelegate;
-
- NSString *placementID = [adapterDelegate getPlacementID];
- if ([UnityAds isReady:placementID]) {
- UADSMediationMetaData *mediationMetaData = [[UADSMediationMetaData alloc] init];
- [mediationMetaData setOrdinal:impressionOrdinal++];
- [mediationMetaData commit];
- [UnityAds show:viewController placementId:placementID];
- } else {
- UADSMediationMetaData *mediationMetaData = [[UADSMediationMetaData alloc] init];
- [mediationMetaData setMissedImpressionOrdinal:missedImpressionOrdinal++];
- [mediationMetaData commit];
- }
-}
-
-#pragma mark - Unity Delegate Methods
-
-- (void)unityAdsPlacementStateChanged:(NSString *)placementId
- oldState:(UnityAdsPlacementState)oldState
- newState:(UnityAdsPlacementState)newState {
- // This callback is not forwarded to the adapter by the GADMAdapterUnitySingleton and the adapter
- // should use the unityAdsReady: and unityAdsDidError: callbacks to forward Unity Ads SDK state to
- // Google Mobile Ads SDK.
-}
-
-- (void)unityAdsDidFinish:(NSString *)placementID withFinishState:(UnityAdsFinishState)state {
- @synchronized(_adapterDelegates) {
- GADMAdapterUnityMapTableRemoveObjectForKey(_adapterDelegates, placementID);
- }
- [_currentShowingUnityDelegate unityAdsDidFinish:placementID withFinishState:state];
-}
-
-- (void)unityAdsDidStart:(NSString *)placementID {
- [_currentShowingUnityDelegate unityAdsDidStart:placementID];
-}
-
-- (void)unityAdsReady:(NSString *)placementID {
- id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate> adapterDelegate;
- @synchronized(_adapterDelegates) {
- adapterDelegate = [_adapterDelegates objectForKey:placementID];
- }
-
- if (adapterDelegate) {
- [adapterDelegate unityAdsReady:placementID];
- }
-}
-
-- (void)unityAdsDidClick:(NSString *)placementID {
- [_currentShowingUnityDelegate unityAdsDidClick:placementID];
-}
-
-- (void)unityAdsDidError:(UnityAdsError)error withMessage:(NSString *)message {
- if (error == kUnityAdsErrorShowError) {
- [_currentShowingUnityDelegate unityAdsDidError:error withMessage:message];
- return;
- }
-
- NSArray *delegates;
- @synchronized(_adapterDelegates) {
- delegates = _adapterDelegates.objectEnumerator.allObjects;
- }
-
- for (id<UnityAdsExtendedDelegate, UnityAdsExtendedDelegate> delegate in delegates) {
- [delegate unityAdsDidError:error withMessage:message];
- }
-
- @synchronized(_adapterDelegates) {
- [_adapterDelegates removeAllObjects];
- }
-}
-
-- (void)stopTrackingDelegate:
- (id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)adapterDelegate {
- GADMAdapterUnityMapTableRemoveObjectForKey(_adapterDelegates, [adapterDelegate getPlacementID]);
+ [UnityAds initialize:gameID testMode:false enablePerPlacementLoad:true];
}
@end


message:
Update singleton to use complete block
Update singleton to use complete block

change_type: MODIFY

diff:
return;
}
- [[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:_gameID];
+ UnitySingletonCompletion completeBlock = ^(UnityAdsError *error, NSString *message) {
+ if(!error) {
[UnityAds addDelegate:self];
- [UnityAds load:_placementID];
+ [UnityAds load:[self getPlacementID]];
+ } else {
+ id<GADMAdNetworkConnector> strongNetworkConnector = self->_networkConnector;
+ if (strongNetworkConnector) {
+ NSError *errorWithDescription = GADUnityErrorWithDescription(message);
+ [strongNetworkConnector adapter:self didFailAd:errorWithDescription];
+ }
+ }
+ };
+
+ [[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:_gameID
+ completeBlock:completeBlock];
}
- (void)presentInterstitialFromRootViewController:(UIViewController *)rootViewController {
- (void)unityAdsDidFinish:(NSString *)placementID withFinishState:(UnityAdsFinishState)state {
id<GADMAdNetworkConnector> strongNetworkConnector = _networkConnector;
if (strongNetworkConnector && [placementID isEqualToString:_placementID]) {
+ if (state == kUnityAdsFinishStateCompleted) {
+
+
+ } else if (state == kUnityAdsFinishStateError) {
+ [strongNetworkConnector adapterWillDismissInterstitial:self];
+ [strongNetworkConnector adapterDidDismissInterstitial:self];
+
+ } else if (state == kUnityAdsFinishStateSkipped) {
[strongNetworkConnector adapterWillDismissInterstitial:self];
[strongNetworkConnector adapterDidDismissInterstitial:self];
+
+ }
[UnityAds removeDelegate:self];
}
}
}
- (void)unityAdsDidError:(UnityAdsError)error withMessage:(NSString *)message {
- id<GADMAdNetworkConnector> strongNetworkConnector = _networkConnector;
- if (strongNetworkConnector) {
- NSError *errorWithDescription = GADUnityErrorWithDescription(message);
- [strongNetworkConnector adapter:self didFailAd:errorWithDescription];
- if (error == kUnityAdsErrorShowError) {
- [strongNetworkConnector adapterWillDismissInterstitial:self];
- [strongNetworkConnector adapterDidDismissInterstitial:self];
- }
- [UnityAds removeDelegate:self];
- }
- return;
+// id<GADMAdNetworkConnector> strongNetworkConnector = _networkConnector;
+// if (strongNetworkConnector) {
+// NSError *errorWithDescription = GADUnityErrorWithDescription(message);
+// [strongNetworkConnector adapter:self didFailAd:errorWithDescription];
+// if (error == kUnityAdsErrorShowError) {
+// [strongNetworkConnector adapterWillDismissInterstitial:self];
+// [strongNetworkConnector adapterDidDismissInterstitial:self];
+// }
+// [UnityAds removeDelegate:self];
+// }
+// return;
}
- (void)unityAdsDidStart:(nonnull NSString *)placementID {

diff:
if (![UnityAds isInitialized]) {
NSString *gameID = [strongConnector.credentials[kGADMAdapterUnityGameID] copy];
- [GADMAdapterUnitySingleton.sharedInstance initializeWithGameID:gameID];
+
+ UnitySingletonCompletion completeBlock = ^(UnityAdsError *error, NSString *message) {
+ if(!error) {
+ [UnityAds addDelegate:self];
+ [UnityAds load:gameID];
+ } else {
+ id<GADMAdNetworkConnector> strongConnector = self->_connector;
+ id<GADMAdNetworkAdapter> strongAdapter = self->_adapter;
+ if (strongConnector && strongAdapter) {
+ [strongConnector adapter:strongAdapter didFailAd:GADUnityErrorWithDescription(message)];
+ }
+ }
+ };
+
+ [[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:gameID
+ completeBlock:completeBlock];
}
_placementID = [strongConnector.credentials[kGADMAdapterUnityPlacementID] copy];

diff:
return;
}
- [[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:_gameID];
+ UnitySingletonCompletion completeBlock = ^(UnityAdsError *error, NSString *message) {
+ if(!error) {
[UnityAds addDelegate:self];
- [UnityAds load:_placementID];
+ [UnityAds load:[self getPlacementID]];
+ } else {
+ NSError *errorWithDescription = GADUnityErrorWithDescription(message);
+ self->_adLoadCompletionHandler(nil, errorWithDescription);
+ self->_adLoadCompletionHandler = nil;
+ }
+ };
+
+ [[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:_gameID
+ completeBlock:completeBlock];
+
}
- (void)presentFromViewController:(nonnull UIViewController *)viewController {
#pragma mark - Unity Delegate Methods
- (void)unityAdsDidError:(UnityAdsError)error withMessage:(nonnull NSString *)message {
- id<GADMediationRewardedAdEventDelegate> strongDelegate = _adEventDelegate;
- if (strongDelegate && error == kUnityAdsErrorShowError) {
- NSError *presentError = GADUnityErrorWithDescription(message);
- [_adEventDelegate didFailToPresentWithError:presentError];
- }
-
- if (_adLoadCompletionHandler) {
- NSError *errorWithDescription = GADUnityErrorWithDescription(message);
- _adLoadCompletionHandler(nil, errorWithDescription);
- _adLoadCompletionHandler = nil;
- }
+// id<GADMediationRewardedAdEventDelegate> strongDelegate = _adEventDelegate;
+// if (strongDelegate && error == kUnityAdsErrorShowError) {
+// NSError *presentError = GADUnityErrorWithDescription(message);
+// [_adEventDelegate didFailToPresentWithError:presentError];
+// }
+//
+// if (_adLoadCompletionHandler) {
+// NSError *errorWithDescription = GADUnityErrorWithDescription(message);
+// _adLoadCompletionHandler(nil, errorWithDescription);
+// _adLoadCompletionHandler = nil;
+// }
}
- (void)unityAdsDidFinish:(nonnull NSString *)placementID
GADAdReward *reward = [[GADAdReward alloc] initWithRewardType:@""
rewardAmount:[NSDecimalNumber one]];
[strongDelegate didRewardUserWithReward:reward];
+ } else if (state == kUnityAdsFinishStateError) {
+ NSError *presentError = GADUnityErrorWithDescription(@"Finish State Error");
+ [strongDelegate didFailToPresentWithError:presentError];
}
[strongDelegate willDismissFullScreenView];
[strongDelegate didDismissFullScreenView];
+ [strongDelegate didEndVideo];
[UnityAds removeDelegate:self];
}
}

diff:
#import "GADMAdapterUnityProtocol.h"
+typedef void (^UnitySingletonCompletion)(UnityAdsError *error, NSString *message);
+
@interface GADMAdapterUnitySingleton : NSObject
+@property (nonatomic, strong) UnitySingletonCompletion completeBlock;
+
/// Shared instance.
+ (instancetype)sharedInstance;
/// Configures a reward-based video ad with provided |gameID| and |adapterDelegate| and returns
/// YES if successful; otherwise returns NO.
-- (void)initializeWithGameID:(NSString *)gameID;
+- (void)initializeWithGameID:(NSString *)gameID
+ completeBlock:(UnitySingletonCompletion)completeBlock;
@end

diff:
#import "GADMAdapterUnityConstants.h"
#import "GADMAdapterUnityUtils.h"
-@interface GADMAdapterUnitySingleton () {
- /// Array to hold all adapter delegates.
- NSMapTable *_adapterDelegates;
-
- int impressionOrdinal;
- int missedImpressionOrdinal;
-
- /// Connector from unity adapter to send Unity callbacks.
- __weak id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate> _currentShowingUnityDelegate;
-}
+@interface GADMAdapterUnitySingleton () <UnityAdsExtendedDelegate>
@end
- (id)init {
self = [super init];
- if (self) {
- _adapterDelegates = [NSMapTable mapTableWithKeyOptions:NSMapTableStrongMemory
- valueOptions:NSMapTableWeakMemory];
- }
return self;
}
-- (void)initializeWithGameID:(NSString *)gameID {
+- (void)initializeWithGameID:(NSString *)gameID
+ completeBlock:(UnitySingletonCompletion)completeBlock{
if ([UnityAds isInitialized]) {
+ completeBlock(NULL, @"UnityAds Initialization Succeeded");
return;
}
- // Metadata needed by Unity Ads SDK before initialization.
+ [self setCompleteBlock:completeBlock];
+
UADSMediationMetaData *mediationMetaData = [[UADSMediationMetaData alloc] init];
[mediationMetaData setName:kGADMAdapterUnityMediationNetworkName];
[mediationMetaData setVersion:kGADMAdapterUnityVersion];
[mediationMetaData set:@"adapter_version" value:[UnityAds getVersion]];
[mediationMetaData commit];
- // Initializing Unity Ads with |gameID|.
- [UnityAds initialize:gameID testMode:NO enablePerPlacementLoad:YES];
+ [UnityAds initialize:gameID testMode:false enablePerPlacementLoad:true];
+ [UnityAds addDelegate:self];
+}
+
+#pragma mark - Unity Delegate Methods
+
+- (void)unityAdsPlacementStateChanged:(NSString *)placementId
+ oldState:(UnityAdsPlacementState)oldState
+ newState:(UnityAdsPlacementState)newState {
+ if (newState == kUnityAdsPlacementStateWaiting || newState == kUnityAdsPlacementStateReady) {
+ if (self.completeBlock) {
+ self.completeBlock(NULL, @"UnityAds Initialization Succeeded");
+ }
+ }
+ return;
+}
+
+- (void)unityAdsDidError:(UnityAdsError)error withMessage:(NSString *)message {
+ if (error == kUnityAdsErrorNotInitialized || error == kUnityAdsErrorInvalidArgument || error == kUnityAdsErrorInitializedFailed || error == kUnityAdsErrorInitSanityCheckFail) {
+ if (self.completeBlock) {
+ self.completeBlock(&error, @"Unity Ads Initialization Failed");
+ }
+ }
+ return;
+}
+
+- (void)unityAdsDidFinish:(NSString *)placementID withFinishState:(UnityAdsFinishState)state {
+}
+
+- (void)unityAdsDidStart:(NSString *)placementID {
+}
+
+- (void)unityAdsReady:(NSString *)placementID {
+}
+
+- (void)unityAdsDidClick:(NSString *)placementID {
}
@end

diff:
#import "GADUnityError.h"
@import UnityAds;
-@interface GADMediationAdapterUnity ()
+@interface GADMediationAdapterUnity () <GADMediationAdapter>
@property(nonatomic, strong) GADMAdapterUnityRewardedAd *rewardedAd;
NSLog(@"Initializing Unity Ads SDK with the game ID %@.", gameID);
}
- [[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:gameID];
+ UnitySingletonCompletion completeBlock = ^(UnityAdsError *error, NSString *message) {
+ if(!error && completionHandler) {
completionHandler(nil);
+ } else {
+ completionHandler(GADUnityErrorWithDescription(message));
+ }
+ };
+
+ [[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:gameID
+ completeBlock:completeBlock];
}
+ (GADVersionNumber)adSDKVersion {

license: Apache License 2.0


message:
update rewardedloadcompletionHandler
update rewardedloadcompletionHandler

diff:
[UnityAds addDelegate:self];
[UnityAds load:[self getPlacementID]];
} else {
- id<GADMAdNetworkConnector> strongNetworkConnector = self->_networkConnector;
- if (strongNetworkConnector) {
+ if (strongConnector) {
NSError *errorWithDescription = GADUnityErrorWithDescription(message);
- [strongNetworkConnector adapter:self didFailAd:errorWithDescription];
+ [strongConnector adapter:self didFailAd:errorWithDescription];
}
}
};

diff:
[UnityAds addDelegate:self];
[UnityAds load:gameID];
} else {
- id<GADMAdNetworkConnector> strongConnector = self->_connector;
- id<GADMAdNetworkAdapter> strongAdapter = self->_adapter;
if (strongConnector && strongAdapter) {
[strongConnector adapter:strongAdapter didFailAd:GADUnityErrorWithDescription(message)];
}

diff:
#import "GADUnityError.h"
@interface GADMAdapterUnityRewardedAd () <GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate> {
- // The completion handler to call when the ad loading succeeds or fails.
- GADMediationRewardedLoadCompletionHandler _adLoadCompletionHandler;
-
// Ad configuration for the ad to be rendered.
GADMediationAdConfiguration *_adConfiguration;
BOOL _isLoading;
}
+// The completion handler to call when the ad loading succeeds or fails.
+@property (nonatomic, copy)GADMediationRewardedLoadCompletionHandler adLoadCompletionHandler;
@end
@implementation GADMAdapterUnityRewardedAd
}
return;
}
+ GADMAdapterUnityRewardedAd *__weak weakSelf = self;
UnitySingletonCompletion completeBlock = ^(UnityAdsError *error, NSString *message) {
if(!error) {
[UnityAds load:[self getPlacementID]];
} else {
NSError *errorWithDescription = GADUnityErrorWithDescription(message);
- self->_adLoadCompletionHandler(nil, errorWithDescription);
- self->_adLoadCompletionHandler = nil;
+ if(weakSelf) {
+ weakSelf.adLoadCompletionHandler(nil, errorWithDescription);
+ }
}
};
[[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:_gameID
completeBlock:completeBlock];
-
}
- (void)presentFromViewController:(nonnull UIViewController *)viewController {
#pragma mark - Unity Delegate Methods
- (void)unityAdsDidError:(UnityAdsError)error withMessage:(nonnull NSString *)message {
-// id<GADMediationRewardedAdEventDelegate> strongDelegate = _adEventDelegate;
-// if (strongDelegate && error == kUnityAdsErrorShowError) {
-// NSError *presentError = GADUnityErrorWithDescription(message);
-// [_adEventDelegate didFailToPresentWithError:presentError];
-// }
-//
-// if (_adLoadCompletionHandler) {
-// NSError *errorWithDescription = GADUnityErrorWithDescription(message);
-// _adLoadCompletionHandler(nil, errorWithDescription);
-// _adLoadCompletionHandler = nil;
-// }
}
- (void)unityAdsDidFinish:(nonnull NSString *)placementID
}
[strongDelegate willDismissFullScreenView];
[strongDelegate didDismissFullScreenView];
- [strongDelegate didEndVideo];
[UnityAds removeDelegate:self];
}
}


message:
clear completeBlock after called it once
clear completeBlock after called it once

diff:
if (newState == kUnityAdsPlacementStateNoFill){
NSError *errorWithDescription = GADUnityErrorWithDescription(@"NO_FILL");
[strongNetworkConnector adapter:self didFailAd:errorWithDescription];
+ } else if (newState == kUnityAdsPlacementStateDisabled) {
+ NSError *errorWithDescription = GADUnityErrorWithDescription(@"PlACEMENT_DISABLED");
+ [strongNetworkConnector adapter:self didFailAd:errorWithDescription];
+ } else if (newState == kUnityAdsPlacementStateNotAvailable) {
+ NSError *errorWithDescription = GADUnityErrorWithDescription(@"PlACEMENT_NOTAVAILABLE");
+ [strongNetworkConnector adapter:self didFailAd:errorWithDescription];
}
}
}
id<GADMAdNetworkConnector> strongNetworkConnector = _networkConnector;
if (strongNetworkConnector && [placementID isEqualToString:_placementID]) {
if (state == kUnityAdsFinishStateCompleted) {
-
-
+ [strongNetworkConnector adapterDidDismissInterstitial:self];
} else if (state == kUnityAdsFinishStateError) {
- [strongNetworkConnector adapterWillDismissInterstitial:self];
+ [strongNetworkConnector adapterWillPresentInterstitial:self];
[strongNetworkConnector adapterDidDismissInterstitial:self];
-
} else if (state == kUnityAdsFinishStateSkipped) {
- [strongNetworkConnector adapterWillDismissInterstitial:self];
[strongNetworkConnector adapterDidDismissInterstitial:self];
-
}
[UnityAds removeDelegate:self];
}
}
- (void)unityAdsDidError:(UnityAdsError)error withMessage:(NSString *)message {
-// id<GADMAdNetworkConnector> strongNetworkConnector = _networkConnector;
-// if (strongNetworkConnector) {
-// NSError *errorWithDescription = GADUnityErrorWithDescription(message);
-// [strongNetworkConnector adapter:self didFailAd:errorWithDescription];
-// if (error == kUnityAdsErrorShowError) {
-// [strongNetworkConnector adapterWillDismissInterstitial:self];
-// [strongNetworkConnector adapterDidDismissInterstitial:self];
-// }
-// [UnityAds removeDelegate:self];
-// }
-// return;
+ //do nothing.
}
- (void)unityAdsDidStart:(nonnull NSString *)placementID {

diff:
rewardAmount:[NSDecimalNumber one]];
[strongDelegate didRewardUserWithReward:reward];
} else if (state == kUnityAdsFinishStateError) {
+ [strongDelegate willPresentFullScreenView];
NSError *presentError = GADUnityErrorWithDescription(@"Finish State Error");
[strongDelegate didFailToPresentWithError:presentError];
}
- [strongDelegate willDismissFullScreenView];
[strongDelegate didDismissFullScreenView];
[UnityAds removeDelegate:self];
}
- (void)unityAdsReady:(nonnull NSString *)placementID {
if (_adLoadCompletionHandler && [placementID isEqualToString:_placementID]) {
_adEventDelegate = _adLoadCompletionHandler(self, nil);
- _adLoadCompletionHandler = nil;
}
}
// should use the unityAdsReady: and unityAdsDidError: callbacks to forward Unity Ads SDK state to
// Google Mobile Ads SDK.
//id<GADMediationRewardedAdEventDelegate> strongDelegate = _adEventDelegate;
- if (_adLoadCompletionHandler && [placementID isEqualToString:_placementID] && newState == kUnityAdsPlacementStateNoFill) {
+ if (_adLoadCompletionHandler && [placementID isEqualToString:_placementID]) {
+ if (newState == kUnityAdsPlacementStateNoFill) {
NSError *errorWithDescription = GADUnityErrorWithDescription(@"NO_FILL");
_adLoadCompletionHandler(nil, errorWithDescription);
- _adLoadCompletionHandler = nil;
+ } else if (newState == kUnityAdsPlacementStateNotAvailable) {
+ NSError *errorWithDescription = GADUnityErrorWithDescription(@"PlACEMENT_NOTAVAILABLE");
+ _adLoadCompletionHandler(nil, errorWithDescription);
+ } else if (newState == kUnityAdsPlacementStateDisabled) {
+ NSError *errorWithDescription = GADUnityErrorWithDescription(@"PlACEMENT_DISABLED");
+ _adLoadCompletionHandler(nil, errorWithDescription);
+ }
}
}

diff:
if (newState == kUnityAdsPlacementStateWaiting || newState == kUnityAdsPlacementStateReady) {
if (self.completeBlock) {
self.completeBlock(NULL, @"UnityAds Initialization Succeeded");
+ self.completeBlock = nil;
}
}
return;
if (error == kUnityAdsErrorNotInitialized || error == kUnityAdsErrorInvalidArgument || error == kUnityAdsErrorInitializedFailed || error == kUnityAdsErrorInitSanityCheckFail) {
if (self.completeBlock) {
self.completeBlock(&error, @"Unity Ads Initialization Failed");
+ self.completeBlock = nil;
}
}
return;


message:
move delegate
move delegate

diff:
[mediationMetaData set:@"adapter_version" value:[UnityAds getVersion]];
[mediationMetaData commit];
- [UnityAds initialize:gameID testMode:false enablePerPlacementLoad:true];
[UnityAds addDelegate:self];
+ [UnityAds initialize:gameID testMode:false enablePerPlacementLoad:true];
}
#pragma mark - Unity Delegate Methods

original_message:
move delegate

move delegate


message: Updated for FAN 5.7

diff:
## Facebook iOS Mediation Adapter Changelog
+#### Version 5.7.0.0
+- Verified compatibility with FAN SDK 5.7.0.
+
#### Version 5.6.1.0
- Verified compatibility with FAN SDK 5.6.1.

diff:
// limitations under the License.
/// Facebook mediation network adapter version.
-static NSString *const kGADMAdapterFacebookVersion = @"5.6.1.0";
+static NSString *const kGADMAdapterFacebookVersion = @"5.7.0.0";
static NSString *const kGADMAdapterFacebookOpenBiddingPubID = @"placement_id";

original_message: Updated for FAN 5.7


message: Updated for FAN SDK 5.7.1

diff:
## Facebook iOS Mediation Adapter Changelog
+#### Version 5.7.1.0
+- Verified compatibility with FAN SDK 5.7.1.
+
#### Version 5.7.0.0
- Verified compatibility with FAN SDK 5.7.0.

diff:
// limitations under the License.
/// Facebook mediation network adapter version.
-static NSString *const kGADMAdapterFacebookVersion = @"5.7.0.0";
+static NSString *const kGADMAdapterFacebookVersion = @"5.7.1.0";
static NSString *const kGADMAdapterFacebookOpenBiddingPubID = @"placement_id";

original_message: Updated for FAN SDK 5.7.1


message:
Address comments
Address the first round comments

diff:
}
UnitySingletonCompletion completeBlock = ^(UnityAdsError *error, NSString *message) {
- if(!error) {
- [UnityAds addDelegate:self];
- [UnityAds load:[self getPlacementID]];
- } else {
+ if(error) {
if (strongConnector) {
NSError *errorWithDescription = GADUnityErrorWithDescription(message);
[strongConnector adapter:self didFailAd:errorWithDescription];
}
+ return;
}
+ [UnityAds addDelegate:self];
+ [UnityAds load:[self getPlacementID]];
};
[[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:_gameID

diff:
NSString *gameID = [strongConnector.credentials[kGADMAdapterUnityGameID] copy];
UnitySingletonCompletion completeBlock = ^(UnityAdsError *error, NSString *message) {
- if(!error) {
- [UnityAds addDelegate:self];
- [UnityAds load:gameID];
- } else {
+ if(error) {
if (strongConnector && strongAdapter) {
[strongConnector adapter:strongAdapter didFailAd:GADUnityErrorWithDescription(message)];
}
+ return;
}
};

diff:
GADMAdapterUnityRewardedAd *__weak weakSelf = self;
UnitySingletonCompletion completeBlock = ^(UnityAdsError *error, NSString *message) {
- if(!error) {
- [UnityAds addDelegate:self];
- [UnityAds load:[self getPlacementID]];
- } else {
+ if(error) {
NSError *errorWithDescription = GADUnityErrorWithDescription(message);
if(weakSelf) {
weakSelf.adLoadCompletionHandler(nil, errorWithDescription);
}
+ return;
}
+ [UnityAds addDelegate:self];
+ [UnityAds load:[self getPlacementID]];
};
[[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:_gameID
- (void)unityAdsPlacementStateChanged:(nonnull NSString *)placementID
oldState:(UnityAdsPlacementState)oldState
newState:(UnityAdsPlacementState)newState {
- // This callback is not forwarded to the adapter by the GADMAdapterUnitySingleton and the adapter
- // should use the unityAdsReady: and unityAdsDidError: callbacks to forward Unity Ads SDK state to
- // Google Mobile Ads SDK.
- //id<GADMediationRewardedAdEventDelegate> strongDelegate = _adEventDelegate;
if (_adLoadCompletionHandler && [placementID isEqualToString:_placementID]) {
if (newState == kUnityAdsPlacementStateNoFill) {
NSError *errorWithDescription = GADUnityErrorWithDescription(@"NO_FILL");

diff:
- (void)initializeWithGameID:(NSString *)gameID
completeBlock:(UnitySingletonCompletion)completeBlock{
if ([UnityAds isInitialized]) {
- completeBlock(NULL, @"UnityAds Initialization Succeeded");
+ completeBlock(nil, @"UnityAds Initialization Succeeded");
return;
}
- [self setCompleteBlock:completeBlock];
+ self.completeBlock = completeBlock;
UADSMediationMetaData *mediationMetaData = [[UADSMediationMetaData alloc] init];
[mediationMetaData setName:kGADMAdapterUnityMediationNetworkName];
- (void)unityAdsPlacementStateChanged:(NSString *)placementId
oldState:(UnityAdsPlacementState)oldState
newState:(UnityAdsPlacementState)newState {
- if (newState == kUnityAdsPlacementStateWaiting || newState == kUnityAdsPlacementStateReady) {
- if (self.completeBlock) {
- self.completeBlock(NULL, @"UnityAds Initialization Succeeded");
+ if ((newState == kUnityAdsPlacementStateWaiting || newState == kUnityAdsPlacementStateReady) && self.completeBlock) {
+ self.completeBlock(nil, @"UnityAds Initialization Succeeded");
self.completeBlock = nil;
}
}
- return;
-}
- (void)unityAdsDidError:(UnityAdsError)error withMessage:(NSString *)message {
if (error == kUnityAdsErrorNotInitialized || error == kUnityAdsErrorInvalidArgument || error == kUnityAdsErrorInitializedFailed || error == kUnityAdsErrorInitSanityCheckFail) {

diff:
}
UnitySingletonCompletion completeBlock = ^(UnityAdsError *error, NSString *message) {
- if(!error && completionHandler) {
- completionHandler(nil);
- } else {
+ if (error) {
completionHandler(GADUnityErrorWithDescription(message));
+ return;
}
+ completionHandler(nil);
};
[[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:gameID


message:
Address the comments about property
Address the comments about property

diff:
/// Unity Ads Banner wrapper
GADMAdapterUnityBannerAd *_bannerAd;
+
+ NSString *_uuid;
+
+ UADSMetaData *_metaData;
}
@end
self = [super init];
if (self) {
_networkConnector = connector;
+ _uuid = [[NSUUID UUID] UUIDString];
+
+ _metaData = [[UADSMetaData alloc] init];
+
+ [_metaData setCategory:@"mediation_adapter"];
+ [_metaData setValue:@"create-adapter" forKey:_uuid];
+ [_metaData commit];
}
return self;
}
[[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:_gameID
completeBlock:completeBlock];
+
+ [_metaData setCategory:@"mediation_adapter"];
+ [_metaData setValue:@"load-interstitial" forKey:_uuid];
+ [_metaData setValue:_placementID forKey:_uuid];
+ [_metaData commit];
}
- (void)presentInterstitialFromRootViewController:(UIViewController *)rootViewController {
[UnityAds show:rootViewController placementId:_placementID];
+
+ [_metaData setCategory:@"mediation_adapter"];
+ [_metaData setValue:@"show-interstitial" forKey:_uuid];
+ [_metaData setValue:_placementID forKey:_uuid];
+ [_metaData commit];
}
#pragma mark Banner Methods

diff:
#import "GADUnityError.h"
@interface GADMAdapterUnityRewardedAd () <GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate> {
+ // The completion handler to call when the ad loading succeeds or fails.
+ GADMediationRewardedLoadCompletionHandler _adLoadCompletionHandler;
// Ad configuration for the ad to be rendered.
GADMediationAdConfiguration *_adConfiguration;
/// YES if the adapter is loading.
BOOL _isLoading;
+
+ NSString *_uuid;
+
+ UADSMetaData *_metaData;
}
-// The completion handler to call when the ad loading succeeds or fails.
-@property (nonatomic, copy)GADMediationRewardedLoadCompletionHandler adLoadCompletionHandler;
+
@end
@implementation GADMAdapterUnityRewardedAd
if (self) {
_adLoadCompletionHandler = completionHandler;
_adConfiguration = adConfiguration;
+
+ _uuid = [[NSUUID UUID] UUIDString];
+
+ _metaData = [[UADSMetaData alloc] init];
+
+ [_metaData setCategory:@"mediation_adapter"];
+ [_metaData setValue:@"create-adapter" forKey:_uuid];
+ [_metaData commit];
}
return self;
}
return;
}
GADMAdapterUnityRewardedAd *__weak weakSelf = self;
-
UnitySingletonCompletion completeBlock = ^(UnityAdsError *error, NSString *message) {
+ GADMAdapterUnityRewardedAd *strongSelf = weakSelf;
+ if (!strongSelf) {
+ return;
+ }
+
if (error) {
NSError *errorWithDescription = GADUnityErrorWithDescription(message);
- if(weakSelf) {
- weakSelf.adLoadCompletionHandler(nil, errorWithDescription);
- }
+ strongSelf->_adLoadCompletionHandler(nil, errorWithDescription);
return;
}
- [UnityAds addDelegate:self];
- [UnityAds load:[self getPlacementID]];
+ [UnityAds addDelegate:strongSelf];
+ [UnityAds load:[strongSelf getPlacementID]];
};
[[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:_gameID
completeBlock:completeBlock];
+ [_metaData setCategory:@"mediation_adapter"];
+ [_metaData setValue:@"load-rewarded" forKey:_uuid];
+ [_metaData setValue:_placementID forKey:_uuid];
+ [_metaData commit];
}
- (void)presentFromViewController:(nonnull UIViewController *)viewController {
[UnityAds show:viewController placementId:_placementID];
+
+ [_metaData setCategory:@"mediation_adapter"];
+ [_metaData setValue:@"show-rewarded" forKey:_uuid];
+ [_metaData setValue:_placementID forKey:_uuid];
+ [_metaData commit];
}
#pragma mark GADMAdapterUnityDataProvider Methods


message:
remove metadata
remove metadata

diff:
/// Unity Ads Banner wrapper
GADMAdapterUnityBannerAd *_bannerAd;
- NSString *_uuid;
-
- UADSMetaData *_metaData;
}
@end
self = [super init];
if (self) {
_networkConnector = connector;
- _uuid = [[NSUUID UUID] UUIDString];
-
- _metaData = [[UADSMetaData alloc] init];
-
- [_metaData setCategory:@"mediation_adapter"];
- [_metaData setValue:@"create-adapter" forKey:_uuid];
- [_metaData commit];
}
return self;
}
[[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:_gameID
completeBlock:completeBlock];
-
- [_metaData setCategory:@"mediation_adapter"];
- [_metaData setValue:@"load-interstitial" forKey:_uuid];
- [_metaData setValue:_placementID forKey:_uuid];
- [_metaData commit];
}
- (void)presentInterstitialFromRootViewController:(UIViewController *)rootViewController {
[UnityAds show:rootViewController placementId:_placementID];
-
- [_metaData setCategory:@"mediation_adapter"];
- [_metaData setValue:@"show-interstitial" forKey:_uuid];
- [_metaData setValue:_placementID forKey:_uuid];
- [_metaData commit];
}
#pragma mark Banner Methods

diff:
/// YES if the adapter is loading.
BOOL _isLoading;
-
- NSString *_uuid;
-
- UADSMetaData *_metaData;
}
if (self) {
_adLoadCompletionHandler = completionHandler;
_adConfiguration = adConfiguration;
-
- _uuid = [[NSUUID UUID] UUIDString];
-
- _metaData = [[UADSMetaData alloc] init];
-
- [_metaData setCategory:@"mediation_adapter"];
- [_metaData setValue:@"create-adapter" forKey:_uuid];
- [_metaData commit];
}
return self;
}
[[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:_gameID
completeBlock:completeBlock];
- [_metaData setCategory:@"mediation_adapter"];
- [_metaData setValue:@"load-rewarded" forKey:_uuid];
- [_metaData setValue:_placementID forKey:_uuid];
- [_metaData commit];
}
- (void)presentFromViewController:(nonnull UIViewController *)viewController {
[UnityAds show:viewController placementId:_placementID];
-
- [_metaData setCategory:@"mediation_adapter"];
- [_metaData setValue:@"show-rewarded" forKey:_uuid];
- [_metaData setValue:_placementID forKey:_uuid];
- [_metaData commit];
}
#pragma mark GADMAdapterUnityDataProvider Methods

original_message:
remove metadata

remove metadata


message: Added `VungleRouterConfiguration` class back in

change_type: ADD

diff:
+// Copyright 2019 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface VungleRouterConfiguration : NSObject
++ (void)setPublishIDFV:(BOOL)publish;
++ (void)setMinSpaceForInit:(int)size;
++ (void)setMinSpaceForAdLoad:(int)size;
+@end
+
+NS_ASSUME_NONNULL_END


diff:
@@ -226,7 +226,7 @@ const CGSize kVNGBannerShortSize = {300, 50};
}
} else {
if (![sdk loadPlacementWithID:placement withSize:[self getVungleBannerAdSizeType:adType] error:&loadError]) {
- if (loadError) {
+ if ((loadError) && (loadError.code != VungleSDKResetPlacementForDifferentAdSize)) {
return loadError;
}
}

original_message:
Stop returning error in case of requesting different banner size

IOS-2787


message:
Add placementInUse to manange requested placementId
Add placementInUse to manange requested placementId

diff:
if (_bannerAd != nil) {
[_bannerAd stopBeingDelegate];
}
+ [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:[self getPlacementID]];
[UnityAds removeDelegate:self];
}
NSError *error = GADUnityErrorWithDescription(@"Game ID and Placement ID cannot be nil.");
[strongConnector adapter:self didFailAd:error];
return;
+ } else if ([[GADMAdapterUnitySingleton sharedInstance].placementsInUse containsObject:_placementID]) {
+ NSString *errorMsg = @"An ad is already loading for placement ID: ";
+ errorMsg = [errorMsg stringByAppendingString:_placementID];
+ NSError *error = GADUnityErrorWithDescription(errorMsg);
+ [strongConnector adapter:self didFailAd:error];
+ return;
}
UnitySingletonCompletion completeBlock = ^(UnityAdsError *error, NSString *message) {
NSError *errorWithDescription = GADUnityErrorWithDescription(message);
[strongConnector adapter:self didFailAd:errorWithDescription];
}
+ [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:[self getPlacementID]];
return;
}
+
+ [[GADMAdapterUnitySingleton sharedInstance].placementsInUse addObject:[self getPlacementID]];
[UnityAds addDelegate:self];
[UnityAds load:[self getPlacementID]];
};
}
- (void)presentInterstitialFromRootViewController:(UIViewController *)rootViewController {
+ [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:_placementID];
[UnityAds show:rootViewController placementId:_placementID];
}
- (void)unityAdsPlacementStateChanged:(NSString *)placementID
oldState:(UnityAdsPlacementState)oldState
newState:(UnityAdsPlacementState)newState {
+ if([placementID isEqualToString:_placementID]) {
+ if (newState == kUnityAdsPlacementStateNoFill || newState == kUnityAdsPlacementStateDisabled) {
id<GADMAdNetworkConnector> strongNetworkConnector = _networkConnector;
- if (strongNetworkConnector && [placementID isEqualToString:_placementID]) {
- if (newState == kUnityAdsPlacementStateNoFill){
- NSError *errorWithDescription = GADUnityErrorWithDescription(@"NO_FILL");
- [strongNetworkConnector adapter:self didFailAd:errorWithDescription];
- } else if (newState == kUnityAdsPlacementStateDisabled) {
- NSError *errorWithDescription = GADUnityErrorWithDescription(@"PlACEMENT_DISABLED");
- [strongNetworkConnector adapter:self didFailAd:errorWithDescription];
- } else if (newState == kUnityAdsPlacementStateNotAvailable) {
- NSError *errorWithDescription = GADUnityErrorWithDescription(@"PlACEMENT_NOTAVAILABLE");
+ if (strongNetworkConnector) {
+ NSString *errorMsg = @"Failed to load: ";
+ errorMsg = [errorMsg stringByAppendingString:placementID];
+ NSError *errorWithDescription = GADUnityErrorWithDescription(errorMsg);
[strongNetworkConnector adapter:self didFailAd:errorWithDescription];
}
+ [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:placementID];
+ }
}
}
- (void)unityAdsDidFinish:(NSString *)placementID withFinishState:(UnityAdsFinishState)state {
+ if ([placementID isEqualToString:_placementID]) {
id<GADMAdNetworkConnector> strongNetworkConnector = _networkConnector;
- if (strongNetworkConnector && [placementID isEqualToString:_placementID]) {
+ if (strongNetworkConnector) {
if (state == kUnityAdsFinishStateCompleted) {
[strongNetworkConnector adapterDidDismissInterstitial:self];
} else if (state == kUnityAdsFinishStateError) {
} else if (state == kUnityAdsFinishStateSkipped) {
[strongNetworkConnector adapterDidDismissInterstitial:self];
}
+ }
+ [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:placementID];
[UnityAds removeDelegate:self];
}
}

diff:
_adLoadCompletionHandler = nil;
}
return;
+ } else if ([[GADMAdapterUnitySingleton sharedInstance].placementsInUse containsObject:_placementID]) {
+ if (_adLoadCompletionHandler) {
+ NSString *errorMsg = @"An ad is already loading for placement ID: ";
+ errorMsg = [errorMsg stringByAppendingString:_placementID];
+ NSError *error = GADUnityErrorWithDescription(errorMsg);
+ _adLoadCompletionHandler(nil, error);
+ _adLoadCompletionHandler = nil;
+ }
+ return;
}
if (![UnityAds isSupported]) {
UnitySingletonCompletion completeBlock = ^(UnityAdsError *error, NSString *message) {
GADMAdapterUnityRewardedAd *strongSelf = weakSelf;
if (!strongSelf) {
+ [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:[self getPlacementID]];
return;
}
if (error) {
NSError *errorWithDescription = GADUnityErrorWithDescription(message);
strongSelf->_adLoadCompletionHandler(nil, errorWithDescription);
+ [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:[self getPlacementID]];
return;
}
+
+ [[GADMAdapterUnitySingleton sharedInstance].placementsInUse addObject:[self getPlacementID]];
[UnityAds addDelegate:strongSelf];
[UnityAds load:[strongSelf getPlacementID]];
};
}
- (void)presentFromViewController:(nonnull UIViewController *)viewController {
+ [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:_placementID];
[UnityAds show:viewController placementId:_placementID];
+ id<GADMediationRewardedAdEventDelegate> strongDelegate = _adEventDelegate;
+ if (strongDelegate) {
+ [strongDelegate willPresentFullScreenView];
+ }
}
#pragma mark GADMAdapterUnityDataProvider Methods
#pragma mark - Unity Delegate Methods
- (void)unityAdsDidError:(UnityAdsError)error withMessage:(nonnull NSString *)message {
+ //do nothing.
}
- (void)unityAdsDidFinish:(nonnull NSString *)placementID
withFinishState:(UnityAdsFinishState)state {
+ if ([placementID isEqualToString:_placementID]) {
id<GADMediationRewardedAdEventDelegate> strongDelegate = _adEventDelegate;
- if (strongDelegate && [placementID isEqualToString:_placementID]) {
+ if (strongDelegate) {
if (state == kUnityAdsFinishStateCompleted) {
[strongDelegate didEndVideo];
// Unity Ads doesn't provide a way to set the reward on their front-end. Default to a reward
rewardAmount:[NSDecimalNumber one]];
[strongDelegate didRewardUserWithReward:reward];
} else if (state == kUnityAdsFinishStateError) {
- [strongDelegate willPresentFullScreenView];
NSError *presentError = GADUnityErrorWithDescription(@"Finish State Error");
[strongDelegate didFailToPresentWithError:presentError];
}
[strongDelegate didDismissFullScreenView];
+ }
+ [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:placementID];
[UnityAds removeDelegate:self];
}
}
- (void)unityAdsDidStart:(nonnull NSString *)placementID {
id<GADMediationRewardedAdEventDelegate> strongDelegate = _adEventDelegate;
if (strongDelegate && [placementID isEqualToString:_placementID]) {
- [strongDelegate willPresentFullScreenView];
[strongDelegate didStartVideo];
}
}
- (void)unityAdsPlacementStateChanged:(nonnull NSString *)placementID
oldState:(UnityAdsPlacementState)oldState
newState:(UnityAdsPlacementState)newState {
- if (_adLoadCompletionHandler && [placementID isEqualToString:_placementID]) {
- if (newState == kUnityAdsPlacementStateNoFill) {
- NSError *errorWithDescription = GADUnityErrorWithDescription(@"NO_FILL");
- _adLoadCompletionHandler(nil, errorWithDescription);
- } else if (newState == kUnityAdsPlacementStateNotAvailable) {
- NSError *errorWithDescription = GADUnityErrorWithDescription(@"PlACEMENT_NOTAVAILABLE");
- _adLoadCompletionHandler(nil, errorWithDescription);
- } else if (newState == kUnityAdsPlacementStateDisabled) {
- NSError *errorWithDescription = GADUnityErrorWithDescription(@"PlACEMENT_DISABLED");
+ if ([placementID isEqualToString:_placementID]) {
+ if (newState == kUnityAdsPlacementStateNoFill || newState == kUnityAdsPlacementStateDisabled) {
+ if (_adLoadCompletionHandler) {
+ NSString *errorMsg = @"Failed to load: ";
+ errorMsg = [errorMsg stringByAppendingString:placementID];
+ NSError *errorWithDescription = GADUnityErrorWithDescription(errorMsg);
_adLoadCompletionHandler(nil, errorWithDescription);
}
+ [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:placementID];
+ }
}
}

diff:
@@ -23,6 +23,7 @@ typedef void (^UnitySingletonCompletion)(UnityAdsError *error, NSString *message
@interface GADMAdapterUnitySingleton : NSObject
@property (nonatomic, strong) UnitySingletonCompletion completeBlock;
+@property NSMutableSet<NSString*>* placementsInUse;
/// Shared instance.
+ (instancetype)sharedInstance;

diff:
- (id)init {
self = [super init];
+ if (self) {
+ self.placementsInUse = [[NSMutableSet alloc] init];
+ }
return self;
}


message:
Refactoring
Code refactoring to address comments

diff:
if (_bannerAd != nil) {
[_bannerAd stopBeingDelegate];
}
- [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:[self getPlacementID]];
- [UnityAds removeDelegate:self];
+ [[GADMAdapterUnitySingleton sharedInstance] stopTrackingDelegate:self];
}
#pragma mark Interstitial Methods
NSError *error = GADUnityErrorWithDescription(@"Game ID and Placement ID cannot be nil.");
[strongConnector adapter:self didFailAd:error];
return;
- } else if ([[GADMAdapterUnitySingleton sharedInstance].placementsInUse containsObject:_placementID]) {
- NSString *errorMsg = @"An ad is already loading for placement ID: ";
- errorMsg = [errorMsg stringByAppendingString:_placementID];
- NSError *error = GADUnityErrorWithDescription(errorMsg);
- [strongConnector adapter:self didFailAd:error];
- return;
}
- UnitySingletonCompletion completeBlock = ^(UnityAdsError *error, NSString *message) {
- if(error) {
- if (strongConnector) {
- NSError *errorWithDescription = GADUnityErrorWithDescription(message);
- [strongConnector adapter:self didFailAd:errorWithDescription];
- }
- [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:[self getPlacementID]];
- return;
- }
-
- [[GADMAdapterUnitySingleton sharedInstance].placementsInUse addObject:[self getPlacementID]];
- [UnityAds addDelegate:self];
- [UnityAds load:[self getPlacementID]];
- };
-
- [[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:_gameID
- completeBlock:completeBlock];
+ [[GADMAdapterUnitySingleton sharedInstance] requestInterstitialAdWithDelegate:self];
}
- (void)presentInterstitialFromRootViewController:(UIViewController *)rootViewController {
- [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:_placementID];
- [UnityAds show:rootViewController placementId:_placementID];
+ [_networkConnector adapterWillPresentInterstitial:self];
+ [[GADMAdapterUnitySingleton sharedInstance] presentInterstitialAdForViewController:rootViewController delegate:self];
}
#pragma mark Banner Methods
NSError *errorWithDescription = GADUnityErrorWithDescription(errorMsg);
[strongNetworkConnector adapter:self didFailAd:errorWithDescription];
}
- [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:placementID];
}
}
}
if (state == kUnityAdsFinishStateCompleted) {
[strongNetworkConnector adapterDidDismissInterstitial:self];
} else if (state == kUnityAdsFinishStateError) {
- [strongNetworkConnector adapterWillPresentInterstitial:self];
[strongNetworkConnector adapterDidDismissInterstitial:self];
} else if (state == kUnityAdsFinishStateSkipped) {
[strongNetworkConnector adapterDidDismissInterstitial:self];
}
}
- [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:placementID];
- [UnityAds removeDelegate:self];
}
}
}
- (void)unityAdsDidError:(UnityAdsError)error withMessage:(NSString *)message {
- //do nothing.
+ id<GADMAdNetworkConnector> strongNetworkConnector = _networkConnector;
+ if (strongNetworkConnector) {
+ if (error == kUnityAdsErrorNotInitialized) {
+ NSError *errorWithDescription = GADUnityErrorWithDescription(message);
+ [strongNetworkConnector adapter:self didFailAd:errorWithDescription];
+ } else {
+ [strongNetworkConnector adapterWillDismissInterstitial:self];
+ [strongNetworkConnector adapterDidDismissInterstitial:self];
+ }
+ }
}
- (void)unityAdsDidStart:(nonnull NSString *)placementID {
- id<GADMAdNetworkConnector> strongNetworkConnector = _networkConnector;
- if (strongNetworkConnector && [placementID isEqualToString:_placementID]) {
- [strongNetworkConnector adapterWillPresentInterstitial:self];
- }
+ //nothing to do
}
@end

diff:
if (![UnityAds isInitialized]) {
NSString *gameID = [strongConnector.credentials[kGADMAdapterUnityGameID] copy];
-
- UnitySingletonCompletion completeBlock = ^(UnityAdsError *error, NSString *message) {
- if(error) {
- if (strongConnector && strongAdapter) {
- [strongConnector adapter:strongAdapter didFailAd:GADUnityErrorWithDescription(message)];
- }
- return;
- }
- };
-
- [[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:gameID
- completeBlock:completeBlock];
+ [[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:gameID];
}
_placementID = [strongConnector.credentials[kGADMAdapterUnityPlacementID] copy];

diff:
_placementID = [_adConfiguration.credentials.settings objectForKey:kGADMAdapterUnityPlacementID];
NSLog(@"Requesting unity rewarded ad with placement: %@", _placementID);
+ GADMAdapterUnityRewardedAd __weak *weakSelf = self;
+
if (!_gameID || !_placementID) {
if (_adLoadCompletionHandler) {
NSError *error = GADUnityErrorWithDescription(@"Game ID and Placement ID cannot be nil.");
_adLoadCompletionHandler = nil;
}
return;
- } else if ([[GADMAdapterUnitySingleton sharedInstance].placementsInUse containsObject:_placementID]) {
- if (_adLoadCompletionHandler) {
- NSString *errorMsg = @"An ad is already loading for placement ID: ";
- errorMsg = [errorMsg stringByAppendingString:_placementID];
- NSError *error = GADUnityErrorWithDescription(errorMsg);
- _adLoadCompletionHandler(nil, error);
- _adLoadCompletionHandler = nil;
- }
- return;
}
if (![UnityAds isSupported]) {
}
return;
}
- GADMAdapterUnityRewardedAd *__weak weakSelf = self;
- UnitySingletonCompletion completeBlock = ^(UnityAdsError *error, NSString *message) {
- GADMAdapterUnityRewardedAd *strongSelf = weakSelf;
- if (!strongSelf) {
- [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:[self getPlacementID]];
- return;
- }
- if (error) {
- NSError *errorWithDescription = GADUnityErrorWithDescription(message);
- strongSelf->_adLoadCompletionHandler(nil, errorWithDescription);
- [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:[self getPlacementID]];
- return;
- }
-
- [[GADMAdapterUnitySingleton sharedInstance].placementsInUse addObject:[self getPlacementID]];
- [UnityAds addDelegate:strongSelf];
- [UnityAds load:[strongSelf getPlacementID]];
- };
-
- [[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:_gameID
- completeBlock:completeBlock];
+ [[GADMAdapterUnitySingleton sharedInstance] requestRewardedAdWithDelegate:weakSelf];
}
- (void)presentFromViewController:(nonnull UIViewController *)viewController {
- [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:_placementID];
- [UnityAds show:viewController placementId:_placementID];
id<GADMediationRewardedAdEventDelegate> strongDelegate = _adEventDelegate;
if (strongDelegate) {
[strongDelegate willPresentFullScreenView];
}
+ [[GADMAdapterUnitySingleton sharedInstance] presentRewardedAdForViewController:viewController delegate:self];
}
#pragma mark GADMAdapterUnityDataProvider Methods
#pragma mark - Unity Delegate Methods
- (void)unityAdsDidError:(UnityAdsError)error withMessage:(nonnull NSString *)message {
- //do nothing.
+ if (error == kUnityAdsErrorNotInitialized) {
+ if (_adLoadCompletionHandler) {
+ NSError *errorWithDescription = GADUnityErrorWithDescription(message);
+ _adLoadCompletionHandler(nil, errorWithDescription);
+ _adLoadCompletionHandler = nil;
+ }
+ } else {
+ if (_adEventDelegate) {
+ NSError *errorWithDescription = GADUnityErrorWithDescription(message);
+ [_adEventDelegate didFailToPresentWithError:errorWithDescription];
+ }
+ }
}
- (void)unityAdsDidFinish:(nonnull NSString *)placementID
NSError *presentError = GADUnityErrorWithDescription(@"Finish State Error");
[strongDelegate didFailToPresentWithError:presentError];
}
+ [strongDelegate willDismissFullScreenView];
[strongDelegate didDismissFullScreenView];
}
- [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:placementID];
- [UnityAds removeDelegate:self];
}
}
NSError *errorWithDescription = GADUnityErrorWithDescription(errorMsg);
_adLoadCompletionHandler(nil, errorWithDescription);
}
- [[GADMAdapterUnitySingleton sharedInstance].placementsInUse removeObject:placementID];
}
}
}

diff:
#import "GADMAdapterUnityProtocol.h"
-typedef void (^UnitySingletonCompletion)(UnityAdsError *error, NSString *message);
-
@interface GADMAdapterUnitySingleton : NSObject
-@property (nonatomic, strong) UnitySingletonCompletion completeBlock;
-@property NSMutableSet<NSString*>* placementsInUse;
-
/// Shared instance.
+ (instancetype)sharedInstance;
/// Configures a reward-based video ad with provided |gameID| and |adapterDelegate| and returns
/// YES if successful; otherwise returns NO.
-- (void)initializeWithGameID:(NSString *)gameID
- completeBlock:(UnitySingletonCompletion)completeBlock;
+- (void)initializeWithGameID:(NSString *)gameID;
+
+/// Requests a reward-based video ad with |adapterDelegate|.
+- (void)requestRewardedAdWithDelegate:
+(id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)adapterDelegate;
+
+/// Presents a reward-based video ad for |viewController| with |adapterDelegate|.
+- (void)presentRewardedAdForViewController:(UIViewController *)viewController
+ delegate:
+(id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)
+adapterDelegate;
+
+/// Configures an interstitial ad with provided |gameID| and |adapterDelegate|.
+- (void)requestInterstitialAdWithDelegate:
+(id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)adapterDelegate;
+
+/// Presents an interstitial ad for |viewController| with |adapterDelegate|.
+- (void)presentInterstitialAdForViewController:(UIViewController *)viewController
+ delegate:(id<GADMAdapterUnityDataProvider,
+ UnityAdsExtendedDelegate>)adapterDelegate;
+
+/// Tells the adapter to remove itself as a |adapterDelegate|.
+- (void)stopTrackingDelegate:
+(id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)adapterDelegate;
@end

diff:
#import "GADMAdapterUnityConstants.h"
#import "GADMAdapterUnityUtils.h"
-@interface GADMAdapterUnitySingleton () <UnityAdsExtendedDelegate>
+@interface GADMAdapterUnitySingleton () <UnityAdsExtendedDelegate> {
+ /// Array to hold all adapter delegates.
+ NSMapTable *_adapterDelegates;
+
+ /// Connector from unity adapter to send Unity callbacks.
+ __weak id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate> _currentShowingUnityDelegate;
+}
@end
- (id)init {
self = [super init];
if (self) {
- self.placementsInUse = [[NSMutableSet alloc] init];
+ _adapterDelegates = [NSMapTable mapTableWithKeyOptions:NSMapTableStrongMemory
+ valueOptions:NSMapTableWeakMemory];
}
return self;
}
-- (void)initializeWithGameID:(NSString *)gameID
- completeBlock:(UnitySingletonCompletion)completeBlock{
+- (void)initializeWithGameID:(NSString *)gameID {
if ([UnityAds isInitialized]) {
- completeBlock(nil, @"UnityAds Initialization Succeeded");
return;
}
- self.completeBlock = completeBlock;
-
+ // Metadata needed by Unity Ads SDK before initialization.
UADSMediationMetaData *mediationMetaData = [[UADSMediationMetaData alloc] init];
[mediationMetaData setName:kGADMAdapterUnityMediationNetworkName];
[mediationMetaData setVersion:kGADMAdapterUnityVersion];
[mediationMetaData set:@"adapter_version" value:[UnityAds getVersion]];
[mediationMetaData commit];
+ // Initializing Unity Ads with |gameID|.
[UnityAds addDelegate:self];
- [UnityAds initialize:gameID testMode:false enablePerPlacementLoad:true];
+ [UnityAds initialize:gameID testMode:NO enablePerPlacementLoad:YES];
+}
+
+- (void)addAdapterDelegate:
+ (id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)adapterDelegate {
+ @synchronized(_adapterDelegates) {
+ [_adapterDelegates setObject:adapterDelegate forKey:[adapterDelegate getPlacementID]];
+ }
+}
+
+#pragma mark - Rewardbased video ad methods
+
+- (void)requestRewardedAdWithDelegate:
+ (id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)adapterDelegate {
+ NSString *gameID = [adapterDelegate getGameID];
+ NSString *placementID = [adapterDelegate getPlacementID];
+
+ @synchronized(_adapterDelegates) {
+ if ([_adapterDelegates objectForKey:placementID]) {
+ NSString *message = @"An ad is already loading for placement ID %@";
+ [adapterDelegate unityAdsDidError:kUnityAdsErrorInternalError
+ withMessage:[NSString stringWithFormat:message, placementID]];
+ return;
+ }
+ }
+
+ [self addAdapterDelegate:adapterDelegate];
+
+ if (![UnityAds isInitialized]) {
+ [self initializeWithGameID:gameID];
+ }
+
+ [UnityAds load:placementID];
+}
+
+- (void)presentRewardedAdForViewController:(UIViewController *)viewController
+ delegate:
+ (id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)
+ adapterDelegate {
+ _currentShowingUnityDelegate = adapterDelegate;
+
+ NSString *placementID = [adapterDelegate getPlacementID];
+ [UnityAds show:viewController placementId:placementID];
+}
+
+#pragma mark - Interstitial ad methods
+
+- (void)requestInterstitialAdWithDelegate:
+ (id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)adapterDelegate {
+ NSString *gameID = [adapterDelegate getGameID];
+ NSString *placementID = [adapterDelegate getPlacementID];
+
+ @synchronized(_adapterDelegates) {
+ if ([_adapterDelegates objectForKey:placementID]) {
+ NSString *message = @"An ad is already loading for placement ID %@";
+ [adapterDelegate unityAdsDidError:kUnityAdsErrorInternalError
+ withMessage:[NSString stringWithFormat:message, placementID]];
+ return;
+ }
+ }
+
+ [self addAdapterDelegate:adapterDelegate];
+ if (![UnityAds isInitialized]) {
+ [self initializeWithGameID:gameID];
+ }
+
+ [UnityAds load:placementID];
+}
+
+- (void)presentInterstitialAdForViewController:(UIViewController *)viewController
+ delegate:(id<GADMAdapterUnityDataProvider,
+ UnityAdsExtendedDelegate>)adapterDelegate {
+ _currentShowingUnityDelegate = adapterDelegate;
+
+ NSString *placementID = [adapterDelegate getPlacementID];
+ [UnityAds show:viewController placementId:placementID];
}
#pragma mark - Unity Delegate Methods
- (void)unityAdsPlacementStateChanged:(NSString *)placementId
oldState:(UnityAdsPlacementState)oldState
newState:(UnityAdsPlacementState)newState {
- if ((newState == kUnityAdsPlacementStateWaiting || newState == kUnityAdsPlacementStateReady) && self.completeBlock) {
- self.completeBlock(nil, @"UnityAds Initialization Succeeded");
- self.completeBlock = nil;
- }
+ id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate> adapterDelegate;
+ @synchronized(_adapterDelegates) {
+ adapterDelegate = [_adapterDelegates objectForKey:placementId];
}
-- (void)unityAdsDidError:(UnityAdsError)error withMessage:(NSString *)message {
- if (error == kUnityAdsErrorNotInitialized || error == kUnityAdsErrorInvalidArgument || error == kUnityAdsErrorInitializedFailed || error == kUnityAdsErrorInitSanityCheckFail) {
- if (self.completeBlock) {
- self.completeBlock(&error, @"Unity Ads Initialization Failed");
- self.completeBlock = nil;
- }
+ if (adapterDelegate) {
+ [adapterDelegate unityAdsPlacementStateChanged:placementId oldState:oldState newState:newState];
}
- return;
}
- (void)unityAdsDidFinish:(NSString *)placementID withFinishState:(UnityAdsFinishState)state {
+ @synchronized(_adapterDelegates) {
+ GADMAdapterUnityMapTableRemoveObjectForKey(_adapterDelegates, placementID);
+ }
+ [_currentShowingUnityDelegate unityAdsDidFinish:placementID withFinishState:state];
}
- (void)unityAdsDidStart:(NSString *)placementID {
+ [_currentShowingUnityDelegate unityAdsDidStart:placementID];
}
- (void)unityAdsReady:(NSString *)placementID {
+ id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate> adapterDelegate;
+ @synchronized(_adapterDelegates) {
+ adapterDelegate = [_adapterDelegates objectForKey:placementID];
+ }
+
+ if (adapterDelegate) {
+ [adapterDelegate unityAdsReady:placementID];
+ }
}
- (void)unityAdsDidClick:(NSString *)placementID {
+ [_currentShowingUnityDelegate unityAdsDidClick:placementID];
+}
+
+- (void)unityAdsDidError:(UnityAdsError)error withMessage:(NSString *)message {
+ if (error == kUnityAdsErrorInitSanityCheckFail || error == kUnityAdsErrorNotInitialized || error == kUnityAdsErrorInvalidArgument ||
+ error == kUnityAdsErrorInitializedFailed || error == kUnityAdsErrorAdBlockerDetected) {
+ NSArray *delegates;
+ @synchronized(_adapterDelegates) {
+ delegates = _adapterDelegates.objectEnumerator.allObjects;
+ }
+
+ for (id<UnityAdsExtendedDelegate, UnityAdsExtendedDelegate> delegate in delegates) {
+ [delegate unityAdsDidError:kUnityAdsErrorNotInitialized withMessage:message];
+ }
+
+ @synchronized(_adapterDelegates) {
+ [_adapterDelegates removeAllObjects];
+ }
+ } else {
+ [_currentShowingUnityDelegate unityAdsDidError:error withMessage:message];
+ }
+}
+
+- (void)stopTrackingDelegate:
+ (id<GADMAdapterUnityDataProvider, UnityAdsExtendedDelegate>)adapterDelegate {
+ GADMAdapterUnityMapTableRemoveObjectForKey(_adapterDelegates, [adapterDelegate getPlacementID]);
}
@end


message:
Remove completeBlock from GADMediationAdapterUnity.m
Remove completeBlock from GADMediationAdapterUnity.m

diff:
#import "GADUnityError.h"
@import UnityAds;
-@interface GADMediationAdapterUnity () <GADMediationAdapter>
+@interface GADMediationAdapterUnity ()
@property(nonatomic, strong) GADMAdapterUnityRewardedAd *rewardedAd;
NSLog(@"Initializing Unity Ads SDK with the game ID %@.", gameID);
}
- UnitySingletonCompletion completeBlock = ^(UnityAdsError *error, NSString *message) {
- if (error) {
- completionHandler(GADUnityErrorWithDescription(message));
- return;
- }
+ [[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:gameID];
completionHandler(nil);
- };
-
- [[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:gameID
- completeBlock:completeBlock];
}
+ (GADVersionNumber)adSDKVersion {


message: Update for FAN 5.8.0

diff:
## Facebook iOS Mediation Adapter Changelog
+#### Version 5.8.0.0
+- Verified compatibility with FAN SDK 5.8.0.
+
#### Next Version
- Adapter now returns a non-zero `mediaContent` aspect ratio regardless if the media view is rendered or not.

diff:
// limitations under the License.
/// Facebook mediation network adapter version.
-static NSString *const kGADMAdapterFacebookVersion = @"5.7.1.2";
+static NSString *const kGADMAdapterFacebookVersion = @"5.8.0.0";
static NSString *const kGADMAdapterFacebookOpenBiddingPubID = @"placement_id";

original_message: Update for FAN 5.8.0


message:
Add metatdata
Add metatdata

diff:
/// Unity Ads Banner wrapper
GADMAdapterUnityBannerAd *_bannerAd;
+ NSString *_uuid;
+ UADSMetaData *_metaData;
+
}
@end
self = [super init];
if (self) {
_networkConnector = connector;
+
+ _uuid = [[NSUUID UUID] UUIDString];
+
+ _metaData = [[UADSMetaData alloc] init];
+
+ [_metaData setCategory:@"mediation_adapter"];
+ [_metaData set:_uuid value:@"create-adapter"];
+ [_metaData commit];
}
return self;
}
return;
}
+ [_metaData setCategory:@"mediation_adapter"];
+ [_metaData set:_uuid value:@"load-interstitial"];
+ [_metaData set:_uuid value:_placementID];
+ [_metaData commit];
+
[[GADMAdapterUnitySingleton sharedInstance] requestInterstitialAdWithDelegate:self];
}
- (void)presentInterstitialFromRootViewController:(UIViewController *)rootViewController {
[_networkConnector adapterWillPresentInterstitial:self];
+
+ [_metaData setCategory:@"mediation_adapter"];
+ [_metaData set:_uuid value:@"show-interstitial"];
+ [_metaData set:_uuid value:_placementID];
+ [_metaData commit];
+
[[GADMAdapterUnitySingleton sharedInstance] presentInterstitialAdForViewController:rootViewController delegate:self];
}

diff:
/// YES if the adapter is loading.
BOOL _isLoading;
+
+ NSString *_uuid;
+ UADSMetaData *_metaData;
}
@end
if (self) {
_adLoadCompletionHandler = completionHandler;
_adConfiguration = adConfiguration;
+
+ _uuid = [[NSUUID UUID] UUIDString];
+
+ _metaData = [[UADSMetaData alloc] init];
+ [_metaData setCategory:@"mediation_adapter"];
+ [_metaData set:_uuid value:@"create-adapter"];
+ [_metaData commit];
}
return self;
}
return;
}
+ [_metaData setCategory:@"mediation_adapter"];
+ [_metaData set:_uuid value:@"load-rewarded"];
+ [_metaData set:_uuid value:_placementID];
+ [_metaData commit];
[[GADMAdapterUnitySingleton sharedInstance] requestRewardedAdWithDelegate:weakSelf];
}
if (strongDelegate) {
[strongDelegate willPresentFullScreenView];
}
+
+ [_metaData setCategory:@"mediation_adapter"];
+ [_metaData set:_uuid value:@"show-rewarded"];
+ [_metaData set:_uuid value:_placementID];
+ [_metaData commit];
+
[[GADMAdapterUnitySingleton sharedInstance] presentRewardedAdForViewController:viewController delegate:self];
}

original_message:
Add metatdata

Add metatdata


message: Updated the message

diff:
## Facebook iOS Mediation Adapter Changelog
-#### Version 5.8.0.0
-- Verified compatibility with FAN SDK 5.8.0.
#### Next Version
+
+
+#### Version 5.8.0.0
+- Verified compatibility with FAN 5.8.0.
- Adapter now returns a non-zero `mediaContent` aspect ratio regardless if the media view is rendered or not.
#### Version 5.7.1.2
@@ -14,8 +16,7 @@ Built and tested with
- FAN SDK version 5.7.1.
#### Version 5.7.1.1
-- Removed support for the i386 architecture.
-
+- Removed support for the i386 architecture.s
Built and tested with
- Google Mobile Ads SDK version 7.56.0.
- FAN SDK version 5.7.1.

original_message: Updated the message


message: Updated for FAN 5.9

diff:
## Facebook iOS Mediation Adapter Changelog
+#### Version 5.9.0.0
+- Verified compatibility with FAN SDK 5.9.0.
+
+Built and tested with
+- Google Mobile Ads SDK version 7.58.0.
+- FAN SDK version 5.9.0.
+
#### Version 5.8.0.2
- Adapter now calls adapterWillPresentScreen: immediately followed by adapterDidDismissScreen: if interstitial ads fail to present.
- Fixed a bug where some banner requests failed with reason "Display format doesn't match".

diff:
// limitations under the License.
/// Facebook mediation network adapter version.
-static NSString *const kGADMAdapterFacebookVersion = @"5.8.0.2";
+static NSString *const kGADMAdapterFacebookVersion = @"5.9.0.1";
static NSString *const kGADMAdapterFacebookOpenBiddingPubID = @"placement_id";

original_message: Updated for FAN 5.9


message: Fixed the version

diff:
// limitations under the License.
/// Facebook mediation network adapter version.
-static NSString *const kGADMAdapterFacebookVersion = @"5.9.0.1";
+static NSString *const kGADMAdapterFacebookVersion = @"5.9.0.0";
static NSString *const kGADMAdapterFacebookOpenBiddingPubID = @"placement_id";

original_message: Fixed the version


message: Updated SDK init api

diff:
@@ -97,8 +97,22 @@ static NSString *const _Nonnull kGADMAdapterVungleNullPubRequestID = @"null";
// Disable refresh functionality for all banners
[[VungleSDK sharedSDK] disableBannerRefresh];
+ // Set init options for priority placement
+ NSMutableDictionary *initOptions = [NSMutableDictionary dictionary];
+ if (delegate) {
+ NSString *priorityPlacementID = delegate.desiredPlacement;
+ [initOptions setObject:priorityPlacementID forKey:VungleSDKInitOptionKeyPriorityPlacementID];
+
+ NSInteger priorityPlacementAdSize = 1;
+ GADMAdapterVungleAdType adType = [delegate adapterAdType];
+ if (adType == GADMAdapterVungleAdTypeBanner || adType == GADMAdapterVungleAdTypeShortBanner || adType == GADMAdapterVungleAdTypeLeaderboardBanner) {
+ priorityPlacementAdSize = [self getVungleBannerAdSizeType:adType];
+ }
+ [initOptions setObject:[NSNumber numberWithInteger:priorityPlacementAdSize] forKey:VungleSDKInitOptionKeyPriorityPlacementAdSize];
+ }
+
NSError *err = nil;
- [sdk startWithAppId:appId error:&err];
+ [sdk startWithAppId:appId options:initOptions error:&err];
if (err) {
[self initialized:NO error:err];
}

original_message: Updated SDK init api


message: Updated for FAN 5.10.0

diff:
## Facebook iOS Mediation Adapter Changelog
+#### Version 5.10.0.0
+- Verified compatibility with FAN SDK 5.10.0.
+- Now requires Google Mobile Ads SDK version 7.60.0 or higher.
+
+Built and tested with
+- Google Mobile Ads SDK version 7.60.0.
+- FAN SDK version 5.10.0.
+
#### Version 5.9.0.1
- Added support for rewarded interstitial ads.
- Now requires Google Mobile Ads SDK version 7.60.0 or higher.

diff:
// limitations under the License.
/// Facebook mediation network adapter version.
-static NSString *const kGADMAdapterFacebookVersion = @"5.9.0.1";
+static NSString *const kGADMAdapterFacebookVersion = @"5.10.0.0";
static NSString *const kGADMAdapterFacebookOpenBiddingPubID = @"placement_id";

original_message: Updated for FAN 5.10.0


message: Updated for FAN 5.10.1

diff:
## Facebook iOS Mediation Adapter Changelog
+#### Version 5.10.1.0
+- Verified compatibility with FAN SDK 5.10.1.
+- Now requires Google Mobile Ads SDK version 7.61.0 or higher.
+
+Built and tested with
+- Google Mobile Ads SDK version 7.61.0.
+- FAN SDK version 5.10.1.
+
#### Version 5.10.0.0
- Verified compatibility with FAN SDK 5.10.0.
- Now requires Google Mobile Ads SDK version 7.61.0 or higher.

diff:
// limitations under the License.
/// Facebook mediation network adapter version.
-static NSString *const kGADMAdapterFacebookVersion = @"5.10.0.0";
+static NSString *const kGADMAdapterFacebookVersion = @"5.10.1.0";
static NSString *const kGADMAdapterFacebookOpenBiddingPubID = @"placement_id";

original_message: Updated for FAN 5.10.1


message:
Add lazy init into load
Add lazy init into load.

diff:
/// Unity Ads banner ad object.
UADSBannerView *_bannerAd;
+ /// Unity ads game ID.
+ NSString *_gameID;
+
/// Unity ads placement ID.
NSString *_placementID;
}
id<GADMAdNetworkConnector> strongConnector = _connector;
id<GADMAdNetworkAdapter> strongAdapter = _adapter;
- if (![UnityAds isInitialized]) {
- [GADMAdapterUnity initialize];
- }
-
if (!strongConnector) {
NSLog(@"Unity Ads Adapter Error: No GADMAdNetworkConnector found.");
return;
return;
}
+ _gameID = [[[strongConnector credentials] objectForKey:kGADMAdapterUnityGameID] copy];
_placementID = [strongConnector.credentials[kGADMAdapterUnityPlacementID] copy];
- if (!_placementID) {
+ if (!_gameID || !_placementID) {
NSError *error = GADUnityErrorWithDescription(kMISSING_ID_ERROR);
[strongConnector adapter:strongAdapter didFailAd:error];
return;
}
+
+ if (![UnityAds isInitialized]) {
+ [[GADMAdapterUnity alloc] initializeWithGameID:_gameID withInitDelegate:Nil];
+ }
+
_bannerAd = [[UADSBannerView alloc] initWithPlacementId:_placementID size:adSize.size];
if (!_bannerAd) {
NSError *error = GADMAdapterUnityErrorWithCodeAndDescription(GADMAdapterUnityErrorAdObjectNil, @"Unity banner failed to initialize.");

diff:
#import <Foundation/Foundation.h>
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <UnityAds/UnityAds.h>
+#import "GADMUnityInitializer.h"
@interface GADMAdapterUnityRewardedAd
: NSObject <GADMediationRewardedAd, UnityAdsExtendedDelegate>

diff:
return;
}
+ if (![UnityAds isInitialized]) {
+ [[GADMAdapterUnity alloc] initializeWithGameID:_gameID withInitDelegate:Nil];
+ }
+
[UnityAds addDelegate:self];
[UnityAds load:_placementID loadDelegate:self];
}
newState:(UnityAdsPlacementState)newState {
}
+#pragma mark - UnityLoadDelegate Methods
+
- (void)unityAdsAdFailedToLoad:(nonnull NSString *)placementId {
[UnityAds removeDelegate:self];
if (_adLoadCompletionHandler) {

diff:
#import <Foundation/Foundation.h>
#import <GoogleMobileAds/GoogleMobileAds.h>
-#import <UnityAds/UnityAds.h>'
-
+#import <UnityAds/UnityAds.h>
#import "GADMUnityInitializer.h"
@protocol GADMAdNetworkAdapter;

diff:
id<GADMAdNetworkConnector> strongConnector = _connector;
id<GADMAdNetworkAdapter> strongAdapter = _adapter;
- if (![UnityAds isInitialized]) {
- //[GADMAdapterUnity initializeWithGameID: _gameID withInitDelegate:Nil];
- [GADMAdapterUnity initialize];
- }
-
if (!strongConnector) {
NSLog(@"Unity Ads Adapter Error: No GADMAdNetworkConnector found.");
return;
[strongConnector adapter:strongAdapter didFailAd:error];
return;
}
+
+ if (![UnityAds isInitialized]) {
+ [[GADMAdapterUnity alloc] initializeWithGameID: _gameID withInitDelegate:Nil];
+ }
+
_isLoading = YES;
[UnityAds addDelegate:self];
[UnityAds load:_placementID loadDelegate:self];
// unityAdsAdLoaded.
}
-
-// UnityAdsLoadDelegate methods
+#pragma mark - UnityAdsLoadDelegate Methods
- (void)unityAdsAdFailedToLoad:(nonnull NSString *)placementId {
[UnityAds removeDelegate:self];


message:
Clean up RewardedAd
Clean up RewardedAd

diff:
#import "GADMUnityInitializer.h"
@interface GADMAdapterUnityRewardedAd
-: NSObject <GADMediationRewardedAd, UnityAdsExtendedDelegate>
+: NSObject <GADMediationRewardedAd, UnityAdsExtendedDelegate, UnityAdsLoadDelegate>
- (instancetype)initWithAdConfiguration:(GADMediationRewardedAdConfiguration *)adConfiguration
completionHandler:(GADMediationRewardedLoadCompletionHandler)completionHandler;

diff:
#import "GADUnityError.h"
#import "GADMAdapterUnityUtils.h"
-@interface GADMAdapterUnityRewardedAd () <UnityAdsExtendedDelegate, UnityAdsLoadDelegate> {
+@interface GADMAdapterUnityRewardedAd () <GADMediationRewardedAd, UnityAdsExtendedDelegate, UnityAdsLoadDelegate> {
// The completion handler to call when the ad loading succeeds or fails.
GADMediationRewardedLoadCompletionHandler _adLoadCompletionHandler;
[UnityAds show:viewController placementId:_placementID];
}
-#pragma mark - Unity Delegate Methods
+#pragma mark - UnityAdsExtendedDelegate Methods
- (void)unityAdsDidError:(UnityAdsError)error withMessage:(nonnull NSString *)message {
[UnityAds removeDelegate:self];
newState:(UnityAdsPlacementState)newState {
}
-#pragma mark - UnityLoadDelegate Methods
+#pragma mark - UnityAdsLoadDelegate Methods
- (void)unityAdsAdFailedToLoad:(nonnull NSString *)placementId {
[UnityAds removeDelegate:self];

original_message:
Clean up RewardedAd

Clean up RewardedAd


message:
Remove duplicates from Initializer and move Banner logic to BannerAd class
Remove duplicates from Initializer and move Banner logic to BannerAd class

diff:
return;
}
+ GADAdSize supportedSize = [self supportedAdSizeFromRequestedSize:adSize];
+ if (!IsGADAdSizeValid(supportedSize)) {
+ NSString *errorMsg = [NSString
+ stringWithFormat:
+ @"UnityAds supported banner sizes are not a good fit for the requested size: %@",
+ NSStringFromGADAdSize(adSize)];
+ NSError *error =
+ GADMAdapterUnityErrorWithCodeAndDescription(GADMAdapterUnityErrorSizeMismatch, errorMsg);
+ [strongConnector adapter:strongAdapter didFailAd:error];
+ return;
+ }
+
if (![UnityAds isInitialized]) {
[[GADMAdapterUnity alloc] initializeWithGameID:_gameID withInitDelegate:Nil];
}
_bannerAd.delegate = nil;
}
+// Find closest supported ad size from a given ad size.
+- (GADAdSize)supportedAdSizeFromRequestedSize:(GADAdSize)gadAdSize {
+ NSArray *potentials =
+ @[ NSValueFromGADAdSize(kGADAdSizeBanner), NSValueFromGADAdSize(kGADAdSizeLeaderboard) ];
+ return GADClosestValidSizeForAdSizes(gadAdSize, potentials);
+}
+
#pragma mark UADSBannerView Delegate methods
- (void)bannerViewDidLoad:(UADSBannerView *)bannerView {

diff:
- (void)getInterstitial {
id<GADMAdNetworkConnector> strongConnector = _networkConnector;
- if (!strongConnector) return;
- _gameID = [[[strongConnector credentials] objectForKey:kGADMAdapterUnityGameID] copy];
+
_interstitialAd = [[GADMUnityInterstitialAd alloc] initWithGADMAdNetworkConnector:strongConnector adapter:self];
- if (!_interstitialAd) {
- NSString *description = [NSString
- stringWithFormat:@"%@ initialization failed!", NSStringFromClass([GADMUnityInterstitialAd class])];
- NSError *error = GADMAdapterUnityErrorWithCodeAndDescription(GADMAdapterUnityErrorAdInitializationFailure, description);
- [strongConnector adapter:self didFailAd:error];
- return;
- }
[_interstitialAd getInterstitial];
}
- (void)presentInterstitialFromRootViewController:(UIViewController *)rootViewController {
- id<GADMAdNetworkConnector> strongConnector = _networkConnector;
- if (strongConnector) {
- [strongConnector adapterWillPresentInterstitial:self];
- }
[_interstitialAd presentInterstitialFromRootViewController:rootViewController];
}
- (void)getBannerWithSize:(GADAdSize)adSize {
id<GADMAdNetworkConnector> strongConnector = _networkConnector;
- if (!strongConnector) {
- NSLog(@"Adapter Error: No GADMAdNetworkConnector found.");
-
- return;
- }
- GADAdSize supportedSize = [self supportedAdSizeFromRequestedSize:adSize];
- if (!IsGADAdSizeValid(supportedSize)) {
- NSString *errorMsg = [NSString
- stringWithFormat:
- @"UnityAds supported banner sizes are not a good fit for the requested size: %@",
- NSStringFromGADAdSize(adSize)];
- NSError *error =
- GADMAdapterUnityErrorWithCodeAndDescription(GADMAdapterUnityErrorSizeMismatch, errorMsg);
- [strongConnector adapter:self didFailAd:error];
- return;
- }
- _gameID = [strongConnector.credentials[kGADMAdapterUnityGameID] copy];
- _placementID = [strongConnector.credentials[kGADMAdapterUnityPlacementID] copy];
- if (!_gameID || !_placementID) {
- NSError *error = GADMAdapterUnityErrorWithCodeAndDescription( GADMAdapterUnityErrorInvalidServerParameters, kMISSING_ID_ERROR);
- [strongConnector adapter:self didFailAd:error];
- return;
- }
_bannerAd = [[GADMAdapterUnityBannerAd alloc] initWithGADMAdNetworkConnector:strongConnector
adapter:self];
-
- if (!_bannerAd) {
- NSString *description = [NSString
- stringWithFormat:@"%@ initialization failed!", NSStringFromClass([GADMAdapterUnityBannerAd class])];
- NSError *error = GADMAdapterUnityErrorWithCodeAndDescription(GADMAdapterUnityErrorAdInitializationFailure, description);
- [strongConnector adapter:self didFailAd:error];
- return;
- }
- [_bannerAd loadBannerWithSize:supportedSize];
-}
-
-/// Find closest supported ad size from a given ad size.
-- (GADAdSize)supportedAdSizeFromRequestedSize:(GADAdSize)gadAdSize {
- NSArray *potentials =
- @[ NSValueFromGADAdSize(kGADAdSizeBanner), NSValueFromGADAdSize(kGADAdSizeLeaderboard) ];
- return GADClosestValidSizeForAdSizes(gadAdSize, potentials);
+ [_bannerAd loadBannerWithSize:adSize];
}
@end


message:
Remove isLoading and use UnityExtendedDelegate for show only
Remove isLoading and use UnityExtendedDelegate for show only

diff:
[[GADMAdapterUnity alloc] initializeWithGameID: _gameID withInitDelegate:Nil];
}
- _isLoading = YES;
- [UnityAds addDelegate:self];
[UnityAds load:_placementID loadDelegate:self];
}
return;
}
- [strongConnector adapterWillPresentInterstitial:strongAdapter];
if ([UnityAds isReady:_placementID]) {
+ [UnityAds addDelegate:self];
+ [strongConnector adapterWillPresentInterstitial:strongAdapter];
[UnityAds show:rootViewController placementId:_placementID];
+ } else {
+ return;
}
}
[UnityAds removeDelegate:self];
id<GADMAdNetworkConnector> strongNetworkConnector = _connector;
id<GADMAdNetworkAdapter> strongAdapter = _adapter;
- if (!_isLoading) {
- // Unity Ads show error will only happen after the ad has been loaded. So, we will send
- // dismiss/close callbacks.
+
if (error == kUnityAdsErrorShowError) {
if (strongNetworkConnector && strongAdapter) {
[strongNetworkConnector adapterWillDismissInterstitial:strongAdapter];
[strongNetworkConnector adapterDidDismissInterstitial:strongAdapter];
}
}
- return;
- }
-
- NSError *errorWithDescription = GADUnityErrorWithDescription(message);
- if (strongNetworkConnector && strongAdapter) {
- [strongNetworkConnector adapter:strongAdapter didFailAd:errorWithDescription];
- }
- _isLoading = NO;
}
- (void)unityAdsDidStart:(nonnull NSString *)placementId {
#pragma mark - UnityAdsLoadDelegate Methods
- (void)unityAdsAdFailedToLoad:(nonnull NSString *)placementId {
- [UnityAds removeDelegate:self];
id<GADMAdNetworkConnector> strongConnector = _connector;
id<GADMAdNetworkAdapter> strongAdapter = _adapter;
if (strongConnector && strongAdapter) {
- (void)unityAdsAdLoaded:(nonnull NSString *)placementId {
id<GADMAdNetworkConnector> strongNetworkConnector = _connector;
id<GADMAdNetworkAdapter> strongAdapter = _adapter;
- if (!_isLoading) {
- return;
- }
+
if (strongNetworkConnector && strongAdapter) {
[strongNetworkConnector adapterDidReceiveInterstitial:strongAdapter];
}
- _isLoading = NO;
}
@end


message:
move import to .m
move import to .m

diff:
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <UnityAds/UnityAds.h>
-#import "GADMUnityInitializer.h"
-
@interface GADMAdapterUnityBannerAd : NSObject
/// Initializes a new instance with |connector| and |adapter|.

diff:
#import "GADMAdapterUnityUtils.h"
#import "GADMediationAdapterUnity.h"
#import "GADUnityError.h"
+#import "GADMUnityInitializer.h"
@interface GADMAdapterUnityBannerAd () <UADSBannerViewDelegate>
@end

diff:
#import <Foundation/Foundation.h>
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <UnityAds/UnityAds.h>
-#import "GADMUnityInitializer.h"
@interface GADMAdapterUnityRewardedAd
: NSObject <GADMediationRewardedAd, UnityAdsExtendedDelegate>

diff:
#import "GADMAdapterUnityConstants.h"
#import "GADUnityError.h"
#import "GADMAdapterUnityUtils.h"
+#import "GADMUnityInitializer.h"
@interface GADMAdapterUnityRewardedAd () <UnityAdsExtendedDelegate, UnityAdsLoadDelegate> {
// The completion handler to call when the ad loading succeeds or fails.

diff:
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <UnityAds/UnityAds.h>
-#import "GADMUnityInitializer.h"
@protocol GADMAdNetworkAdapter;
@protocol GADMAdNetworkConnector;

diff:
#import "GADMUnityInterstitialAd.h"
#import "GADMAdapterUnityConstants.h"
#import "GADUnityError.h"
+#import "GADMUnityInitializer.h"
@interface GADMUnityInterstitialAd ()
@end

original_message:
move import to .m

move import to .m


message:
use ExtendedDelegate as showDelegate only
use ExtendedDelegate as showDelegate only

diff:
[[GADMAdapterUnity alloc] initializeWithGameID:_gameID withInitDelegate:Nil];
}
- [UnityAds addDelegate:self];
[UnityAds load:_placementID loadDelegate:self];
}
return;
}
[_adEventDelegate willPresentFullScreenView];
+ [UnityAds addDelegate:self];
[UnityAds show:viewController placementId:_placementID];
}
#pragma mark - UnityAdsLoadDelegate Methods
- (void)unityAdsAdFailedToLoad:(nonnull NSString *)placementId {
- [UnityAds removeDelegate:self];
if (_adLoadCompletionHandler) {
NSError *error = GADUnityErrorWithDescription([NSString stringWithFormat:@"Failed to load rewarded ad with placement ID '%@'", placementId]);
_adEventDelegate = _adLoadCompletionHandler(nil, error);


message:
nit clean up
nit clean up

diff:
@interface GADMAdapterUnityBannerAd : NSObject
/// Initializes a new instance with |connector| and |adapter|.
-- (instancetype)initWithGADMAdNetworkConnector:(nonnull id<GADMAdNetworkConnector>)connector
+- (nonnull instancetype)initWithGADMAdNetworkConnector:(nonnull id<GADMAdNetworkConnector>)connector
adapter:(nonnull id<GADMAdNetworkAdapter>)adapter
NS_DESIGNATED_INITIALIZER;

diff:
NSString *_placementID;
}
-- (instancetype)initWithGADMAdNetworkConnector:(nonnull id<GADMAdNetworkConnector>)connector
+- (nonnull instancetype)initWithGADMAdNetworkConnector:(nonnull id<GADMAdNetworkConnector>)connector
adapter:(nonnull id<GADMAdNetworkAdapter>)adapter {
self = [super init];
if (self) {

diff:
@interface GADMAdapterUnityRewardedAd () <GADMediationRewardedAd, UnityAdsExtendedDelegate, UnityAdsLoadDelegate> {
// The completion handler to call when the ad loading succeeds or fails.
GADMediationRewardedLoadCompletionHandler _adLoadCompletionHandler;
-
// Ad configuration for the ad to be rendered.
GADMediationAdConfiguration *_adConfiguration;

diff:
}
- (void)loadRewardedAdForAdConfiguration:(GADMediationRewardedAdConfiguration *)adConfiguration
- completionHandler:(GADMediationRewardedLoadCompletionHandler)completionHandler {
+ completionHandler:
+ (GADMediationRewardedLoadCompletionHandler)completionHandler {
self.rewardedAd = [[GADMAdapterUnityRewardedAd alloc] initWithAdConfiguration:adConfiguration
completionHandler:completionHandler];
[self.rewardedAd requestRewardedAd];

original_message:
nit clean up

nit clean up


message:
create NSError via GADMAdapterUnityErrorWithCodeAndDescription
create NSError via GADMAdapterUnityErrorWithCodeAndDescription

diff:
_gameID = [[[strongConnector credentials] objectForKey:kGADMAdapterUnityGameID] copy];
_placementID = [strongConnector.credentials[kGADMAdapterUnityPlacementID] copy];
if (!_gameID || !_placementID) {
- NSError *error = GADUnityErrorWithDescription(kMISSING_ID_ERROR);
+ NSError *error = GADMAdapterUnityErrorWithCodeAndDescription(
+ GADMAdapterUnityErrorInvalidServerParameters, @"Game ID and Placement ID cannot be nil.");
[strongConnector adapter:strongAdapter didFailAd:error];
return;
}

diff:
if (!_interstitialAd) {
NSString *description = [NSString
stringWithFormat:@"%@ initialization failed!", NSStringFromClass([GADMUnityInterstitialAd class])];
- NSError *error = GADMAdapterUnityErrorWithCodeAndDescription(GADMAdapterUnityErrorAdInitializationFailure, description);
+ NSError *error = GADMAdapterUnityErrorWithCodeAndDescription(GADMAdapterUnityErrorAdObjectNil, description);
[strongConnector adapter:self didFailAd:error];
return;
}
_gameID = [strongConnector.credentials[kGADMAdapterUnityGameID] copy];
_placementID = [strongConnector.credentials[kGADMAdapterUnityPlacementID] copy];
if (!_gameID || !_placementID) {
- NSError *error = GADMAdapterUnityErrorWithCodeAndDescription( GADMAdapterUnityErrorInvalidServerParameters, kMISSING_ID_ERROR);
+ NSError *error = GADMAdapterUnityErrorWithCodeAndDescription( GADMAdapterUnityErrorInvalidServerParameters, @"Game ID and Placement ID cannot be nil.");
[strongConnector adapter:self didFailAd:error];
return;
}
if (!_bannerAd) {
NSString *description = [NSString
stringWithFormat:@"%@ initialization failed!", NSStringFromClass([GADMAdapterUnityBannerAd class])];
- NSError *error = GADMAdapterUnityErrorWithCodeAndDescription(GADMAdapterUnityErrorAdInitializationFailure, description);
+ NSError *error = GADMAdapterUnityErrorWithCodeAndDescription(GADMAdapterUnityErrorAdObjectNil, description);
[strongConnector adapter:self didFailAd:error];
return;
}

diff:
#import "GADMAdapterUnityConstants.h"
#import "GADUnityError.h"
#import "GADMUnityInitializer.h"
+#import "GADMAdapterUnityUtils.h"
@interface GADMUnityInterstitialAd ()
@end
_gameID = [[[strongConnector credentials] objectForKey:kGADMAdapterUnityGameID] copy];
_placementID = [[[strongConnector credentials] objectForKey:kGADMAdapterUnityPlacementID] copy];
if (!_gameID || !_placementID) {
- NSError *error = GADUnityErrorWithDescription(kMISSING_ID_ERROR);
+ NSError *error = GADMAdapterUnityErrorWithCodeAndDescription(
+ GADMAdapterUnityErrorInvalidServerParameters, @"Game ID and Placement ID cannot be nil.");
[strongConnector adapter:strongAdapter didFailAd:error];
return;
}
id<GADMAdNetworkConnector> strongConnector = _connector;
id<GADMAdNetworkAdapter> strongAdapter = _adapter;
if (strongConnector && strongAdapter) {
- NSError *error = GADUnityErrorWithDescription([NSString stringWithFormat:@"Failed to load interstitial ad with placement ID '%@'", placementId]);
+ NSString *errorMsg = [NSString stringWithFormat:@"No ad available for the placement ID: %@", _placementID];
+ NSError *error = GADMAdapterUnityErrorWithCodeAndDescription(GADMAdapterUnityErrorPlacementStateNoFill, errorMsg);
[strongConnector adapter:strongAdapter didFailAd:error];
}
}

diff:
#import <Foundation/Foundation.h>
-/// Missing gameID or placementID
-static NSString *const kMISSING_ID_ERROR = @"Game ID and Placement ID cannot be nil.";
-
/// Returns an NSError with NSLocalizedDescriptionKey and NSLocalizedFailureReasonErrorKey values
/// set to |description|.
NSError *GADUnityErrorWithDescription(NSString *description);


message: Updated for FAN 6.0.0

diff:
## Facebook iOS Mediation Adapter Changelog
+#### Version 6.0.0.01
+- Verified compatibility with FAN SDK 6.0.0.
+- Now requires Google Mobile Ads SDK version 7.62.0 or higher.
+
+Built and tested with
+- Google Mobile Ads SDK version 7.62.0.
+- FAN SDK version 6.0.0.
+
#### Version 5.10.1.0
- Verified compatibility with FAN SDK 5.10.1.
- Now requires Google Mobile Ads SDK version 7.62.0 or higher.

diff:
// limitations under the License.
/// Facebook mediation network adapter version.
-static NSString *const kGADMAdapterFacebookVersion = @"5.10.1.0";
+static NSString *const kGADMAdapterFacebookVersion = @"6.0.0.0";
static NSString *const kGADMAdapterFacebookOpenBiddingPubID = @"placement_id";

original_message: Updated for FAN 6.0.0