Compatible to iOS SDK 5.4.0
MODIFY
adapters/Vungle/VungleAdapter/GADMAdapterVungleInterstitial.m
adapters/Vungle/VungleAdapter/GADMAdapterVungleInterstitial.m
-#import "GADMAdapterVungleInterstitial.h"
#import <GoogleMobileAds/Mediation/GADMAdNetworkConnectorProtocol.h>
+#import "GADMAdapterVungleInterstitial.h"
#import "vungleHelper.h"
@interface GADMAdapterVungleInterstitial () <VungleDelegate>
}
- (void)getBannerWithSize:(GADAdSize)adSize{
- NSError *error = [NSError
- errorWithDomain:@"google"
+ NSError *error = [NSError errorWithDomain:@"google"
code:0
- userInfo:@{NSLocalizedDescriptionKey : @"Vungle doesn't support banner ads."}];
+ userInfo:@{
+ NSLocalizedDescriptionKey : @"Vungle doesn't support banner ads."
+ }];
[_connector adapter:self didFailAd:error];
}
}
- (void)getInterstitial {
- [vungleHelper
- parseServerParameters:[_connector credentials]
+ [vungleHelper parseServerParameters:[_connector credentials]
networkExtras:[_connector networkExtras]
result:^void(NSDictionary* error, NSString* appId, NSArray* placements) {
if (error) {
- [_connector
- adapter:self
+ [_connector adapter:self
didFailAd:[NSError errorWithDomain:@"GADMAdapterVungleInterstitial"
code:0
userInfo:error]];
return;
}
- desiredPlacement = [vungleHelper findPlacement:[_connector credentials]
- networkExtras:[_connector networkExtras]];
+ desiredPlacement = [vungleHelper findPlacement:[_connector credentials] networkExtras:[_connector networkExtras]];
if (!desiredPlacement) {
desiredPlacement = [placements firstObject];
- NSLog(@"'placementID' not specified. Used first from 'allPlacements': %@",
- desiredPlacement);
+ NSLog(@"'placementID' not specified. Used first from 'allPlacements': %@", desiredPlacement);
}
waitingInit = YES;
[[vungleHelper sharedInstance] initWithAppId:appId placements:placements];

MODIFY
adapters/Vungle/VungleAdapter/GADMAdapterVungleRewardBasedVideoAd.h
adapters/Vungle/VungleAdapter/GADMAdapterVungleRewardBasedVideoAd.h
#import <GoogleMobileAds/Mediation/GADMRewardBasedVideoAdNetworkAdapterProtocol.h>
-@interface GADMAdapterVungleRewardBasedVideoAd
- : NSObject<GADMRewardBasedVideoAdNetworkAdapter>
+@interface GADMAdapterVungleRewardBasedVideoAd : NSObject<GADMRewardBasedVideoAdNetworkAdapter>
@end

MODIFY
adapters/Vungle/VungleAdapter/GADMAdapterVungleRewardBasedVideoAd.m
adapters/Vungle/VungleAdapter/GADMAdapterVungleRewardBasedVideoAd.m
-#import "GADMAdapterVungleRewardBasedVideoAd.h"
#import <GoogleMobileAds/Mediation/GADMRewardBasedVideoAdNetworkConnectorProtocol.h>
-#import "VungleAdNetworkExtras.h"
+#import "GADMAdapterVungleRewardBasedVideoAd.h"
#import "vungleHelper.h"
+#import "VungleAdNetworkExtras.h"
@interface GADMAdapterVungleRewardBasedVideoAd () <VungleDelegate>
@property(nonatomic, weak) id<GADMRewardBasedVideoAdNetworkConnector> connector;
}
- (void)setUp {
- [vungleHelper
- parseServerParameters:[_connector credentials]
+ [vungleHelper parseServerParameters:[_connector credentials]
networkExtras:[_connector networkExtras]
result:^void(NSDictionary* error, NSString* appId, NSArray* placements) {
if (error) {
- [_connector adapter:self
- didFailToSetUpRewardBasedVideoAdWithError:
- [NSError errorWithDomain:@"GADMAdapterVungleRewardBasedVideoAd"
+ [_connector adapter:self didFailToSetUpRewardBasedVideoAdWithError:[NSError errorWithDomain:@"GADMAdapterVungleRewardBasedVideoAd"
code:0
userInfo:error]];
return;
}
- (void)requestRewardBasedVideoAd {
- desiredPlacement = [vungleHelper findPlacement:[_connector credentials]
- networkExtras:[_connector networkExtras]];
+ desiredPlacement = [vungleHelper findPlacement:[_connector credentials] networkExtras:[_connector networkExtras]];
if (!desiredPlacement) {
desiredPlacement = [[vungleHelper sharedInstance].allPlacements firstObject];
- NSLog(@"'placementID' not specified. Used first one from 'allPlacements': %@",
- desiredPlacement);
+ NSLog(@"'placementID' not specified. Used first one from 'allPlacements': %@", desiredPlacement);
}
[[vungleHelper sharedInstance] loadAd:desiredPlacement];
}
- (void)willCloseAd:(BOOL)completedView {
if (completedView){
- GADAdReward* reward =
- [[GADAdReward alloc] initWithRewardType:@"vungle"
+ GADAdReward* reward = [[GADAdReward alloc] initWithRewardType:@"vungle"
rewardAmount:[NSDecimalNumber decimalNumberWithString:@"1"]];
[_connector adapter:self didRewardUserWithReward:reward];
}

MODIFY
adapters/Vungle/VungleAdapter/vungleHelper.h
adapters/Vungle/VungleAdapter/vungleHelper.h
@@ -22,15 +22,10 @@ typedef void (^ParameterCB)(NSDictionary *, NSString *, NSArray<NSString *> *);
+ (vungleHelper *)sharedInstance;
-+ (void)parseServerParameters:(NSDictionary *)serverParameters
- networkExtras:(VungleAdNetworkExtras *)networkExtras
- result:(ParameterCB)result;
-+ (NSString *)findPlacement:(NSDictionary *)serverParameters
- networkExtras:(VungleAdNetworkExtras *)networkExtras;
++ (void)parseServerParameters:(NSDictionary*)serverParameters networkExtras:(VungleAdNetworkExtras*)networkExtras result:(ParameterCB)result;
++ (NSString*)findPlacement:(NSDictionary*)serverParameters networkExtras:(VungleAdNetworkExtras*)networkExtras;
- (void)initWithAppId:(NSString *)appId placements:(NSArray<NSString *>*)placements;
-- (BOOL)playAd:(UIViewController *)viewController
- delegate:(id<VungleDelegate>)delegate
- extras:(VungleAdNetworkExtras *)extras;
+- (BOOL)playAd:(UIViewController *)viewController delegate:(id<VungleDelegate>)delegate extras:(VungleAdNetworkExtras *)extras;
- (void)loadAd:(NSString *)placement;
- (void)addDelegate:(id<VungleDelegate>)delegate;
- (void)removeDelegate:(id<VungleDelegate>)delegate;

MODIFY
adapters/Vungle/VungleAdapter/vungleHelper.m
adapters/Vungle/VungleAdapter/vungleHelper.m
#import "vungleHelper.h"
-static NSString *const vungleAdapterVersion = @"5.3.2";
+static NSString *const vungleAdapterVersion = @"5.4.0";
static NSString *const kApplicationID = @"application_id";
static NSString *const kPlacementID = @"placementID";
@@ -12,6 +12,7 @@ static NSString *const kPlacementID = @"placementID";
@implementation vungleHelper
+
+ (NSString *)adapterVersion {
return vungleAdapterVersion;
}
@@ -37,8 +38,7 @@ static NSString *const kPlacementID = @"placementID";
-(void)initWithAppId:(NSString *)appId placements:(NSArray<NSString *>*)placements{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
- NSString *version =
- [[vungleHelper adapterVersion] stringByReplacingOccurrencesOfString:@"." withString:@"_"];
+ NSString *version = [[vungleHelper adapterVersion] stringByReplacingOccurrencesOfString:@"." withString:@"_"];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
[[VungleSDK sharedSDK] performSelector:@selector(setPluginName:version:)
@@ -65,9 +65,7 @@ static NSString *const kPlacementID = @"placementID";
}
}
-+ (void)parseServerParameters:(NSDictionary *)serverParameters
- networkExtras:(VungleAdNetworkExtras *)networkExtras
- result:(ParameterCB)result {
++(void)parseServerParameters:(NSDictionary*)serverParameters networkExtras:(VungleAdNetworkExtras*)networkExtras result:(ParameterCB)result {
NSMutableArray* allPlacements = [NSMutableArray array];
if (networkExtras && networkExtras.allPlacements && [networkExtras.allPlacements count] > 0) {
[allPlacements addObjectsFromArray:networkExtras.allPlacements];
@@ -89,17 +87,14 @@ static NSString *const kPlacementID = @"placementID";
result(nil, appId, allPlacements);
}
-+ (NSString *)findPlacement:(NSDictionary *)serverParameters
- networkExtras:(VungleAdNetworkExtras *)networkExtras {
++(NSString*)findPlacement:(NSDictionary*)serverParameters networkExtras:(VungleAdNetworkExtras*)networkExtras {
NSString* ret = nil;
if (serverParameters && [serverParameters objectForKey:kPlacementID]) {
ret = [serverParameters objectForKey:kPlacementID];
}
if (networkExtras && networkExtras.playingPlacement) {
if (ret) {
- NSLog(
- @"'placementID' had a value in both serverParameters and networkExtras. Used one from "
- @"serverParameters");
+ NSLog(@"'placementID' had a value in both serverParameters and networkExtras. Used one from serverParameters");
} else {
ret = networkExtras.playingPlacement;
}
@@ -139,22 +134,20 @@ static NSString *const kPlacementID = @"placementID";
}
}
-- (BOOL)playAd:(UIViewController *)viewController
- delegate:(id<VungleDelegate>)delegate
- extras:(VungleAdNetworkExtras *)extras {
- if (!delegate || !delegate.desiredPlacement ||
- ![[VungleSDK sharedSDK] isAdCachedForPlacementID:delegate.desiredPlacement]) {
+- (BOOL)playAd:(UIViewController *)viewController delegate:(id<VungleDelegate>)delegate extras:(VungleAdNetworkExtras *)extras {
+ if (!delegate || !delegate.desiredPlacement || ![[VungleSDK sharedSDK] isAdCachedForPlacementID:delegate.desiredPlacement]) {
return false;
}
NSMutableDictionary *options = [[NSMutableDictionary alloc] init];
NSError *error = nil;
bool startPlaying = true;
[VungleSDK sharedSDK].muted = extras.muted;
- if (extras.userId) [options setObject:extras.userId forKey:VunglePlayAdOptionKeyUser];
- if (extras.ordinal) [options setObject:@(extras.ordinal) forKey:VunglePlayAdOptionKeyOrdinal];
+ if (extras.userId)
+ [options setObject:extras.userId forKey:VunglePlayAdOptionKeyUser];
+ if (extras.ordinal)
+ [options setObject:@(extras.ordinal) forKey:VunglePlayAdOptionKeyOrdinal];
if (extras.flexViewAutoDismissSeconds)
- [options setObject:@(extras.flexViewAutoDismissSeconds)
- forKey:VunglePlayAdOptionKeyFlexViewAutoDismissSeconds];
+ [options setObject:@(extras.flexViewAutoDismissSeconds) forKey:VunglePlayAdOptionKeyFlexViewAutoDismissSeconds];
if (![[VungleSDK sharedSDK] playAd:viewController
options:options
placementID:delegate.desiredPlacement
@@ -162,8 +155,7 @@ static NSString *const kPlacementID = @"placementID";
startPlaying = false;
}
if (error) {
- NSLog(@"Adapter failed to present reward based video ad, error %@",
- [error localizedDescription]);
+ NSLog(@"Adapter failed to present reward based video ad, error %@", [error localizedDescription]);
startPlaying = false;
};
if (startPlaying) {
@@ -189,16 +181,18 @@ static NSString *const kPlacementID = @"placementID";
}
}
-- (void)vungleWillCloseAdWithViewInfo:(nonnull VungleViewInfo *)info
- placementID:(nonnull NSString *)placementID {
+- (void)vungleWillCloseAdWithViewInfo:(nonnull VungleViewInfo *)info placementID:(nonnull NSString *)placementID {
if (_playingDelegate) {
[_playingDelegate willCloseAd:[info.completedView boolValue]];
}
}
-- (void)vungleAdPlayabilityUpdate:(BOOL)isAdPlayable placementID:(nullable NSString *)placementID {
+- (void)vungleAdPlayabilityUpdate:(BOOL)isAdPlayable placementID:(NSString *)placementID error:(NSError *)error {
if (isAdPlayable) {
[self notifyAdIsReady:placementID];
+ } else if (error) {
+ // do we want to do anything with the error here?
+ NSLog(@"Vungle Ad Playability returned an error: %@", error.localizedDescription);
}
}

Compatible to iOS SDK 5.4.0