Skip to content

Commit

Permalink
add SDK Ver 6.20.8
Browse files Browse the repository at this point in the history
  • Loading branch information
FluctMember committed Jan 6, 2023
1 parent 5432c81 commit 77a861d
Show file tree
Hide file tree
Showing 21 changed files with 507 additions and 203 deletions.
4 changes: 2 additions & 2 deletions FluctSDK-MediationAdapter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Pod::Spec.new do |s|
s.name = "FluctSDK-MediationAdapter"
s.summary = "Mediation Adapter for FluctSDK ad Framework"
s.license = { :type => "Copyright", :text => "Copyright (c) fluct,Inc. All rights reserved." }
s.version = "6.20.7"
s.version = "6.20.8"
s.author = "fluct,Inc."
s.requires_arc = true
s.static_framework = true
Expand Down Expand Up @@ -57,6 +57,6 @@ Pod::Spec.new do |s|
s.subspec "Pangle" do |ss|
ss.source_files = "FluctSDK-MediationAdapter/Pangle/*.{h,m}"
ss.dependency "FluctSDK", ">=6.14.0"
ss.dependency "Ads-Global", '>= 4.5.2.7'
ss.dependency "Ads-Global", '>= 4.8.1.0'
end
end
33 changes: 33 additions & 0 deletions FluctSDK-MediationAdapter/Pangle/FSSPangle.h
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
30 changes: 30 additions & 0 deletions FluctSDK-MediationAdapter/Pangle/FSSPangle.m
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
28 changes: 28 additions & 0 deletions FluctSDK-MediationAdapter/Pangle/FSSPangleLoadManager.h
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 FluctSDK-MediationAdapter/Pangle/FSSPangleLoadManager.m
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
Loading

0 comments on commit 77a861d

Please sign in to comment.