Skip to content

Commit

Permalink
Release 4.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
runner authored and runner committed Sep 28, 2023
1 parent 737812a commit fa01420
Show file tree
Hide file tree
Showing 96 changed files with 1,340 additions and 1,023 deletions.
28 changes: 17 additions & 11 deletions SourceCode/Private/Ads/Api/UADSApiGMAScar/UADSApiGMAScar.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ + (void)WebViewExposed_isAvailable: (USRVWebViewCallback *)callback {
[callback invoke: [NSNumber numberWithBool: present], nil];
}

+ (void)WebViewExposed_getSCARSignals: (NSArray *)interstitialPlacements
rewardedPlacements: (NSArray *)rewardedPlacements
callback: (USRVWebViewCallback *)callback {
+(void)WebViewExposed_getSCARSignal: (NSString *)placementId
adFormat: (NSString *)adFormat
callback: (USRVWebViewCallback *)callback {
id success = ^(NSString *_Nullable signals) {
GMAWebViewEvent *event = [GMAWebViewEvent newSignalsEvent: signals];
[self sendEvent: event];
Expand All @@ -47,14 +47,10 @@ + (void)WebViewExposed_getSCARSignals: (NSArray *)interstitialPlacements
[self.errorHandler catchError: error];
};

UADSGMAEncodedSignalsCompletion *completion = [UADSGMAEncodedSignalsCompletion newWithSuccess: success
andError: error];

[self.facade getSCARSignalsUsingInterstitialList: interstitialPlacements
andRewardedList: rewardedPlacements
completion: completion];

[callback invoke: nil];
UADSGMAEncodedSignalsCompletion *completion = [UADSGMAEncodedSignalsCompletion newWithSuccess: success andError: error];
UADSScarSignalParameters *params = [[UADSScarSignalParameters alloc] initWithPlacementId:placementId adFormat: [self getInfoAdTypeFrom:adFormat]];
[self.facade getSCARSignals: @[ params ]
completion: completion];
}

+ (void)WebViewExposed_load: (NSString *)placementId
Expand Down Expand Up @@ -135,4 +131,14 @@ + (void)sendAvailabilityMetrics {
}
}

