Address comments
Address the first round comments
MODIFY
adapters/Unity/UnityAdapter/GADMAdapterUnity.m
adapters/Unity/UnityAdapter/GADMAdapterUnity.m
}
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

MODIFY
adapters/Unity/UnityAdapter/GADMAdapterUnityBannerAd.m
adapters/Unity/UnityAdapter/GADMAdapterUnityBannerAd.m
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;
}
};

MODIFY
adapters/Unity/UnityAdapter/GADMAdapterUnityRewardedAd.m
adapters/Unity/UnityAdapter/GADMAdapterUnityRewardedAd.m
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");

MODIFY
adapters/Unity/UnityAdapter/GADMAdapterUnitySingleton.m
adapters/Unity/UnityAdapter/GADMAdapterUnitySingleton.m
- (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) {

MODIFY
adapters/Unity/UnityAdapter/GADMediationAdapterUnity.m
adapters/Unity/UnityAdapter/GADMediationAdapterUnity.m
}
UnitySingletonCompletion completeBlock = ^(UnityAdsError *error, NSString *message) {
- if(!error && completionHandler) {
- completionHandler(nil);
- } else {
+ if (error) {
completionHandler(GADUnityErrorWithDescription(message));
+ return;
}
+ completionHandler(nil);
};
[[GADMAdapterUnitySingleton sharedInstance] initializeWithGameID:gameID

Address comments

Address the first round comments