create NSError via GADMAdapterUnityErrorWithCodeAndDescription
create NSError via GADMAdapterUnityErrorWithCodeAndDescription
MODIFY
adapters/Unity/UnityAdapter/GADMAdapterUnityBannerAd.m
adapters/Unity/UnityAdapter/GADMAdapterUnityBannerAd.m
_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;
}

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

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

MODIFY
adapters/Unity/UnityAdapter/GADUnityError.h
adapters/Unity/UnityAdapter/GADUnityError.h
#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);

create NSError via GADMAdapterUnityErrorWithCodeAndDescription

create NSError via GADMAdapterUnityErrorWithCodeAndDescription