Skip to content

Commit

Permalink
add SDK Ver 6.36.3
Browse files Browse the repository at this point in the history
  • Loading branch information
FluctMember committed Aug 7, 2024
1 parent 4a6646f commit 18f2e4c
Show file tree
Hide file tree
Showing 23 changed files with 218 additions and 304 deletions.
6 changes: 3 additions & 3 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.36.2"
s.version = "6.36.3"
s.author = "fluct,Inc."
s.requires_arc = true
s.static_framework = true
Expand Down Expand Up @@ -38,8 +38,8 @@ Pod::Spec.new do |s|
s.subspec "maio" do |ss|
ss.source_files = "FluctSDK-MediationAdapter/maio/*.{h,m}"
ss.dependency "FluctSDK", ">=6.14.0"
ss.dependency "MaioSDK", '=1.6.5'
ss.ios.deployment_target = "11.0"
ss.dependency "MaioSDK-v2", '=2.1.5'
ss.ios.deployment_target = "14.0"
end

s.subspec "UnityAds" do |ss|
Expand Down
35 changes: 35 additions & 0 deletions FluctSDK-MediationAdapter/maio/FSSMaio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// FSSMaio.h
// FluctSDK
//
// Copyright © 2024 fluct, Inc. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <Maio/Maio.h>

NS_ASSUME_NONNULL_BEGIN

@protocol FSSMaioProtocol

- (void)load:(NSString *)zoneId
testMode:(BOOL)testMode
loadCallback:(nullable id<MaioRewardedLoadCallback>)loadCallback;

- (void)show:(UIViewController *)viewController
showCallback:(nullable id<MaioRewardedShowCallback>)showCallback;

@end

@interface FSSMaio : NSObject <FSSMaioProtocol>

- (void)load:(NSString *)zoneId
testMode:(BOOL)testMode
loadCallback:(nullable id<MaioRewardedLoadCallback>)loadCallback;

- (void)show:(UIViewController *)viewController
showCallback:(nullable id<MaioRewardedShowCallback>)showCallback;

@end

NS_ASSUME_NONNULL_END
29 changes: 29 additions & 0 deletions FluctSDK-MediationAdapter/maio/FSSMaio.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// FSSMaio.m
// FluctSDK
//
// Copyright © 2024 fluct, Inc. All rights reserved.
//

#import "FSSMaio.h"

@interface FSSMaio () <FSSMaioProtocol, MaioRewardedLoadCallback>

@property (nonatomic) MaioRewarded *rewardedVideo;
@end

@implementation FSSMaio

- (void)load:(NSString *)zoneId
testMode:(BOOL)testMode
loadCallback:(nullable id<MaioRewardedLoadCallback>)loadCallback {
MaioRequest *maioRequest = [[MaioRequest alloc] initWithZoneId:zoneId testMode:testMode];
self.rewardedVideo = [MaioRewarded loadAdWithRequest:maioRequest callback:loadCallback];
}

