clear completeBlock after called it once
clear completeBlock after called it once
MODIFY
adapters/Unity/UnityAdapter/GADMAdapterUnity.m
adapters/Unity/UnityAdapter/GADMAdapterUnity.m
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 {

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

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

clear completeBlock after called it once

clear completeBlock after called it once