Adding adapter files - Vungle
UNKNOWN
adapters/Vungle/BuildScript/Script_Framework.sh
adapters/Vungle/BuildScript/Script_Framework.sh
UNKNOWN
adapters/Vungle/BuildScript/Script_Library.sh
adapters/Vungle/BuildScript/Script_Library.sh
MODIFY
adapters/Vungle/Public/module.modulemap
adapters/Vungle/Public/module.modulemap
@@ -8,4 +8,5 @@ framework module VungleAdapter {
link framework "UIKit"
// Add any public headers here.
+ header "VungleAdNetworkExtras.h"
}

MODIFY
adapters/Vungle/README.md
adapters/Vungle/README.md
This is an adapter to be used in conjunction with the Google Mobile Ads SDK.
For requirements, instructions, and other info, see the
-[quick start guide](https://firebase.google.com/docs/admob/ios/quick-start).
+[quick start guide](https://developers.google.com/admob/ios/mediation/vungle).

MODIFY
adapters/Vungle/VungleAdapter.xcodeproj/project.pbxproj
adapters/Vungle/VungleAdapter.xcodeproj/project.pbxproj
7D1B6CA61DC2AD7700D8CABF /* Framework Script */,
);
dependencies = (
+ A8435CF61F152C9400AA595E /* PBXTargetDependency */,
);
name = Framework;
productName = Framework;
7DD2DCBD1DD12E3E00888FDB /* Static Library Script */,
);
dependencies = (
+ A8435CF41F152C8E00AA595E /* PBXTargetDependency */,
);
name = FatAdapter;
productName = FatAdapter;
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
- 7D1575701EB7FB9200059469 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = 7D15756F1EB7FB9200059469 /* README.md */; };
7D1575721EB7FBB200059469 /* VungleAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = 7D1575711EB7FBB200059469 /* VungleAdapter.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ A85428E01F11853A00C135E7 /* GADMAdapterVungleInterstitial.h in Headers */ = {isa = PBXBuildFile; fileRef = A85428D81F11853A00C135E7 /* GADMAdapterVungleInterstitial.h */; };
+ A85428E11F11853A00C135E7 /* GADMAdapterVungleInterstitial.m in Sources */ = {isa = PBXBuildFile; fileRef = A85428D91F11853A00C135E7 /* GADMAdapterVungleInterstitial.m */; };
+ A85428E21F11853A00C135E7 /* GADMAdapterVungleRewardBasedVideoAd.h in Headers */ = {isa = PBXBuildFile; fileRef = A85428DA1F11853A00C135E7 /* GADMAdapterVungleRewardBasedVideoAd.h */; };
+ A85428E31F11853A00C135E7 /* GADMAdapterVungleRewardBasedVideoAd.m in Sources */ = {isa = PBXBuildFile; fileRef = A85428DB1F11853A00C135E7 /* GADMAdapterVungleRewardBasedVideoAd.m */; };
+ A85428E41F11853A00C135E7 /* VungleAdNetworkExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = A85428DC1F11853A00C135E7 /* VungleAdNetworkExtras.h */; };
+ A85428E51F11853A00C135E7 /* VungleAdNetworkExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = A85428DD1F11853A00C135E7 /* VungleAdNetworkExtras.m */; };
+ A85428E61F11853A00C135E7 /* vungleHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = A85428DE1F11853A00C135E7 /* vungleHelper.h */; };
+ A85428E71F11853A00C135E7 /* vungleHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = A85428DF1F11853A00C135E7 /* vungleHelper.m */; };
/* End PBXBuildFile section */
+/* Begin PBXContainerItemProxy section */
+ A8435CF31F152C8E00AA595E /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 7DFABB151DA8682C00322E02 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 7DFABB1C1DA8682C00322E02;
+ remoteInfo = Adapter;
+ };
+ A8435CF51F152C9400AA595E /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 7DFABB151DA8682C00322E02 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 7DFABB1C1DA8682C00322E02;
+ remoteInfo = Adapter;
+ };
+/* End PBXContainerItemProxy section */
+
/* Begin PBXCopyFilesBuildPhase section */
7DFABB1B1DA8682C00322E02 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
- 7D15756F1EB7FB9200059469 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
7D1575711EB7FBB200059469 /* VungleAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VungleAdapter.h; sourceTree = "<group>"; };
7D264FF01DDD1B4E00027720 /* CHANGELOG.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = "<group>"; };
7D264FF21DDD1B9400027720 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
7DC8681F1DDA8D4400F0F1C4 /* module.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
7DE821BF1DB04B5000AA08CF /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
7DFABB1D1DA8682C00322E02 /* libAdapter.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAdapter.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ A85428D81F11853A00C135E7 /* GADMAdapterVungleInterstitial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADMAdapterVungleInterstitial.h; sourceTree = "<group>"; };
+ A85428D91F11853A00C135E7 /* GADMAdapterVungleInterstitial.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GADMAdapterVungleInterstitial.m; sourceTree = "<group>"; };
+ A85428DA1F11853A00C135E7 /* GADMAdapterVungleRewardBasedVideoAd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADMAdapterVungleRewardBasedVideoAd.h; sourceTree = "<group>"; };
+ A85428DB1F11853A00C135E7 /* GADMAdapterVungleRewardBasedVideoAd.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GADMAdapterVungleRewardBasedVideoAd.m; sourceTree = "<group>"; };
+ A85428DC1F11853A00C135E7 /* VungleAdNetworkExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VungleAdNetworkExtras.h; sourceTree = "<group>"; };
+ A85428DD1F11853A00C135E7 /* VungleAdNetworkExtras.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VungleAdNetworkExtras.m; sourceTree = "<group>"; };
+ A85428DE1F11853A00C135E7 /* vungleHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vungleHelper.h; sourceTree = "<group>"; };
+ A85428DF1F11853A00C135E7 /* vungleHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = vungleHelper.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
7D15756E1EB7FB9200059469 /* VungleAdapter */ = {
isa = PBXGroup;
children = (
- 7D15756F1EB7FB9200059469 /* README.md */,
+ A85428D81F11853A00C135E7 /* GADMAdapterVungleInterstitial.h */,
+ A85428D91F11853A00C135E7 /* GADMAdapterVungleInterstitial.m */,
+ A85428DA1F11853A00C135E7 /* GADMAdapterVungleRewardBasedVideoAd.h */,
+ A85428DB1F11853A00C135E7 /* GADMAdapterVungleRewardBasedVideoAd.m */,
+ A85428DC1F11853A00C135E7 /* VungleAdNetworkExtras.h */,
+ A85428DD1F11853A00C135E7 /* VungleAdNetworkExtras.m */,
+ A85428DE1F11853A00C135E7 /* vungleHelper.h */,
+ A85428DF1F11853A00C135E7 /* vungleHelper.m */,
);
path = VungleAdapter;
sourceTree = "<group>";
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
+ A85428E41F11853A00C135E7 /* VungleAdNetworkExtras.h in Headers */,
+ A85428E01F11853A00C135E7 /* GADMAdapterVungleInterstitial.h in Headers */,
7D1575721EB7FBB200059469 /* VungleAdapter.h in Headers */,
+ A85428E21F11853A00C135E7 /* GADMAdapterVungleRewardBasedVideoAd.h in Headers */,
+ A85428E61F11853A00C135E7 /* vungleHelper.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 7D1575701EB7FB9200059469 /* README.md in Sources */,
+ A85428E51F11853A00C135E7 /* VungleAdNetworkExtras.m in Sources */,
+ A85428E11F11853A00C135E7 /* GADMAdapterVungleInterstitial.m in Sources */,
+ A85428E71F11853A00C135E7 /* vungleHelper.m in Sources */,
+ A85428E31F11853A00C135E7 /* GADMAdapterVungleRewardBasedVideoAd.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
+/* Begin PBXTargetDependency section */
+ A8435CF41F152C8E00AA595E /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 7DFABB1C1DA8682C00322E02 /* Adapter */;
+ targetProxy = A8435CF31F152C8E00AA595E /* PBXContainerItemProxy */;
+ };
+ A8435CF61F152C9400AA595E /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 7DFABB1C1DA8682C00322E02 /* Adapter */;
+ targetProxy = A8435CF51F152C9400AA595E /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
/* Begin XCBuildConfiguration section */
7D1B6CA41DC2ACF900D8CABF /* Debug */ = {
isa = XCBuildConfiguration;
7DFABB271DA8682C00322E02 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(inherited)",
+ "$(PROJECT_DIR)/Drop_Framework_And_Headers",
+ );
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
SKIP_INSTALL = YES;
};
7DFABB281DA8682C00322E02 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(inherited)",
+ "$(PROJECT_DIR)/Drop_Framework_And_Headers",
+ );
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
SKIP_INSTALL = YES;
};