+ (GADQueryInfoAdType)getInfoAdTypeFrom: (NSString *)adFormat {
if ([adFormat isEqualToString: @"interstitial"]) {
return GADQueryInfoAdTypeInterstitial;
}
if ([adFormat isEqualToString: @"rewarded"]) {
return GADQueryInfoAdTypeRewarded;
}
return GADQueryInfoAdTypeBanner;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,41 @@ - (void)didFailWithError:(UADSInternalError * _Nonnull)error forPlacementID:(NSS

- (void)bannerViewDidLoad: (UADSBannerView *)bannerView {
dispatch_on_main( ^{
[self.decorated bannerViewDidLoad: self.bannerView];
if ([self.decorated respondsToSelector: @selector(bannerViewDidLoad:)]) {
[self.decorated bannerViewDidLoad: self.bannerView];
}
});
}

- (void)bannerViewDidShow:(UADSBannerView *)bannerView {
dispatch_on_main( ^{
[self.decorated bannerViewDidShow: self.bannerView];
if ([self.decorated respondsToSelector: @selector(bannerViewDidShow:)]) {
[self.decorated bannerViewDidShow: self.bannerView];
}
});
}

- (void)bannerViewDidClick: (UADSBannerView *)bannerView {
dispatch_on_main( ^{
[self.decorated bannerViewDidClick: self.bannerView];
if ([self.decorated respondsToSelector: @selector(bannerViewDidClick:)]) {
[self.decorated bannerViewDidClick: self.bannerView];
}
});
}

- (void)bannerViewDidLeaveApplication: (UADSBannerView *)bannerView {
dispatch_on_main( ^{
[self.decorated bannerViewDidLeaveApplication: self.bannerView];
if ([self.decorated respondsToSelector: @selector(bannerViewDidLeaveApplication:)]) {
[self.decorated bannerViewDidLeaveApplication: self.bannerView];
}
});
}

- (void)bannerViewDidError: (UADSBannerView *)bannerView error: (UADSBannerError *)error {
dispatch_on_main( ^{
[self.decorated bannerViewDidError: self.bannerView error: error];
if ([self.decorated respondsToSelector: @selector(bannerViewDidError:error:)]) {
[self.decorated bannerViewDidError: self.bannerView error: error];
}
});
}

Expand Down
63 changes: 63 additions & 0 deletions SourceCode/Private/Banners/Api/UADSApiBanner.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
#import "UADSBannerRefreshInfo.h"
#import "UADSBannerWebPlayerContainerType.h"
#import "UADSBannerLoadModule.h"
#import "UADSGMAScar.h"
#import "GADBannerViewBridge.h"
#import "GMABannerWebViewEvent.h"
#import "UADSGADBannerWrapper.h"
#import "UIViewController+TopController.h"
#import "UADSTools.h"

@implementation UADSApiBanner

Expand Down Expand Up @@ -70,4 +76,61 @@ + (void)WebViewExposed_setRefreshRate: (NSString *)placementId refreshRate: (NSN
[callback invoke: nil];
}

+ (void)WebViewExposed_loadScar: (NSString *)bannerAd
placementId: (NSString *)placementId
queryId: (NSString *)queryId
adUnitId: (NSString *)adUnitId
adString: (NSString *)adString
width: (NSNumber *)width
height: (NSNumber *)height
callback: (USRVWebViewCallback *)callback {

UADSBannerView *bannerView = [[UADSBannerLoadModule sharedInstance] bannerViewWithID:bannerAd];
if (!bannerView) {
return;
}

CGSize bannerSize = CGSizeMake(width.floatValue, height.floatValue);
GMAAdMetaData *data = [GMAAdMetaData new];
data.type = GADQueryInfoAdTypeBanner;
data.placementID = placementId;
data.adString = adString;
data.adUnitID = adUnitId;
data.queryID = queryId;
data.bannerAdId = bannerAd;
data.bannerSize = bannerSize;

UADSGADBannerWrapper *wrapper = [UADSGADBannerWrapper newWithMeta: data
eventSender: self.eventSender
gmaScar: UADSGMAScar.sharedInstance];

data.beforeLoad = ^(GADBaseAd *_Nullable ad) {
wrapper.gadBanner = (GADBannerViewBridge *)ad;
dispatch_on_main_sync(^{
[wrapper addToBannerView:bannerView withSize:bannerSize];
});
};

id successHandler = ^(GADBaseAd *_Nullable ad) {
[self.eventSender sendEvent: [GMABannerWebViewEvent newBannerLoadedWithMeta: data]];
};

id errorHandler = ^(id<UADSError> _Nonnull error) {
[self.eventSender sendEvent: [GMABannerWebViewEvent newBannerLoadFailedWithMeta: data]];
dispatch_on_main_sync(^{
[wrapper removeFromSuperview]; // remove from UADSBannerView
});
};

UADSLoadAdCompletion *completion = [UADSLoadAdCompletion newWithSuccess: successHandler
andError: errorHandler];

[[UADSGMAScar sharedInstance] loadAdUsingMetaData:data andCompletion:completion];
[callback invoke: nil];
}

+ (id<UADSWebViewEventSender>)eventSender {
return [UADSWebViewEventSenderBase new];
}

@end
19 changes: 19 additions & 0 deletions SourceCode/Private/Banners/GMAScar/UADSGADBannerWrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#import <UIKit/UIKit.h>
#import "UADSBannerView.h"
#import "GADBannerViewBridge.h"
#import "UADSWebViewEventSender.h"
#import "GMAAdMetaData.h"
#import "UADSGMAScar.h"

NS_ASSUME_NONNULL_BEGIN

@interface UADSGADBannerWrapper : UIView
@property (nonatomic, strong) GADBannerViewBridge *gadBanner;

+ (instancetype)newWithMeta: (GMAAdMetaData *)meta eventSender: (id<UADSWebViewEventSender>)eventSender gmaScar:(UADSGMAScar*)gmaScar;
- (void)addToBannerView: (UADSBannerView *)bannerView withSize: (CGSize)size;
- (void)updateGADBannerRootViewController;

@end

NS_ASSUME_NONNULL_END
69 changes: 69 additions & 0 deletions SourceCode/Private/Banners/GMAScar/UADSGADBannerWrapper.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#import <UIKit/UIKit.h>
#import "UIView+Subview.h"
#import "UADSGADBannerWrapper.h"
#import "UIViewController+TopController.h"
#import "UIView+ParentViewController.h"
#import "GMABannerWebViewEvent.h"

@interface UADSGADBannerWrapper()
@property (nonatomic, strong) id<UADSWebViewEventSender> eventSender;
@property (nonatomic, strong) GMAAdMetaData *meta;
@property (nonatomic, strong) UADSGMAScar *gmaScar;
@end

@implementation UADSGADBannerWrapper

+ (instancetype)newWithMeta: (GMAAdMetaData *)meta eventSender: (id<UADSWebViewEventSender>)eventSender gmaScar:(UADSGMAScar*)gmaScar {
UADSGADBannerWrapper *wrapper = [UADSGADBannerWrapper new];
wrapper.meta = meta;
wrapper.eventSender = eventSender;
wrapper.gmaScar = gmaScar;
return wrapper;
}

- (void)addToBannerView: (UADSBannerView *)bannerView withSize: (CGSize)size {
[bannerView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
[bannerView addSubview:self withSize:size];

UIView *gBannerView = self.gadBannerView;
[self addSubview:gBannerView withSize:size];

[self updateGADBannerRootViewController];
}

- (void)updateGADBannerRootViewController {
[self.gadBanner setRootViewController: self.bannerRootViewController];
}

- (UIViewController *)bannerRootViewController {
return [self parentViewController] ?: [UIViewController uads_getTopController];
}

- (UIView *)gadBannerView {
return (UIView *)self.gadBanner.proxyObject;
}

- (void)willMoveToSuperview:(UIView *)newSuperview {
if (newSuperview == nil) {
[self.gmaScar removeAdForPlacement: self.meta.placementID];
}
}

- (void)willMoveToWindow:(UIWindow *)newWindow {
if (newWindow) {
[self updateGADBannerRootViewController];
[self sendAttachedEvent];
} else {
[self sendDettachedEvent];
}
}

- (void)sendAttachedEvent {
[self.eventSender sendEvent:[GMABannerWebViewEvent newBannerAttachedWithMeta: self.meta]];
}

- (void)sendDettachedEvent {
[self.eventSender sendEvent:[GMABannerWebViewEvent newBannerDetachedWithMeta: self.meta]];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -165,31 +165,4 @@ - (NSString *)getCurrentScarHBURL {
return scarURL ?: kDefaultScarURL;
}

- (UADSSCARHBStrategyType) selectedSCARHBStrategyType {
USRVConfiguration *config = [ self getCurrentConfiguration];
if (!config.experiments.json) {
return UADSSCARHeaderBiddingStrategyTypeDisabled;
}
NSDictionary* strategyDictionary = config.experiments.json[@"scar_bm"];
if (![strategyDictionary isKindOfClass:[NSDictionary class]]) {
return UADSSCARHeaderBiddingStrategyTypeDisabled;
}
NSString* strategyValue = strategyDictionary[@"value"];
return [self selectedStrategyTypeForString:strategyValue];
}

- (UADSSCARHBStrategyType) selectedStrategyTypeForString:(NSString*)stringValue {
if ([stringValue isEqualToString:@"eag"]) {
return UADSSCARHeaderBiddingStrategyTypeEager;
}
if ([stringValue isEqualToString:@"laz"]) {
return UADSSCARHeaderBiddingStrategyTypeLazy;
}
if ([stringValue isEqualToString:@"hyb"]) {
return UADSSCARHeaderBiddingStrategyTypeHybrid;
}
return UADSSCARHeaderBiddingStrategyTypeDisabled;
}


@end
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ NS_ASSUME_NONNULL_BEGIN
@property (readonly) NSDictionary<NSString *, NSDictionary *> *json;
+ (instancetype)newWithJSON: (NSDictionary<NSString *, NSDictionary *> *)json;

- (BOOL) isSwiftDownloadEnabled;
- (BOOL) isSwiftNativeRequestsEnabled;
- (BOOL) isSwiftWebViewRequestsEnabled;
- (BOOL) isSwiftInitFlowEnabled;
- (BOOL) isUseNewTasksEnabled;
- (BOOL) isParallelExecutionEnabled;
- (BOOL) isPrivacyWaitEnabled;
- (BOOL) isNativeWebViewCacheEnabled;
- (BOOL) isWebAdAssetCacheEnabled;
- (BOOL) isSwiftTokenEnabled;
- (BOOL) isOrientationSafeguardEnabled;
- (BOOL) isSwiftDownloadEnabled;
- (BOOL) isSwiftNativeRequestsEnabled;
- (BOOL) isSwiftWebViewRequestsEnabled;
- (BOOL) isSwiftInitFlowEnabled;
- (BOOL) isUseNewTasksEnabled;
- (BOOL) isParallelExecutionEnabled;
- (BOOL) isPrivacyWaitEnabled;
- (BOOL) isNativeWebViewCacheEnabled;
- (BOOL) isWebAdAssetCacheEnabled;
- (BOOL) isSwiftTokenEnabled;
- (BOOL) isOrientationSafeguardEnabled;
- (BOOL) isScarBannerSignalsEnabled;

- (NSDictionary<NSString *, NSString *> *)nextSessionFlags;
- (NSDictionary<NSString *, NSString *> *)currentSessionFlags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ - (BOOL)isOrientationSafeguardEnabled {
return [self isExperimentEnabledWithKey: @"osg"];
}

- (BOOL) isScarBannerSignalsEnabled {
return [self isExperimentEnabledWithKey: @"scar_bn"];
}

- (NSDictionary<NSString *, NSString *> *)nextSessionFlags {
return [self flattenFlagsWith:^BOOL (id key) {
return [self isExperimentForNextSession: key];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, strong) id<IUSRVWebRequestFactory> requestFactory;
@property (nonatomic, strong) id<GMASCARSignalService> signalService;
@property (nonatomic, weak) id<USRVStringCompressor> compressor;
@property (nonatomic, strong) id<UADSSCARHeaderBiddingStrategyFactory> strategyFactory;
@property (nonatomic, strong) id<UADSDeviceIDFIReader> idfiReader;
@property (nonatomic, strong) id<UADSConfigurationReader> configurationReader;
@property (nonatomic, strong) id<ISDKMetrics> metricsSender;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#import "UADSHeaderBiddingTokenReaderSCARSignalsConfig.h"
#import "UADSSCARHeaderBiddingFetchSendStrategyFactory.h"
#import "UADSSCARHeaderBiddingStrategyFactory.h"

@implementation UADSHeaderBiddingTokenReaderSCARSignalsConfig

-(instancetype) init {
SUPER_INIT;
UADSSCARHeaderBiddingFetchSendStrategyFactory* strategyFactory = [UADSSCARHeaderBiddingFetchSendStrategyFactory new];
strategyFactory.config = self;
self.strategyFactory = strategyFactory;
self.idfiReader = [UADSDeviceIDFIReaderBase new];
self.timestampReader = [UADSCurrentTimestampBase new];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "UADSHeaderBiddingTokenReaderWithSCARSignals.h"
#import "UADSServiceProvider.h"
#import "UADSSCARHeaderBiddingFetchSendStrategyFactory.h"
#import "UADSHeaderBiddingTokenReaderWithSCARSignalsEagerStrategy.h"

@interface UADSHeaderBiddingTokenReaderWithSCARSignals ()
@property (nonatomic, strong) id<UADSHeaderBiddingAsyncTokenReader, UADSHeaderBiddingTokenCRUD> original;
Expand All @@ -18,7 +18,7 @@ + (instancetype)decorateOriginal: (id<UADSHeaderBiddingAsyncTokenReader, UADSHea
}

-(id<UADSHeaderBiddingAsyncTokenReader, UADSHeaderBiddingTokenCRUD>)strategy {
return [self.config.strategyFactory strategyWithOriginal:self.original];
return [UADSHeaderBiddingTokenReaderWithSCARSignalsEagerStrategy decorateOriginal:self.original config:self.config];
}

- (void)getToken:(nonnull UADSHeaderBiddingTokenCompletion)completion {
Expand Down

This file was deleted.

Loading

0 comments on commit fa01420

Please sign in to comment.