Compatible with iOS SDK 6.2.0
MODIFY
adapters/Vungle/Public/Headers/VungleAdNetworkExtras.h
adapters/Vungle/Public/Headers/VungleAdNetworkExtras.h
#import <Foundation/Foundation.h>
-@import GoogleMobileAds;
+#import <GoogleMobileAds/GADAdNetworkExtras.h>
+
+typedef NS_ENUM(NSInteger, VungleExtrasConsentStatus) {
+ VungleExtrasConsentAccepted = 1,
+ VungleExtrasConsentDenied
+};
@interface VungleAdNetworkExtras : NSObject<GADAdNetworkExtras>
*/
@property(nonatomic, assign) BOOL muted;
-@property(nonatomic, copy) NSArray<NSString *> *_Nonnull allPlacements;
-
-@property(nonatomic, copy) NSString *_Nonnull playingPlacement;
-
@property(nonatomic, assign) NSUInteger ordinal;
@property(nonatomic, assign) NSTimeInterval flexViewAutoDismissSeconds;
+@property(nonatomic, copy) NSArray<NSString *> *_Nullable allPlacements;
+
+@property(nonatomic, copy) NSString *_Nullable playingPlacement;
+
+@property(nonatomic, assign) VungleExtrasConsentStatus consentStatus;
+
@end

MODIFY
adapters/Vungle/VungleAdapter/GADMAdapterVungleInterstitial.h
adapters/Vungle/VungleAdapter/GADMAdapterVungleInterstitial.h
#import <Foundation/Foundation.h>
-@import GoogleMobileAds;
+#import <GoogleMobileAds/Mediation/GADMAdNetworkAdapterProtocol.h>
@interface GADMAdapterVungleInterstitial : NSObject<GADMAdNetworkAdapter>
@end