ADD
adapters/Vungle/VungleAdapter/GADMAdapterVungleInterstitial.h
+#import <Foundation/Foundation.h>
+
+#import <GoogleMobileAds/Mediation/GADMAdNetworkAdapterProtocol.h>
+
+@interface GADMAdapterVungleInterstitial : NSObject<GADMAdNetworkAdapter>
+@end
\ No newline at end of file

ADD
adapters/Vungle/VungleAdapter/GADMAdapterVungleInterstitial.m
+#import <GoogleMobileAds/Mediation/GADMAdNetworkConnectorProtocol.h>
+#import "GADMAdapterVungleInterstitial.h"
+#import "vungleHelper.h"
+
+static NSString *const kGADMAdapterVungleInterstitialKeyApplicationID = @"application_id";
+
+@interface GADMAdapterVungleInterstitial () <VungleDelegate>
+@property(nonatomic, weak) id<GADMAdNetworkConnector> connector;
+@end
+
+@implementation GADMAdapterVungleInterstitial
+
++ (NSString *)adapterVersion {
+ return [vungleHelper adapterVersion];
+}
+
++ (Class<GADAdNetworkExtras>)networkExtrasClass {
+ return [VungleAdNetworkExtras class];
+}
+
+- (instancetype)initWithGADMAdNetworkConnector:(id<GADMAdNetworkConnector>)connector {
+ self = [super init];
+ if (self) {
+ self.connector = connector;
+ [vungleHelper sharedInstance].interstitialDelegate = self;
+ }
+ return self;
+}
+
+
+- (void)dealloc {
+ [vungleHelper sharedInstance].interstitialDelegate = nil;
+}
+
+- (void)getBannerWithSize:(GADAdSize)adSize{
+ NSError *error = [NSError errorWithDomain:@"google"
+ code:0
+ userInfo:@{
+ NSLocalizedDescriptionKey : @"No ad fetched."
+ }];
+ [_connector adapter:self didFailAd:error];
+}
+
+- (void) loadAd {
+ if ([[vungleHelper sharedInstance] isAdPlayableFor:desiredPlacement]) {
+ [_connector adapterDidReceiveInterstitial:self];
+ } else {
+ [[vungleHelper sharedInstance] loadAd:InterstitialAdapter placement:desiredPlacement];
+ }
+}
+
+
+- (void)getInterstitial {
+ VungleAdNetworkExtras* extras = [_connector networkExtras];
+ desiredPlacement = extras.placement;
+ if (!extras || !extras.placements || [extras.placements count] == 0) {
+ NSLog(@"Placements should be specified!");
+ [_connector adapter:self didFailAd:[NSError errorWithDomain:@"GADMAdapterVungleInterstitial" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Placements should be specified!"}]];
+ return;
+ }
+
+ if ([[vungleHelper sharedInstance] isInitialised]) {
+ [self loadAd];
+ } else {
+ NSDictionary *serverParameters = [_connector credentials];
+ NSString *applicationID = [serverParameters objectForKey:kGADMAdapterVungleInterstitialKeyApplicationID];
+ [[vungleHelper sharedInstance] initWithAppId:applicationID placements:extras.placements adapter:InterstitialAdapter];
+ }
+}
+
+- (void)stopBeingDelegate {
+ _connector = nil;
+ [vungleHelper sharedInstance].interstitialDelegate = nil;
+}
+
+- (BOOL)isBannerAnimationOK:(GADMBannerAnimationType)animType{
+ return YES;
+}
+
+- (void)presentInterstitialFromRootViewController:(UIViewController *)rootViewController{
+ if (![[vungleHelper sharedInstance] playAd:rootViewController adapter:InterstitialAdapter placement:desiredPlacement extras:[_connector networkExtras]]) {
+ [_connector adapterDidDismissInterstitial:self];
+ }
+}
+
+#pragma mark - vungleHelper delegates
+
+
+@synthesize desiredPlacement;
+
+-(void)initialized:(BOOL)isSuccess error:(NSError *)error {
+ if (isSuccess) {
+ if (desiredPlacement) {
+ [self loadAd];
+ }
+ } else {
+ [_connector adapter:self didFailAd:error];
+ }
+}
+
+-(void)adAvailable{
+ [_connector adapterDidReceiveInterstitial:self];
+}
+
+-(void)willShowAd{
+ [_connector adapterWillPresentInterstitial:self];
+}
+
+-(void)willLeaveApplication {
+ [_connector adapterWillLeaveApplication:self];
+}
+
+-(void)willCloseAd:(bool)completedView{
+ [_connector adapterWillDismissInterstitial:self];
+ [_connector adapterDidDismissInterstitial:self];
+}
+
+@end

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

ADD
adapters/Vungle/VungleAdapter/GADMAdapterVungleRewardBasedVideoAd.m
+#import <GoogleMobileAds/Mediation/GADMRewardBasedVideoAdNetworkConnectorProtocol.h>
+#import "GADMAdapterVungleRewardBasedVideoAd.h"
+#import "vungleHelper.h"
+#import "VungleAdNetworkExtras.h"
+
+static NSString *const kGADMAdapterVungleRewardBasedVideoAdKeyApplicationID = @"application_id";
+
+@interface GADMAdapterVungleRewardBasedVideoAd () <VungleDelegate>
+@property(nonatomic, weak) id<GADMRewardBasedVideoAdNetworkConnector> connector;
+@end
+
+@implementation GADMAdapterVungleRewardBasedVideoAd
+
++ (NSString *)adapterVersion {
+ return [vungleHelper adapterVersion];
+}
+
++ (Class<GADAdNetworkExtras>)networkExtrasClass {
+ return [VungleAdNetworkExtras class];
+}
+
+- (instancetype)initWithRewardBasedVideoAdNetworkConnector:(id<GADMRewardBasedVideoAdNetworkConnector>)connector {
+ self = [super init];
+ if (self) {
+ self.connector = connector;
+ [vungleHelper sharedInstance].rewardDelegate = self;
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [vungleHelper sharedInstance].rewardDelegate = nil;
+}
+
+- (void)setUp {
+ NSDictionary *serverParameters = [_connector credentials];
+ NSString *applicationID = [serverParameters objectForKey:kGADMAdapterVungleRewardBasedVideoAdKeyApplicationID];
+ VungleAdNetworkExtras* extras = [_connector networkExtras];
+ if (!extras || !extras.placements || [extras.placements count] == 0) {
+ NSLog(@"Placements should be specified!");
+ [_connector adapter:self didFailToSetUpRewardBasedVideoAdWithError:[NSError errorWithDomain:@"GADMAdapterVungleRewardBasedVideoAd" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Placements should be specified!"}]];
+ return;
+ }
+ vungleHelper* sdk = [vungleHelper sharedInstance];
+ if ([sdk isInitialised]) {
+ [_connector adapterDidSetUpRewardBasedVideoAd:self];
+ } else {
+ [sdk initWithAppId:applicationID placements:extras.placements adapter:RewardBasedAdapter];
+ }
+}
+
+- (void)requestRewardBasedVideoAd {
+ vungleHelper* sdk = [vungleHelper sharedInstance];
+ desiredPlacement = ((VungleAdNetworkExtras *)[_connector networkExtras]).placement;
+ if ([sdk isAdPlayableFor:desiredPlacement]) {
+ [_connector adapterDidReceiveRewardBasedVideoAd:self];
+ } else {
+ [sdk loadAd:RewardBasedAdapter placement:desiredPlacement];
+ }
+}
+
+- (void)presentRewardBasedVideoAdWithRootViewController:(UIViewController *)viewController {
+ if (![[vungleHelper sharedInstance] playAd:viewController adapter:RewardBasedAdapter placement:desiredPlacement extras:[_connector networkExtras]]) {
+ [_connector adapterDidCloseRewardBasedVideoAd:self];
+ }
+}
+
+- (void)stopBeingDelegate {
+ _connector = nil;
+ [vungleHelper sharedInstance].rewardDelegate = nil;
+}
+
+#pragma mark - vungleHelper delegates
+
+@synthesize desiredPlacement;
+
+-(void)initialized:(BOOL)isSuccess error:(NSError *)error{
+ if (isSuccess){
+ [_connector adapterDidSetUpRewardBasedVideoAd:self];
+ } else {
+ [_connector adapter:self didFailToSetUpRewardBasedVideoAdWithError:error];
+ }
+}
+
+-(void)adAvailable{
+ [_connector adapterDidReceiveRewardBasedVideoAd:self];
+}
+
+-(void)willShowAd{
+ [_connector adapterDidOpenRewardBasedVideoAd:self];
+ [_connector adapterDidStartPlayingRewardBasedVideoAd:self];
+}
+
+-(void)willLeaveApplication {
+ [_connector adapterWillLeaveApplication:self];
+}
+
+-(void)willCloseAd:(bool)completedView{
+ if (completedView){
+ GADAdReward* reward = [[GADAdReward alloc] initWithRewardType:@"vungle" rewardAmount:[NSDecimalNumber decimalNumberWithString:@"1"]];
+ [_connector adapter:self didRewardUserWithReward:reward];
+ }
+ [_connector adapterDidCloseRewardBasedVideoAd:self];
+}
+
+@end

DELETE
adapters/Vungle/VungleAdapter/README.md
-Place adapter source code files in this folder.

ADD
adapters/Vungle/VungleAdapter/vungleHelper.h
+#import <Foundation/Foundation.h>
+#import <VungleSDK/VungleSDK.h>
+
+#import "VungleAdNetworkExtras.h"
+
+typedef enum {
+ InterstitialAdapter = 1 << 1,
+ RewardBasedAdapter = 1 << 2
+} Adapter;
+
+@protocol VungleDelegate <NSObject>
+-(void)initialized:(BOOL)isSuccess error:(NSError *)error;
+-(void)adAvailable;
+-(void)willShowAd;
+-(void)willLeaveApplication;
+-(void)willCloseAd:(bool)completedView;
+@property (strong) NSString * desiredPlacement;
+@end
+
+@interface vungleHelper : NSObject<VungleSDKDelegate>
+@property (strong) id<VungleDelegate> interstitialDelegate;
+@property (strong) id<VungleDelegate> rewardDelegate;
+@property (readonly) BOOL isInitialising;
+@property (readonly) BOOL isInitialised;
+
++ (NSString *)adapterVersion;
+
++ (vungleHelper*) sharedInstance;
+
+-(void)initWithAppId:(NSString *)appId placements:(NSArray<NSString *>*)placements adapter:(Adapter)adapter;
+-(BOOL)isAdPlayableFor:(NSString *)placement;
+-(BOOL)playAd:(UIViewController *)viewController adapter:(Adapter)adapter placement:(NSString *)placement extras:(VungleAdNetworkExtras *)extras;
+-(void)loadAd:(Adapter)adapter placement:(NSString *)placement;
+@end

ADD
adapters/Vungle/VungleAdapter/vungleHelper.m
+#import "vungleHelper.h"
+
+@implementation vungleHelper
+
+static Adapter initializing = 0;
+static Adapter waiting = 0;
+static Adapter playing = 0;
+
++ (NSString *)adapterVersion {
+ return @"2.0.0";
+}
+
++ (vungleHelper*) sharedInstance{
+ static vungleHelper *instance = nil;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ instance = [[vungleHelper alloc] init];
+ });
+ return instance;
+}
+
+-(id)init{
+ self = [super init];
+ if (self){
+ [VungleSDK sharedSDK].delegate = self;
+ }
+ return self;
+}
+
+-(void)initWithAppId:(NSString *)appId placements:(NSArray<NSString *>*)placements adapter:(Adapter)adapter{
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ NSString *version = [[vungleHelper adapterVersion] stringByReplacingOccurrencesOfString:@"." withString:@"_"];
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wundeclared-selector"
+ [[VungleSDK sharedSDK] performSelector:@selector(setPluginName:version:) withObject:@"admob" withObject:version];
+#pragma clang diagnostic pop
+ });
+ VungleSDK* sdk = [VungleSDK sharedSDK];
+ if ([sdk isInitialized]) {
+ _isInitialised = true;
+ return;
+ }
+ initializing |= adapter;
+ if ([self isInitialising]) {
+ return;
+ }
+
+ _isInitialising = true;
+
+ NSError* err = nil;
+ [sdk startWithAppId:appId placements:placements error:&err];
+ if (err) {
+ [self initialized:false error:err];
+ }
+}
+
+-(BOOL)isAdPlayableFor:(NSString *)placement{
+ return [[VungleSDK sharedSDK] isAdCachedForPlacementID:placement];
+}
+
+-(void)loadAd:(Adapter)adapter placement:(NSString *)placement {
+ waiting |= adapter;
+ VungleSDK* sdk = [VungleSDK sharedSDK];
+ if ([sdk isAdCachedForPlacementID:placement]) {
+ [self vungleAdPlayabilityUpdate:true placementID:placement];
+ return;
+ }
+ [sdk loadPlacementWithID:placement error:nil];
+}
+
+- (BOOL)playAd:(UIViewController *)viewController adapter:(Adapter)adapter placement:(NSString *)placement extras:(VungleAdNetworkExtras *)extras {
+ if (![[VungleSDK sharedSDK] isAdCachedForPlacementID:placement]) {
+ return false;
+ }
+ NSMutableDictionary *options = [[NSMutableDictionary alloc] init];
+ NSError *error = nil;
+ bool startPlaying = true;
+ [VungleSDK sharedSDK].muted = extras.muted;
+ playing |= adapter;
+ if (![[VungleSDK sharedSDK] playAd:viewController options:options placementID:placement error:&error]){
+ playing &= ~adapter;
+ startPlaying = false;
+ }
+ if (error) {
+ NSLog(@"Adapter failed to present reward based video ad, error %@", [error localizedDescription]);
+ playing &= ~adapter;
+ startPlaying = false;
+ };
+ return startPlaying;
+}
+
+-(void)initialized:(BOOL)isSuccess error:(NSError *)error {
+ _isInitialising = false;
+ if (isSuccess) {
+ _isInitialised = true;
+ }
+ if ((initializing & InterstitialAdapter) && _interstitialDelegate && [_interstitialDelegate respondsToSelector:@selector(initialized:error:)]) {
+ initializing &= ~InterstitialAdapter;
+ [_interstitialDelegate initialized:isSuccess error:error];
+ }
+
+ if ((initializing & RewardBasedAdapter) && _rewardDelegate && [_rewardDelegate respondsToSelector:@selector(initialized:error:)]) {
+ initializing &= ~RewardBasedAdapter;
+ [_rewardDelegate initialized:isSuccess error:error];
+ }
+}
+
+#pragma mark - VungleSDKDelegate methods
+
+- (void)vungleWillShowAdForPlacementID:(nullable NSString *)placementID {
+ if ((playing & InterstitialAdapter) && _interstitialDelegate && [_interstitialDelegate respondsToSelector:@selector(willShowAd)]){
+ [_interstitialDelegate willShowAd];
+ }
+ if ((playing & RewardBasedAdapter) && _rewardDelegate && [_rewardDelegate respondsToSelector:@selector(willShowAd)]){
+ [_rewardDelegate willShowAd];
+ }
+}
+
+- (void)vungleWillCloseAdWithViewInfo:(nonnull VungleViewInfo *)info placementID:(nonnull NSString *)placementID {
+ if (playing & InterstitialAdapter){
+ playing &= ~InterstitialAdapter;
+ if (_interstitialDelegate && [_interstitialDelegate respondsToSelector:@selector(willCloseAd:)]){
+ [_interstitialDelegate willCloseAd:info.completedView];
+ }
+ }
+ if (playing & RewardBasedAdapter){
+ playing &= ~RewardBasedAdapter;
+ if (_rewardDelegate && [_rewardDelegate respondsToSelector:@selector(willCloseAd:)]){
+ [_rewardDelegate willCloseAd:info.completedView];
+ }
+ }
+}
+
+- (void)vungleAdPlayabilityUpdate:(BOOL)isAdPlayable placementID:(nullable NSString *)placementID {
+ if (isAdPlayable) {
+ if (waiting & InterstitialAdapter) {
+ if (_interstitialDelegate && [_interstitialDelegate respondsToSelector:@selector(desiredPlacement)]){
+ NSString* desired = [_interstitialDelegate desiredPlacement];
+ if (!desired || [desired isEqualToString:placementID]) {
+ waiting &= ~InterstitialAdapter;
+ if ([_interstitialDelegate respondsToSelector:@selector(adAvailable)]) {
+ [_interstitialDelegate adAvailable];
+ }
+ }
+ } else {
+ waiting &= ~InterstitialAdapter;
+ }
+ }
+ if (waiting & RewardBasedAdapter) {
+ if (_rewardDelegate && [_rewardDelegate respondsToSelector:@selector(desiredPlacement)]){
+ NSString* desired = [_rewardDelegate desiredPlacement];
+ if (!desired || [desired isEqualToString:placementID]) {
+ waiting &= ~RewardBasedAdapter;
+ if ([_rewardDelegate respondsToSelector:@selector(adAvailable)]) {
+ [_rewardDelegate adAvailable];
+ }
+ }
+ } else {
+ waiting &= ~RewardBasedAdapter;
+ }
+ }
+ }
+}
+
+- (void)vungleSDKDidInitialize {
+ [self initialized:true error:nil];
+}
+
+@end

Adding adapter files - Vungle