-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5432c81
commit 77a861d
Showing
21 changed files
with
507 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// FSSPangle.h | ||
// FluctSDKApp | ||
// | ||
// Copyright © 2022 fluct, Inc. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <PAGAdSDK/PAGAdSDK.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@protocol FSSPangleProtocol <NSObject> | ||
|
||
- (void)startWithAppId:(NSString *)appId | ||
debug:(BOOL)debugMode | ||
completionHandler:(nullable PAGAdsCompletionHandler)completionHandler; | ||
- (void)loadAdWithSlotID:(NSString *)slotID | ||
completionHandler:(PAGRewardedAdLoadCompletionHandler)completionHandler; | ||
|
||
@end | ||
|
||
@interface FSSPangle : NSObject <FSSPangleProtocol> | ||
|
||
- (void)startWithAppId:(NSString *)appId | ||
debug:(BOOL)debugMode | ||
completionHandler:(nullable PAGAdsCompletionHandler)completionHandler; | ||
- (void)loadAdWithSlotID:(NSString *)slotID | ||
completionHandler:(PAGRewardedAdLoadCompletionHandler)completionHandler; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// FSSPangle.m | ||
// FluctSDKApp | ||
// | ||
// Copyright © 2022 fluct, Inc. All rights reserved. | ||
// | ||
|
||
#import "FSSPangle.h" | ||
|
||
@implementation FSSPangle | ||
|
||
- (void)startWithAppId:(NSString *)appId | ||
debug:(BOOL)debugMode | ||
completionHandler:(nullable PAGAdsCompletionHandler)completionHandler { | ||
PAGConfig *config = [PAGConfig shareConfig]; | ||
config.appID = appId; | ||
config.debugLog = debugMode; | ||
[PAGSdk startWithConfig:config | ||
completionHandler:completionHandler]; | ||
} | ||
|
||
- (void)loadAdWithSlotID:(NSString *)slotID | ||
completionHandler:(PAGRewardedAdLoadCompletionHandler)completionHandler { | ||
PAGRewardedRequest *request = [PAGRewardedRequest request]; | ||
[PAGRewardedAd loadAdWithSlotID:slotID | ||
request:request | ||
completionHandler:completionHandler]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// FSSPangleLoadManager.h | ||
// FluctSDKApp | ||
// | ||
// Copyright © 2022 fluct, Inc. All rights reserved. | ||
// | ||
|
||
#import <FluctSDK/FluctSDK.h> | ||
#import <PAGAdSDK/PAGAdSDK.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@protocol FSSPangleLoadManagerDelegate | ||
- (void)pangleFailedToInitializeWithFluctError:(NSError *)fluctError | ||
adnetworkError:(NSError *)adnetworkError; | ||
- (void)pangleRewardedAdDidLoad:(PAGRewardedAd *)rewardedAd; | ||
- (void)pangleRewardedAdFailedToLoad:(NSError *)error; | ||
@end | ||
|
||
@interface FSSPangleLoadManager : NSObject | ||
+ (instancetype)sharedInstance; | ||
- (void)loadWithAppId:(NSString *)AppId | ||
debugMode:(BOOL)debugMode | ||
slotId:(NSString *)slotId | ||
delegate:(id<FSSPangleLoadManagerDelegate>)delegate; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
138 changes: 138 additions & 0 deletions
138
FluctSDK-MediationAdapter/Pangle/FSSPangleLoadManager.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
// | ||
// FSSPangleLoadManager.m | ||
// FluctSDKApp | ||
// | ||
// Copyright © 2022 fluct, Inc. All rights reserved. | ||
// | ||
|
||
#import "FSSPangleLoadManager.h" | ||
#import "FSSPangle.h" | ||
|
||
typedef NS_ENUM(NSUInteger, FSSPangleInitilizationStatus) { | ||
FSSPangleNotInitilized, | ||
FSSPangleInitilizing, | ||
FSSPangleInitilized, | ||
FSSPangleInitilizationFailed, | ||
}; | ||
|
||
@interface FSSPangleSlotDelegate : NSObject | ||
|
||
@property (nonatomic) NSString *slotId; | ||
@property (nonatomic) id<FSSPangleLoadManagerDelegate> delegate; | ||
|
||
@end | ||
|
||
@implementation FSSPangleSlotDelegate | ||
|
||
- (instancetype)initWithSlotId:(NSString *)slotId | ||
delegate:(id<FSSPangleLoadManagerDelegate>)delegate { | ||
self = [super init]; | ||
if (self) { | ||
self.slotId = slotId; | ||
self.delegate = delegate; | ||
} | ||
return self; | ||
} | ||
|
||
@end | ||
|
||
@interface FSSPangleLoadManager () | ||
|
||
@property (nonatomic) FSSPangle *pangle; | ||
@property (nonatomic) FSSPangleInitilizationStatus initilizationStatus; | ||
@property (nonatomic) NSMutableArray<FSSPangleSlotDelegate *> *slotDelegateArray; | ||
@property (nonatomic) NSError *initilizationFluctError; | ||
@property (nonatomic) NSError *initilizationAdnetworkError; | ||
|
||
@end | ||
|
||
@implementation FSSPangleLoadManager | ||
|
||
+ (instancetype)sharedInstance { | ||
static FSSPangleLoadManager *sharedInstance; | ||
static dispatch_once_t onceToken; | ||
dispatch_once(&onceToken, ^{ | ||
sharedInstance = [[self alloc] initWithPangle:[FSSPangle new]]; | ||
}); | ||
|
||
return sharedInstance; | ||
} | ||
|
||
- (instancetype)initWithPangle:(id<FSSPangleProtocol>)pangle { | ||
self = [super init]; | ||
if (self) { | ||
_pangle = pangle; | ||
_initilizationStatus = FSSPangleNotInitilized; | ||
_slotDelegateArray = [NSMutableArray new]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)startWithAppId:(NSString *)appId | ||
debug:(BOOL)debugMode { | ||
self.initilizationStatus = FSSPangleInitilizing; | ||
__weak __typeof(self) weakSelf = self; | ||
[self.pangle startWithAppId:appId | ||
debug:debugMode | ||
completionHandler:^(BOOL success, NSError *_Nonnull error) { | ||
if (success) { | ||
[weakSelf initializationComplete]; | ||
} else { | ||
[weakSelf initializationFailed:error]; | ||
} | ||
}]; | ||
} | ||
|
||
- (void)loadWithAppId:(NSString *)AppId | ||
debugMode:(BOOL)debugMode | ||
slotId:(NSString *)slotId | ||
delegate:(id<FSSPangleLoadManagerDelegate>)delegate { | ||
if (self.initilizationStatus == FSSPangleNotInitilized) { | ||
self.initilizationStatus = FSSPangleInitilizing; | ||
[self.slotDelegateArray addObject:[[FSSPangleSlotDelegate alloc] initWithSlotId:slotId delegate:delegate]]; | ||
[self startWithAppId:AppId debug:debugMode]; | ||
} else if (self.initilizationStatus == FSSPangleInitilizing) { | ||
[self.slotDelegateArray addObject:[[FSSPangleSlotDelegate alloc] initWithSlotId:slotId delegate:delegate]]; | ||
} else if (self.initilizationStatus == FSSPangleInitilized) { | ||
[self.slotDelegateArray addObject:[[FSSPangleSlotDelegate alloc] initWithSlotId:slotId delegate:delegate]]; | ||
[self load]; | ||
} else { | ||
[delegate pangleFailedToInitializeWithFluctError:self.initilizationFluctError | ||
adnetworkError:self.initilizationAdnetworkError]; | ||
} | ||
} | ||
|
||
- (void)initializationComplete { | ||
self.initilizationStatus = FSSPangleInitilized; | ||
[self load]; | ||
} | ||
|
||
- (void)initializationFailed:(NSError *)error { | ||
self.initilizationStatus = FSSPangleInitilizationFailed; | ||
self.initilizationAdnetworkError = error; | ||
self.initilizationFluctError = [NSError errorWithDomain:FSSVideoErrorSDKDomain | ||
code:FSSVideoErrorInitializeFailed | ||
userInfo:@{NSLocalizedDescriptionKey : @"initialization failed"}]; | ||
|
||
[self.slotDelegateArray enumerateObjectsUsingBlock:^(FSSPangleSlotDelegate *_Nonnull obj, NSUInteger idx, BOOL *_Nonnull stop) { | ||
[obj.delegate pangleFailedToInitializeWithFluctError:self.initilizationFluctError | ||
adnetworkError:self.initilizationAdnetworkError]; | ||
}]; | ||
[self.slotDelegateArray removeAllObjects]; | ||
} | ||
|
||
- (void)load { | ||
[self.slotDelegateArray enumerateObjectsUsingBlock:^(FSSPangleSlotDelegate *_Nonnull obj, NSUInteger idx, BOOL *_Nonnull stop) { | ||
[self.pangle loadAdWithSlotID:obj.slotId | ||
completionHandler:^(PAGRewardedAd *_Nullable rewardedAd, NSError *_Nullable error) { | ||
if (error) { | ||
[obj.delegate pangleRewardedAdFailedToLoad:error]; | ||
return; | ||
} | ||
[obj.delegate pangleRewardedAdDidLoad:rewardedAd]; | ||
}]; | ||
}]; | ||
[self.slotDelegateArray removeAllObjects]; | ||
} | ||
|
||
@end |
Oops, something went wrong.