MODIFY
adapters/Vungle/VungleAdapter/GADMAdapterVungleInterstitial.m
adapters/Vungle/VungleAdapter/GADMAdapterVungleInterstitial.m
}
- (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];
}
[vungleHelper
parseServerParameters:[_connector credentials]
networkExtras:[_connector networkExtras]
- result:^void(NSDictionary *error, NSString *appId, NSArray *placements) {
+ result:^void(NSDictionary *error, NSString *appId) {
if (error) {
[_connector
adapter:self
desiredPlacement = [vungleHelper findPlacement:[_connector credentials]
networkExtras:[_connector networkExtras]];
if (!desiredPlacement) {
- desiredPlacement = [placements firstObject];
- NSLog(@"'placementID' not specified. Used first from 'allPlacements': %@",
- desiredPlacement);
+ [_connector
+ adapter:self
+ didFailAd:[NSError errorWithDomain:@"GADMAdapterVungleInterstitial"
+ code:0
+ userInfo:@{
+ NSLocalizedDescriptionKey :
+ @"'placementID' not specified"
+ }]];
+ return;
}
+ [vungleHelper updateConsentStatus:[_connector networkExtras]];
waitingInit = YES;
- [[vungleHelper sharedInstance] initWithAppId:appId placements:placements];
+ [[vungleHelper sharedInstance] initWithAppId:appId];
}];
}
[_connector adapterWillPresentInterstitial:self];
}
-- (void)willLeaveApplication {
- [_connector adapterWillLeaveApplication:self];
-}
-
-- (void)willCloseAd:(BOOL)completedView didClickDownload:(BOOL)didClickDownload {
- if (didClickDownload) {
- // Only the donload button is clickable for Vungle ads, so the didClickDownload flag can be used
- // to track clicks.
+- (void)willCloseAd:(BOOL)completedView didDownload:(BOOL)didDownload {
+ if (didDownload) {
[_connector adapterDidGetAdClick:self];
+ [_connector adapterWillLeaveApplication:self];
}
[_connector adapterWillDismissInterstitial:self];
+}
+
+- (void)didCloseAd:(BOOL)completedView didDownload:(BOOL)didDownload {
[_connector adapterDidDismissInterstitial:self];
desiredPlacement = nil;
}

MODIFY
adapters/Vungle/VungleAdapter/GADMAdapterVungleRewardBasedVideoAd.h
adapters/Vungle/VungleAdapter/GADMAdapterVungleRewardBasedVideoAd.h
#import <Foundation/Foundation.h>
-@import GoogleMobileAds;
+#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
[vungleHelper
parseServerParameters:[_connector credentials]
networkExtras:[_connector networkExtras]
- result:^void(NSDictionary* error, NSString* appId, NSArray* placements) {
+ result:^void(NSDictionary *error, NSString *appId) {
if (error) {
[_connector adapter:self
didFailToSetUpRewardBasedVideoAdWithError:
userInfo:error]];
return;
}
+ [vungleHelper updateConsentStatus:[_connector networkExtras]];
waitingInit = YES;
- [[vungleHelper sharedInstance] initWithAppId:appId placements:placements];
+ [[vungleHelper sharedInstance] initWithAppId:appId];
}];
}
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);
+ [_connector adapter:self
+ didFailToLoadRewardBasedVideoAdwithError:
+ [NSError
+ errorWithDomain:@"GADMAdapterVungleRewardBasedVideoAd"
+ code:0
+ userInfo:@{NSLocalizedDescriptionKey : @"'placementID' not specified"}]];
+ return;
}
[[vungleHelper sharedInstance] loadAd:desiredPlacement];
}
[_connector adapterDidStartPlayingRewardBasedVideoAd:self];
}
-- (void)willLeaveApplication {
- [_connector adapterWillLeaveApplication:self];
+- (void)willCloseAd:(BOOL)completedView didDownload:(BOOL)didDownload {
+ // not used
}
-- (void)willCloseAd:(BOOL)completedView didClickDownload:(BOOL)didClickDownload {
- if (didClickDownload) {
- // Only the download button is clickable for Vungle ads, so the didClickDownload flag can be used
- // to track clicks.
- [_connector adapterDidGetAdClick:self];
- }
+- (void)didCloseAd:(BOOL)completedView didDownload:(BOOL)didDownload {
if (completedView) {
GADAdReward *reward =
[[GADAdReward alloc] initWithRewardType:@"vungle"
rewardAmount:[NSDecimalNumber decimalNumberWithString:@"1"]];
[_connector adapter:self didRewardUserWithReward:reward];
}
+ if (didDownload) {
+ [_connector adapterDidGetAdClick:self];
+ [_connector adapterWillLeaveApplication:self];
+ }
[_connector adapterDidCloseRewardBasedVideoAd:self];
desiredPlacement = nil;
}

MODIFY
adapters/Vungle/VungleAdapter/vungleHelper.h
adapters/Vungle/VungleAdapter/vungleHelper.h
- (void)initialized:(BOOL)isSuccess error:(NSError *)error;
- (void)adAvailable;
- (void)willShowAd;
-- (void)willLeaveApplication;
-- (void)willCloseAd:(BOOL)completedView didClickDownload:(BOOL)didClickDownload;
+- (void)willCloseAd:(BOOL)completedView didDownload:(BOOL)didDownload;
+- (void)didCloseAd:(BOOL)completedView didDownload:(BOOL)didDownload;
@property(readonly, strong) NSString *desiredPlacement;
@property(readonly, assign) BOOL waitingInit;
@end
@interface vungleHelper : NSObject<VungleSDKDelegate>
@property(readonly) BOOL isInitialising;
-@property(readonly, strong) NSArray *allPlacements;
-typedef void (^ParameterCB)(NSDictionary *, NSString *, NSArray<NSString *> *);
+typedef void (^ParameterCB)(NSDictionary *error, NSString *appId);
+ (NSString *)adapterVersion;
@@ -27,7 +26,8 @@ typedef void (^ParameterCB)(NSDictionary *, NSString *, NSArray<NSString *> *);
result:(ParameterCB)result;
+ (NSString *)findPlacement:(NSDictionary *)serverParameters
networkExtras:(VungleAdNetworkExtras *)networkExtras;
-- (void)initWithAppId:(NSString *)appId placements:(NSArray<NSString *> *)placements;
++ (void)updateConsentStatus:(VungleAdNetworkExtras *)networkExtras;
+- (void)initWithAppId:(NSString *)appId;
- (BOOL)playAd:(UIViewController *)viewController
delegate:(id<VungleDelegate>)delegate
extras:(VungleAdNetworkExtras *)extras;

MODIFY
adapters/Vungle/VungleAdapter/vungleHelper.m
adapters/Vungle/VungleAdapter/vungleHelper.m
@@ -34,7 +34,7 @@ static NSString *const kPlacementID = @"placementID";
return self;
}
-- (void)initWithAppId:(NSString *)appId placements:(NSArray<NSString *> *)placements {
+- (void)initWithAppId:(NSString *)appId {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSString *version =
@@ -58,7 +58,6 @@ static NSString *const kPlacementID = @"placementID";
_isInitialising = true;
NSError *err = nil;
- _allPlacements = placements;
[sdk startWithAppId:appId error:&err];
if (err) {
[self initialized:false error:err];
@@ -68,29 +67,22 @@ static NSString *const kPlacementID = @"placementID";
+ (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];
- }
-
- if (!serverParameters || ![serverParameters objectForKey:kApplicationID]) {
- NSLog(@"Vungle app ID should be specified!");
- result(@{ NSLocalizedDescriptionKey : @"Vungle app ID should be specified!" }, nil, nil);
- return;
- }
- NSString *appId = [serverParameters objectForKey:kApplicationID];
-
- if (allPlacements.count == 0) {
- NSLog(@"At least one placement should be specified!");
- result(
- @{
- NSLocalizedDescriptionKey : @"At least one placement should be specified!"
- },
- nil, nil);
+ if ([networkExtras.allPlacements count] > 0) {
+ NSLog(
+ @"No need to pass placement IDs through `VungleAdNetworkExtras` with Vungle iOS SDK "
+ @"version %@ and plugin version %@",
+ VungleSDKVersion, vungleAdapterVersion);
+ }
+
+ NSString *appId = serverParameters[kApplicationID];
+ if (!appId) {
+ NSString *const message = @"Vungle app ID should be specified!";
+ NSLog(message);
+ result(@{NSLocalizedDescriptionKey : message}, nil);
return;
}
- result(nil, appId, allPlacements);
+ result(nil, appId);
}
+ (NSString *)findPlacement:(NSDictionary *)serverParameters
@@ -101,7 +93,8 @@ static NSString *const kPlacementID = @"placementID";
}
if (networkExtras && networkExtras.playingPlacement) {
if (ret) {
- NSLog(@"'placementID' had a value in both serverParameters and networkExtras. Used one from "
+ NSLog(
+ @"'placementID' had a value in both serverParameters and networkExtras. Used one from "
@"serverParameters");
} else {
ret = networkExtras.playingPlacement;
@@ -111,6 +104,13 @@ static NSString *const kPlacementID = @"placementID";
return ret;
}
++ (void)updateConsentStatus:(VungleAdNetworkExtras *)networkExtras {
+ if (networkExtras.consentStatus == VungleExtrasConsentAccepted)
+ [[VungleSDK sharedSDK] updateConsentStatus:VungleConsentAccepted];
+ else if (networkExtras.consentStatus == VungleExtrasConsentDenied)
+ [[VungleSDK sharedSDK] updateConsentStatus:VungleConsentDenied];
+}
+
- (void)addDelegate:(id<VungleDelegate>)delegate {
if (delegate && ![_delegates containsObject:delegate]) {
[_delegates addObject:delegate];
@@ -196,13 +196,25 @@ static NSString *const kPlacementID = @"placementID";
placementID:(nonnull NSString *)placementID {
if (_playingDelegate) {
[_playingDelegate willCloseAd:[info.completedView boolValue]
- didClickDownload:[info.didDownload boolValue]];
+ didDownload:[info.didDownload boolValue]];
+ }
+}
+
+- (void)vungleDidCloseAdWithViewInfo:(VungleViewInfo *)info placementID:(NSString *)placementID {
+ if (_playingDelegate) {
+ [_playingDelegate didCloseAd:[info.completedView boolValue]
+ didDownload:[info.didDownload 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 with iOS SDK 6.2.0