Skip to content

Commit 364a0f2

Browse files
runnerrunner
authored andcommitted
Release 4.6.0
1 parent 432c091 commit 364a0f2

File tree

306 files changed

+6973
-3432
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

306 files changed

+6973
-3432
lines changed

SourceCode/Private/Ads/Api/UADSApiToken.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#import "UADSApiToken.h"
22
#import "USRVWebViewCallback.h"
33
#import "UADSTokenStorage.h"
4-
#import "UADSServiceProvider.h"
4+
#import "UADSServiceProviderContainer.h"
55
#import "UADSWebViewEvent.h"
66

77
NSString *const kTokenEventName = @"TOKEN_NATIVE_DATA";
@@ -44,7 +44,7 @@ + (void)WebViewExposed_getNativeGeneratedToken: (USRVWebViewCallback *)callback
4444
}
4545

4646
+ (UADSServiceProvider *)serviceProvider {
47-
return UADSServiceProvider.sharedInstance;
47+
return UADSServiceProviderContainer.sharedInstance.serviceProvider;
4848
}
4949

5050
+ (id<UADSWebViewEventSender>)webViewEventSender {

SourceCode/Private/Ads/Configuration/UADSAdsModuleConfiguration.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#import "UADSWebViewShowOperation.H"
33
#import "UADSTokenStorage.h"
44
#import "UADSAbstractModule.h"
5-
#import "UADSServiceProvider.h"
5+
#import "UADSServiceProviderContainer.h"
66
@implementation UADSAdsModuleConfiguration
77

88
- (NSArray<NSString *> *)getWebAppApiClassList {
@@ -20,7 +20,7 @@ @implementation UADSAdsModuleConfiguration
2020

2121
- (BOOL)resetState: (USRVConfiguration *)configuration {
2222
[self setConfigurationToRequiredModules: configuration];
23-
[UADSServiceProvider.sharedInstance.hbTokenReader deleteTokens];
23+
[UADSServiceProviderContainer.sharedInstance.serviceProvider.hbTokenReader deleteTokens];
2424
return true;
2525
}
2626

@@ -30,8 +30,8 @@ - (BOOL)initModuleState: (USRVConfiguration *)configuration {
3030
}
3131

3232
- (BOOL)initErrorState: (USRVConfiguration *)configuration code: (UADSErrorState)stateCode message: (NSString *)message {
33-
[UADSServiceProvider.sharedInstance.hbTokenReader setInitToken: nil];
34-
[UADSServiceProvider.sharedInstance.hbTokenReader deleteTokens];
33+
[UADSServiceProviderContainer.sharedInstance.serviceProvider.hbTokenReader setInitToken: nil];
34+
[UADSServiceProviderContainer.sharedInstance.serviceProvider.hbTokenReader deleteTokens];
3535

3636
return true;
3737
}

SourceCode/Private/Ads/Load/UADSAbstractModule/UADSAbstractModule.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ typedef NSDictionary<NSString *, id<UADSAbstractModuleOperationObject> > UADSAbs
2424
+ (void)setConfiguration: (USRVConfiguration *)config;
2525
+ (USRVConfiguration *) configuration;
2626

27-
- (void)executeForPlacement: (NSString *_Nonnull)placementId
28-
withOptions: (id<UADSDictionaryConvertible>)options
29-
andDelegate: (nullable id<UADSAbstractModuleDelegate>)delegate;
27+
- (NSString *)executeForPlacement: (NSString *_Nonnull)placementId
28+
withOptions: (id<UADSDictionaryConvertible>)options
29+
andDelegate: (nullable id<UADSAbstractModuleDelegate>)delegate;
3030

3131
- (id<UADSAbstractModuleOperationObject>)createEventWithPlacementID: (NSString *)placementID
3232
withOptions: (id<UADSDictionaryConvertible>)options

SourceCode/Private/Ads/Load/UADSAbstractModule/UADSAbstractModule.m

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,32 +66,33 @@ - (instancetype)init {
6666
return self;
6767
}
6868

69-
- (void)executeForPlacement: (NSString *)placementId
70-
withOptions: (id<UADSDictionaryConvertible>)options
71-
andDelegate: (id<UADSAbstractModuleDelegate>)delegate {
69+
- (NSString *)executeForPlacement: (NSString *)placementId
70+
withOptions: (id<UADSDictionaryConvertible>)options
71+
andDelegate: (id<UADSAbstractModuleDelegate>)delegate {
7272
NSString *safePlacementID = placementId ? : kUADSAbstractModuleEmptyPlacementID;
73-
73+
7474
UADSInternalError *error = [self executionErrorForPlacementID: safePlacementID];
75-
75+
7676
if (error) {
7777
[self logErrorAndNotifyDelegate: delegate
7878
errorParams: error
7979
forPlacementID: safePlacementID];
80-
return;
80+
return @"";
8181
}
82-
82+
8383
id<UADSAbstractModuleOperationObject> operation = [self createEventWithPlacementID: safePlacementID
8484
withOptions: options
8585
timer: [self.timerFactory timerWithAppLifeCycle]
8686
withDelegate: delegate];
87-
87+
8888
[_eventHandler eventStarted: operation.id];
8989
[self saveOperation: operation];
90-
91-
90+
91+
9292
dispatch_async(_invokeQueue, ^{
9393
[self invokeOperation: operation];
9494
});
95+
return operation.id;
9596
} /* executeForPlacement */
9697

9798
- (NSInteger)operationOperationTimeoutMs {

SourceCode/Private/Ads/Load/UADSAbstractModule/UADSAbstractModuleBasicState/UADSAbstractModuleOperationBasicObject.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ - (nonnull NSString *)methodName {
3131
return nil;
3232
}
3333

34+
- (nonnull NSString *)className {
35+
NSAssert(NO, @"Cannot use abstract class");
36+
return nil;
37+
}
38+
3439
- (void)startListeningOperationTTLExpiration: (UADSVoidClosure)operationExpired {
3540
_operationExpired = operationExpired;
3641

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#import "UADSLoadModule.h"
2+
#import "UADSLoadOptions.h"
3+
#import "UADSBannerViewDelegate.h"
4+
#import "UnityAdsLoadError.h"
5+
NS_ASSUME_NONNULL_BEGIN
6+
7+
@interface UADSBannerLoadModule : UADSLoadModule
8+
9+
- (void)sendClickEventForListenerID: (NSString *_Nonnull)listenerID;
10+
11+
- (void)sendLeaveApplicationEventForListenerID: (NSString *_Nonnull)listenerID;
12+
13+
- (NSString *)loadForPlacementID: (NSString *)placementID
14+
bannerView: (UADSBannerView *)bannerView
15+
options: (UADSLoadOptions *)options
16+
loadDelegate: (nullable id<UADSBannerViewDelegate>)loadDelegate;
17+
18+
- (UADSBannerView *)bannerViewWithID:(NSString *)bannerID;
19+
20+
21+
@end
22+
23+
NS_ASSUME_NONNULL_END
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#import "UADSBannerLoadModule.h"
2+
#import "WebViewInvokerQueueDecorator.h"
3+
#import "UADSBannerLoadModuleDelegateWrapper.h"
4+
#import "UADSBannerLoadModuleOperationObject.h"
5+
#import "USRVDevice.h"
6+
#import "UADSBannerLoadOptions.h"
7+
8+
@implementation UADSBannerLoadModule
9+
10+
typedef id<UADSWebViewInvoker> Invoker;
11+
12+
+ (instancetype)sharedInstance {
13+
UADS_SHARED_INSTANCE(onceToken, ^{
14+
return [self newSharedModule];
15+
});
16+
}
17+
18+
+ (UADSEventHandlerType)moduleType {
19+
return kUADSEventHandlerTypeBannerLoadModule;
20+
}
21+
22+
- (id<UADSAbstractModuleOperationObject>)createEventWithPlacementID: (NSString *)placementID
23+
withOptions: (id<UADSDictionaryConvertible>)options
24+
timer: (id<UADSRepeatableTimer>)timer
25+
withDelegate: (id<UADSAbstractModuleDelegate>)delegate {
26+
UADSBannerLoadModuleOperationObject *operation = [UADSBannerLoadModuleOperationObject new];
27+
28+
operation.placementID = placementID;
29+
operation.options = options;
30+
operation.delegate = delegate;
31+
operation.ttl = -1;
32+
operation.time = [USRVDevice getElapsedRealtime];
33+
operation.timer = timer;
34+
return operation;
35+
}
36+
37+
- (NSString *)loadForPlacementID: (NSString *)placementID
38+
bannerView: (nonnull UADSBannerView *)bannerView
39+
options: (UADSLoadOptions *)options
40+
loadDelegate: (nullable id<UADSBannerViewDelegate>)loadDelegate {
41+
UADSBannerLoadModuleDelegateWrapper *wrappedDelegate = [UADSBannerLoadModuleDelegateWrapper newWithAdsDelegate: loadDelegate bannerView: bannerView];
42+
UADSBannerLoadOptions *loadOptions = [UADSBannerLoadOptions newBannerLoadOptionsWith:options size:bannerView.size];
43+
return [self executeForPlacement: placementID
44+
withOptions: loadOptions
45+
andDelegate: wrappedDelegate];
46+
}
47+
48+
- (void)sendAdLoadedForPlacementID:(NSString *)placementID andListenerID:(NSString *)listenerID {
49+
[self handleSuccess: listenerID];
50+
UADSBannerLoadModuleDelegateWrapper *delegate = [self getDelegateForID: listenerID];
51+
52+
[delegate bannerViewDidLoad: nil];
53+
}
54+
55+
- (void)sendClickEventForListenerID: (NSString *_Nonnull)listenerID {
56+
UADSBannerLoadModuleDelegateWrapper *delegate = [self getDelegateForID: listenerID];
57+
58+
[delegate bannerViewDidClick:nil];
59+
}
60+
61+
- (void)sendLeaveApplicationEventForListenerID: (NSString *_Nonnull)listenerID {
62+
UADSBannerLoadModuleDelegateWrapper *delegate = [self getDelegateForID: listenerID];
63+
64+
[delegate bannerViewDidLeaveApplication:nil];
65+
}
66+
67+
- (void)sendAdFailedToLoadForPlacementID:(NSString *)placementID listenerID:(NSString *)listenerID message:(NSString *)message error:(UnityAdsLoadError)error {
68+
UADSInternalError *internalError = [UADSInternalError newWithErrorCode: kUADSInternalErrorLoadModule
69+
andReason: error
70+
andMessage: message];
71+
72+
[self catchError: internalError
73+
forId: listenerID];
74+
UADSBannerLoadModuleDelegateWrapper *delegate = [self getDelegateForIDAndRemove: listenerID];
75+
76+
[delegate didFailWithError: internalError forPlacementID: @""];
77+
}
78+
79+
- (UADSBannerLoadModuleDelegateWrapper *)getDelegateForIDAndRemove: (NSString *)listenerID {
80+
return (UADSBannerLoadModuleDelegateWrapper *)[super getDelegateForIDAndRemove: listenerID];
81+
}
82+
83+
- (UADSBannerView *)bannerViewWithID:(NSString *)bannerID {
84+
UADSBannerLoadModuleDelegateWrapper *delegate = [self getDelegateForID: bannerID];
85+
return delegate.bannerView;
86+
87+
}
88+
89+
- (UADSBannerLoadModuleDelegateWrapper *)getDelegateForID: (NSString*)listenerID {
90+
return (UADSBannerLoadModuleDelegateWrapper*)[super getOperationWithID: listenerID].delegate;
91+
}
92+
93+
@end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#import "UADSAbstractModuleDelegate.h"
2+
#import "UADSBannerViewDelegate.h"
3+
4+
NS_ASSUME_NONNULL_BEGIN
5+
6+
@interface UADSBannerLoadModuleDelegateWrapper : NSObject<UADSBannerViewDelegate, UADSAbstractModuleDelegate>
7+
+ (instancetype)newWithAdsDelegate: (id<UADSBannerViewDelegate>)decorated bannerView:(UADSBannerView *)bannerView;
8+
9+
@property (nonatomic, weak, readonly) UADSBannerView *bannerView;
10+
@end
11+
12+
NS_ASSUME_NONNULL_END
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#import "UADSBannerLoadModuleDelegateWrapper.h"
2+
3+
@interface UADSBannerLoadModuleDelegateWrapper()
4+
@property (nonatomic, strong) id<UADSBannerViewDelegate>decorated;
5+
@property (nonatomic, weak) UADSBannerView *bannerView;
6+
@property (nonatomic, copy) NSString *uuidString;
7+
@end
8+
9+
@implementation UADSBannerLoadModuleDelegateWrapper
10+
11+
+ (instancetype)newWithAdsDelegate: (id<UADSBannerViewDelegate>)decorated bannerView:(nonnull UADSBannerView *)bannerView {
12+
UADSBannerLoadModuleDelegateWrapper *wrapper = [UADSBannerLoadModuleDelegateWrapper new];
13+
wrapper.uuidString = [NSUUID new].UUIDString;
14+
wrapper.decorated = decorated;
15+
wrapper.bannerView = bannerView;
16+
return wrapper;
17+
}
18+
19+
- (void)didFailWithError:(UADSInternalError * _Nonnull)error forPlacementID:(NSString * _Nonnull)placementID {
20+
UADSBannerError *bannerError = [[UADSBannerError alloc] initWithCode: [self convertIntoPublicError:error]
21+
userInfo: @{ NSLocalizedDescriptionKey: error.errorMessage }];
22+
[self bannerViewDidError: self.bannerView
23+
error: bannerError];
24+
}
25+
26+
- (void)bannerViewDidLoad: (UADSBannerView *)bannerView {
27+
dispatch_on_main( ^{
28+
[self.decorated bannerViewDidLoad: self.bannerView];
29+
});
30+
}
31+
32+
- (void)bannerViewDidClick: (UADSBannerView *)bannerView {
33+
dispatch_on_main( ^{
34+
[self.decorated bannerViewDidClick: self.bannerView];
35+
});
36+
}
37+
38+
- (void)bannerViewDidLeaveApplication: (UADSBannerView *)bannerView {
39+
dispatch_on_main( ^{
40+
[self.decorated bannerViewDidLeaveApplication: self.bannerView];
41+
});
42+
}
43+
44+
- (void)bannerViewDidError: (UADSBannerView *)bannerView error: (UADSBannerError *)error {
45+
dispatch_on_main( ^{
46+
[self.decorated bannerViewDidError: self.bannerView error: error];
47+
});
48+
}
49+
50+
- (UADSBannerErrorCode)convertIntoPublicError: (UADSInternalError *)error {
51+
if (error.errorCode == kUADSInternalErrorAbstractModule && error.reasonCode == kUADSInternalErrorAbstractModuleTimeout) {
52+
return UADSBannerErrorCodeNativeError;
53+
}
54+
55+
if (error.errorCode == kUADSInternalErrorWebView && error.reasonCode == kUADSInternalErrorWebViewInternal) {
56+
return UADSBannerErrorCodeWebViewError;
57+
}
58+
59+
if (error.errorCode == kUADSInternalErrorWebView && error.reasonCode == kUADSInternalErrorWebViewSDKNotInitialized) {
60+
return UADSBannerErrorInitializeFailed;
61+
}
62+
63+
if (error.errorCode == kUADSInternalErrorAbstractModule && error.reasonCode == kUADSInternalErrorAbstractModuleEmptyPlacementID) {
64+
return UADSBannerErrorInvalidArgument;
65+
}
66+
67+
return error.reasonCode;
68+
}
69+
70+
@end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#import <Foundation/Foundation.h>
2+
#import "UADSAbstractModuleOperationBasicObject.h"
3+
#import "UADSBannerView.h"
4+
NS_ASSUME_NONNULL_BEGIN
5+
6+
static NSString *const kUADSBannerWidth = @"width";
7+
static NSString *const kUADSBannerHeight = @"height";
8+
9+
@interface UADSBannerLoadModuleOperationObject : UADSAbstractModuleOperationBasicObject
10+
@end
11+
12+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)