- (void)show:(UIViewController *)viewController
showCallback:(nullable id<MaioRewardedShowCallback>)showCallback {
[self.rewardedVideo showWithViewContext:viewController callback:showCallback];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// Copyright © 2017年 fluct, Inc. All rights reserved.
//

#import "FSSRewardedVideoMaioManager.h"
#import "FSSMaio.h"
#import <FluctSDK/FluctSDK.h>

@interface FSSRewardedVideoCustomEventMaio : FSSRewardedVideoCustomEvent <FSSRewardedVideoMaioManagerDelegate>
@interface FSSRewardedVideoCustomEventMaio : FSSRewardedVideoCustomEvent <MaioRewardedLoadCallback, MaioRewardedShowCallback>

@end
212 changes: 100 additions & 112 deletions FluctSDK-MediationAdapter/maio/FSSRewardedVideoCustomEventMaio.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@

@interface FSSRewardedVideoCustomEventMaio ()

@property (nonatomic) id<FSSMaioProtocol> maio;
@property (nonatomic, copy) NSString *zoneID;
@property (nonatomic) BOOL isInitialNotificationForAdapter;
@end

static NSString *const FSSMaioSupportVersion = @"14.0";

@implementation FSSRewardedVideoCustomEventMaio

- (instancetype)initWithDictionary:(NSDictionary *)dictionary
Expand All @@ -22,6 +24,27 @@ - (instancetype)initWithDictionary:(NSDictionary *)dictionary
skippable:(BOOL)skippable
targeting:(FSSAdRequestTargeting *)targeting
setting:(id<FSSFullscreenVideoSetting>)setting {
if (![FSSRewardedVideoCustomEventMaio isOSAtLeastVersion:FSSMaioSupportVersion]) {
return nil;
}
return [self initWithDictionary:dictionary
delegate:delegate
testMode:testMode
debugMode:debugMode
skippable:skippable
targeting:nil
setting:setting
maio:[FSSMaio new]];
}

- (instancetype)initWithDictionary:(NSDictionary *)dictionary
delegate:(id<FSSRewardedVideoCustomEventDelegate>)delegate
testMode:(BOOL)testMode
debugMode:(BOOL)debugMode
skippable:(BOOL)skippable
targeting:(FSSAdRequestTargeting *)targeting
setting:(id<FSSFullscreenVideoSetting>)setting
maio:(id<FSSMaioProtocol>)maio {
self = [super initWithDictionary:dictionary
delegate:delegate
testMode:testMode
Expand All @@ -34,160 +57,125 @@ - (instancetype)initWithDictionary:(NSDictionary *)dictionary
return nil;
}
_zoneID = dictionary[@"zone_id"];
_isInitialNotificationForAdapter = YES;
_maio = maio;
return self;
}

- (void)loadRewardedVideoWithDictionary:(NSDictionary *)dictionary {
self.adnwStatus = FSSRewardedVideoADNWStatusLoading;
[[FSSRewardedVideoMaioManager sharedInstance] loadRewardedVideoWithDictionary:dictionary
delegate:self
testMode:self.testMode];
[self.maio load:self.zoneID testMode:self.testMode loadCallback:self];
}

- (FSSRewardedVideoADNWStatus)loadStatus {
return self.adnwStatus;
}

- (void)presentRewardedVideoAdFromViewController:(UIViewController *)viewController {
[[FSSRewardedVideoMaioManager sharedInstance] presentRewardedVideoAdFromViewController:viewController
zoneId:self.zoneID];
[self.maio show:viewController showCallback:self];
}

- (NSString *)sdkVersion {
return [Maio sdkVersion];
return [[MaioVersion shared] toString];
}

#pragma mark FSSRewardedVideoMaioManagerDelegate
- (void)maioDidChangeCanShow:(NSString *)zoneId newValue:(BOOL)newValue {
__weak __typeof(self) weakSelf = self;
#pragma mark MaioRewardedLoadCallback

- (void)didLoad:(MaioRewarded *_Nonnull)ad {
__weak __typeof(self) weakSelf = self;
dispatch_async(FSSWorkQueue(), ^{
if (self.isInitialNotificationForAdapter) {
weakSelf.isInitialNotificationForAdapter = NO;
weakSelf.adnwStatus = FSSRewardedVideoADNWStatusLoaded;
[weakSelf.delegate rewardedVideoDidLoadForCustomEvent:weakSelf];
}
weakSelf.adnwStatus = FSSRewardedVideoADNWStatusLoaded;
[weakSelf.delegate rewardedVideoDidLoadForCustomEvent:weakSelf];
});
}

- (void)maioWillStartAd:(NSString *)zoneId {
- (void)didFail:(MaioRewarded *_Nonnull)ad errorCode:(NSInteger)errorCode {
__weak __typeof(self) weakSelf = self;
dispatch_async(FSSWorkQueue(), ^{
[weakSelf.delegate rewardedVideoWillAppearForCustomEvent:weakSelf];
[weakSelf.delegate rewardedVideoDidAppearForCustomEvent:weakSelf];
switch ([FSSRewardedVideoCustomEventMaio mapErrorCode:errorCode]) {
case FSSVideoErrorLoadFailed:
weakSelf.adnwStatus = FSSRewardedVideoADNWStatusNotDisplayable;
[weakSelf.delegate rewardedVideoDidFailToLoadForCustomEvent:weakSelf
fluctError:[NSError errorWithDomain:FSSVideoErrorSDKDomain
code:FSSVideoErrorLoadFailed
userInfo:nil]
adnetworkError:[NSError errorWithDomain:FSSVideoErrorSDKDomain
code:errorCode
userInfo:@{NSLocalizedDescriptionKey : @"didFail load."}]];
break;
case FSSVideoErrorPlayFailed:
weakSelf.adnwStatus = FSSRewardedVideoADNWStatusNotDisplayable;
[weakSelf.delegate rewardedVideoDidFailToPlayForCustomEvent:weakSelf
fluctError:[NSError errorWithDomain:FSSVideoErrorSDKDomain
code:FSSVideoErrorPlayFailed
userInfo:nil]
adnetworkError:[NSError errorWithDomain:FSSVideoErrorSDKDomain
code:errorCode
userInfo:@{NSLocalizedDescriptionKey : @"didFail show."}]];
break;
default:
// https://github.com/imobile/MaioSDK-v2-iOS/wiki/API-Rererences#optional-func-didfail_-admaiorewarded-errorcode-int
// maioSDKはロード失敗、再生失敗で呼ばれるデリゲートが同じため、adnwStatusでロード前: ロード失敗、ロード後: 再生失敗と分けています。ただし、defaultに入ってくるのはunknownエラーのみなので、分けておく大きな意味はありません。
if (weakSelf.adnwStatus == FSSRewardedVideoADNWStatusLoaded) {
weakSelf.adnwStatus = FSSRewardedVideoADNWStatusNotDisplayable;
[weakSelf.delegate rewardedVideoDidFailToPlayForCustomEvent:weakSelf
fluctError:[NSError errorWithDomain:FSSVideoErrorSDKDomain
code:FSSVideoErrorUnknown
userInfo:nil]
adnetworkError:[NSError errorWithDomain:FSSVideoErrorSDKDomain
code:errorCode
userInfo:@{NSLocalizedDescriptionKey : @"didFail unknown."}]];
} else {
weakSelf.adnwStatus = FSSRewardedVideoADNWStatusNotDisplayable;
[weakSelf.delegate rewardedVideoDidFailToLoadForCustomEvent:weakSelf
fluctError:[NSError errorWithDomain:FSSVideoErrorSDKDomain
code:FSSVideoErrorUnknown
userInfo:nil]
adnetworkError:[NSError errorWithDomain:FSSVideoErrorSDKDomain
code:errorCode
userInfo:@{NSLocalizedDescriptionKey : @"didFail unknown."}]];
}
break;
}
});
}

- (void)maioDidFinishAd:(NSString *)zoneId playtime:(NSInteger)playtime skipped:(BOOL)skipped rewardParam:(NSString *)rewardParam {
__weak __typeof(self) weakSelf = self;
dispatch_async(FSSWorkQueue(), ^{
[weakSelf.delegate rewardedVideoShouldRewardForCustomEvent:weakSelf];
});
+ (FSSVideoError)mapErrorCode:(NSInteger)maioErrorCode {
// https://github.com/imobile/MaioSDK-v2-iOS/wiki/API-Rererences#errorcode
NSString *numberString = [NSString stringWithFormat:@"%ld", (long)maioErrorCode];
unichar firstCharacter = [numberString characterAtIndex:0];

if (firstCharacter == '1') {
return FSSVideoErrorLoadFailed;
}

if (firstCharacter == '2') {
return FSSVideoErrorPlayFailed;
}
return FSSVideoErrorUnknown;
}

- (void)maioDidClickAd:(NSString *)zoneId {
#pragma mark MaioRewardedShowCallback

- (void)didOpen:(MaioRewarded *_Nonnull)ad {
__weak __typeof(self) weakSelf = self;
dispatch_async(FSSWorkQueue(), ^{
[weakSelf.delegate rewardedVideoDidClickForCustomEvent:self];
[weakSelf.delegate rewardedVideoWillAppearForCustomEvent:weakSelf];
[weakSelf.delegate rewardedVideoDidAppearForCustomEvent:weakSelf];
});
}

- (void)maioDidCloseAd:(NSString *)zoneId {
- (void)didClose:(MaioRewarded *_Nonnull)ad {
__weak __typeof(self) weakSelf = self;
dispatch_async(FSSWorkQueue(), ^{
[weakSelf.delegate rewardedVideoWillDisappearForCustomEvent:weakSelf];
[weakSelf.delegate rewardedVideoDidDisappearForCustomEvent:weakSelf];
});
}

- (void)maioDidFail:(NSString *)zoneId reason:(MaioFailReason)reason {
- (void)didReward:(MaioRewarded *_Nonnull)ad reward:(RewardData *_Nonnull)reward {
__weak __typeof(self) weakSelf = self;
dispatch_async(FSSWorkQueue(), ^{
weakSelf.adnwStatus = FSSRewardedVideoADNWStatusNotDisplayable;

NSError *adnwError = [self convertADNWErrorFromFailReason:reason];

// error after initialization
if (reason == MaioFailReasonVideoPlayback) {
[weakSelf.delegate rewardedVideoDidFailToPlayForCustomEvent:weakSelf
fluctError:[NSError errorWithDomain:FSSVideoErrorSDKDomain
code:FSSVideoErrorPlayFailed
userInfo:nil]
adnetworkError:adnwError];
return;
}

// initialization error
if (weakSelf.isInitialNotificationForAdapter) {
weakSelf.isInitialNotificationForAdapter = NO;

switch (reason) {
case MaioFailReasonAdStockOut:
[weakSelf.delegate rewardedVideoDidFailToLoadForCustomEvent:weakSelf
fluctError:[NSError errorWithDomain:FSSVideoErrorSDKDomain
code:FSSVideoErrorNoAds
userInfo:nil]
adnetworkError:adnwError];
break;
case MaioFailReasonUnknown:
[weakSelf.delegate rewardedVideoDidFailToLoadForCustomEvent:weakSelf
fluctError:[NSError errorWithDomain:FSSVideoErrorSDKDomain
code:FSSVideoErrorUnknown
userInfo:nil]
adnetworkError:adnwError];
default:
[weakSelf.delegate rewardedVideoDidFailToLoadForCustomEvent:weakSelf
fluctError:[NSError errorWithDomain:FSSVideoErrorSDKDomain
code:FSSVideoErrorLoadFailed
userInfo:nil]
adnetworkError:adnwError];
break;
}
}
[weakSelf.delegate rewardedVideoShouldRewardForCustomEvent:weakSelf];
});
}

- (NSError *)convertADNWErrorFromFailReason:(MaioFailReason)failReason {
NSString *message = @"unkonw.";
switch (failReason) {
case MaioFailReasonUnknown:
message = @"unkonw.";
break;
case MaioFailReasonAdStockOut:
message = @"ad stock out.";
break;
case MaioFailReasonNetworkConnection:
message = @"network connection.";
break;
case MaioFailReasonNetworkClient:
message = @"network client.";
break;
case MaioFailReasonNetworkServer:
message = @"network server.";
break;
case MaioFailReasonSdk:
message = @"sdk.";
break;
case MaioFailReasonDownloadCancelled:
message = @"download cancelled.";
break;
case MaioFailReasonVideoPlayback:
message = @"video playback.";
break;
case MaioFailReasonIncorrectMediaId:
message = @"incorrect media id.";
break;
case MaioFailReasonIncorrectZoneId:
message = @"incorrect zone id.";
break;
case MaioFailReasonNotFoundViewContext:
message = @"not found view context.";
break;
}
return [NSError errorWithDomain:FSSVideoErrorSDKDomain
code:failReason
userInfo:@{NSLocalizedDescriptionKey : message}];
}

@end
Loading

0 comments on commit 18f2e4c

Please sign in to comment.