react-native-applovin-max 3.3.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +4 -4
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdView.java +162 -61
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewManager.java +22 -165
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXModule.java +12 -6
- package/ios/AppLovinMAX.h +5 -0
- package/ios/AppLovinMAX.m +2 -2
- package/ios/AppLovinMAX.xcodeproj/project.pbxproj +6 -0
- package/ios/AppLovinMAX.xcworkspace/xcuserdata/thomasso.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/AppLovinMAX.xcworkspace/xcuserdata/thomasso.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +24 -0
- package/ios/AppLovinMAXAdView.h +9 -0
- package/ios/AppLovinMAXAdView.m +190 -0
- package/ios/AppLovinMAXAdViewManager.m +10 -280
- package/ios/Podfile +1 -1
- package/ios/Podfile.lock +5 -5
- package/package.json +1 -1
- package/react-native-applovin-max.podspec +2 -2
- package/src/AppLovinMAXAdView.js +35 -142
- package/src/index.js +1 -1
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
#import <AppLovinSDK/AppLovinSDK.h>
|
|
2
|
+
#import "AppLovinMAX.h"
|
|
3
|
+
#import "AppLovinMAXAdView.h"
|
|
4
|
+
|
|
5
|
+
@interface AppLovinMAXAdView()
|
|
6
|
+
|
|
7
|
+
@property (nonatomic, strong, nullable) MAAdView *adView; // nil when unmounted
|
|
8
|
+
|
|
9
|
+
// The following properties are updated from RN layer via the view manager
|
|
10
|
+
@property (nonatomic, copy) NSString *adUnitId;
|
|
11
|
+
@property (nonatomic, weak) MAAdFormat *adFormat;
|
|
12
|
+
@property (nonatomic, copy, nullable) NSString *placement;
|
|
13
|
+
@property (nonatomic, copy, nullable) NSString *customData;
|
|
14
|
+
@property (nonatomic, assign, readonly, getter=isAdaptiveBannerEnabled) BOOL adaptiveBannerEnabled;
|
|
15
|
+
@property (nonatomic, assign, readonly, getter=isAutoRefresh) BOOL autoRefresh;
|
|
16
|
+
|
|
17
|
+
@end
|
|
18
|
+
|
|
19
|
+
@implementation AppLovinMAXAdView
|
|
20
|
+
|
|
21
|
+
- (void)setAdUnitId:(NSString *)adUnitId
|
|
22
|
+
{
|
|
23
|
+
// Ad Unit ID must be set prior to creating MAAdView
|
|
24
|
+
if ( self.adView )
|
|
25
|
+
{
|
|
26
|
+
[[AppLovinMAX shared] log: @"Attempting to set Ad Unit ID %@ after MAAdView is created", adUnitId];
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_adUnitId = adUnitId;
|
|
31
|
+
|
|
32
|
+
[self attachAdViewIfNeeded];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
- (void)setAdFormat:(NSString *)adFormat
|
|
36
|
+
{
|
|
37
|
+
// Ad format must be set prior to creating MAAdView
|
|
38
|
+
if ( self.adView )
|
|
39
|
+
{
|
|
40
|
+
[[AppLovinMAX shared] log: @"Attempting to set ad format %@ after MAAdView is created", adFormat];
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if ( [@"banner" isEqualToString: adFormat] )
|
|
45
|
+
{
|
|
46
|
+
_adFormat = DEVICE_SPECIFIC_ADVIEW_AD_FORMAT;
|
|
47
|
+
}
|
|
48
|
+
else if ( [@"mrec" isEqualToString: adFormat] )
|
|
49
|
+
{
|
|
50
|
+
_adFormat = MAAdFormat.mrec;
|
|
51
|
+
}
|
|
52
|
+
else
|
|
53
|
+
{
|
|
54
|
+
[[AppLovinMAX shared] log: @"Attempting to set an invalid ad format of \"%@\" for %@", adFormat, self.adUnitId];
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
[self attachAdViewIfNeeded];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
- (void)setPlacement:(NSString *)placement
|
|
62
|
+
{
|
|
63
|
+
_placement = placement;
|
|
64
|
+
|
|
65
|
+
if ( self.adView )
|
|
66
|
+
{
|
|
67
|
+
self.adView.placement = placement;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
- (void)setCustomData:(NSString *)customData
|
|
72
|
+
{
|
|
73
|
+
_customData = customData;
|
|
74
|
+
|
|
75
|
+
if ( self.adView )
|
|
76
|
+
{
|
|
77
|
+
self.adView.customData = customData;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
- (void)setAdaptiveBannerEnabled:(BOOL)adaptiveBannerEnabled
|
|
82
|
+
{
|
|
83
|
+
_adaptiveBannerEnabled = adaptiveBannerEnabled;
|
|
84
|
+
|
|
85
|
+
if ( self.adView )
|
|
86
|
+
{
|
|
87
|
+
[self.adView setExtraParameterForKey: @"adaptive_banner" value: adaptiveBannerEnabled ? @"true" : @"false"];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
- (void)setAutoRefresh:(BOOL)autoRefresh
|
|
92
|
+
{
|
|
93
|
+
_autoRefresh = autoRefresh;
|
|
94
|
+
|
|
95
|
+
if ( self.adView )
|
|
96
|
+
{
|
|
97
|
+
if ( autoRefresh )
|
|
98
|
+
{
|
|
99
|
+
[self.adView startAutoRefresh];
|
|
100
|
+
}
|
|
101
|
+
else
|
|
102
|
+
{
|
|
103
|
+
[self.adView stopAutoRefresh];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
- (void)attachAdViewIfNeeded
|
|
109
|
+
{
|
|
110
|
+
// Re-assign in case of race condition
|
|
111
|
+
NSString *adUnitId = self.adUnitId;
|
|
112
|
+
MAAdFormat *adFormat = self.adFormat;
|
|
113
|
+
|
|
114
|
+
// Run after 0.25 sec delay to allow all properties to set
|
|
115
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
116
|
+
|
|
117
|
+
if ( ![adUnitId al_isValidString] )
|
|
118
|
+
{
|
|
119
|
+
[[AppLovinMAX shared] log: @"Attempting to attach MAAdView without Ad Unit ID"];
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if ( !adFormat )
|
|
124
|
+
{
|
|
125
|
+
[[AppLovinMAX shared] log: @"Attempting to attach MAAdView without ad format"];
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if ( self.adView )
|
|
130
|
+
{
|
|
131
|
+
[[AppLovinMAX shared] log: @"Attempting to re-attach with existing MAAdView: %@", self.adView];
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
[[AppLovinMAX shared] log: @"Attaching MAAdView for %@", adUnitId];
|
|
136
|
+
|
|
137
|
+
self.adView = [[MAAdView alloc] initWithAdUnitIdentifier: adUnitId
|
|
138
|
+
adFormat: adFormat
|
|
139
|
+
sdk: [AppLovinMAX shared].sdk];
|
|
140
|
+
self.adView.frame = (CGRect) { CGPointZero, self.frame.size };
|
|
141
|
+
self.adView.delegate = [AppLovinMAX shared]; // Go through core class for callback forwarding to React Native layer
|
|
142
|
+
self.adView.revenueDelegate = [AppLovinMAX shared];
|
|
143
|
+
self.adView.placement = self.placement;
|
|
144
|
+
self.adView.customData = self.customData;
|
|
145
|
+
[self.adView setExtraParameterForKey: @"adaptive_banner" value: [self isAdaptiveBannerEnabled] ? @"true" : @"false"];
|
|
146
|
+
// Set this extra parameter to work around a SDK bug that ignores calls to stopAutoRefresh()
|
|
147
|
+
[self.adView setExtraParameterForKey: @"allow_pause_auto_refresh_immediately" value: @"true"];
|
|
148
|
+
|
|
149
|
+
if ( [self isAutoRefresh] )
|
|
150
|
+
{
|
|
151
|
+
[self.adView startAutoRefresh];
|
|
152
|
+
}
|
|
153
|
+
else
|
|
154
|
+
{
|
|
155
|
+
[self.adView stopAutoRefresh];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
[self.adView loadAd];
|
|
159
|
+
|
|
160
|
+
[self addSubview: self.adView];
|
|
161
|
+
|
|
162
|
+
[NSLayoutConstraint activateConstraints: @[[self.adView.widthAnchor constraintEqualToAnchor: self.widthAnchor],
|
|
163
|
+
[self.adView.heightAnchor constraintEqualToAnchor: self.heightAnchor],
|
|
164
|
+
[self.adView.centerXAnchor constraintEqualToAnchor: self.centerXAnchor],
|
|
165
|
+
[self.adView.centerYAnchor constraintEqualToAnchor: self.centerYAnchor]]];
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
- (void)didMoveToWindow
|
|
170
|
+
{
|
|
171
|
+
[super didMoveToWindow];
|
|
172
|
+
|
|
173
|
+
// This view is unmounted
|
|
174
|
+
if ( !self.window )
|
|
175
|
+
{
|
|
176
|
+
if ( self.adView )
|
|
177
|
+
{
|
|
178
|
+
[[AppLovinMAX shared] log: @"Unmounting MAAdView: %@", self.adView];
|
|
179
|
+
|
|
180
|
+
self.adView.delegate = nil;
|
|
181
|
+
self.adView.revenueDelegate = nil;
|
|
182
|
+
|
|
183
|
+
[self.adView removeFromSuperview];
|
|
184
|
+
|
|
185
|
+
self.adView = nil;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
@end
|
|
@@ -7,297 +7,27 @@
|
|
|
7
7
|
//
|
|
8
8
|
|
|
9
9
|
#import "AppLovinMAXAdViewManager.h"
|
|
10
|
-
#import
|
|
11
|
-
#import "AppLovinMAX.h"
|
|
12
|
-
#import <React/RCTUIManager.h>
|
|
13
|
-
|
|
14
|
-
// Internal
|
|
15
|
-
@interface NSString (ALUtils)
|
|
16
|
-
@property (assign, readonly, getter=al_isValidString) BOOL al_validString;
|
|
17
|
-
@end
|
|
18
|
-
|
|
19
|
-
@interface AppLovinMAXAdViewManager()
|
|
20
|
-
|
|
21
|
-
// Dictionaries from id of the React view to the corresponding ad unit id and ad format.
|
|
22
|
-
// Both must be set before the MAAdView is created.
|
|
23
|
-
@property (nonatomic, strong) NSMutableDictionary<NSNumber *, NSString *> *adUnitIdRegistry;
|
|
24
|
-
@property (nonatomic, strong) NSMutableDictionary<NSNumber *, MAAdFormat *> *adFormatRegistry;
|
|
25
|
-
|
|
26
|
-
// Storage for placement and extra parameters if set before the MAAdView is created
|
|
27
|
-
@property (nonatomic, strong) NSMutableDictionary<NSNumber *, NSString *> *placementRegistry;
|
|
28
|
-
@property (nonatomic, strong) NSMutableDictionary<NSNumber *, NSString *> *customDataRegistry;
|
|
29
|
-
@property (nonatomic, strong) NSMutableDictionary<NSNumber *, NSString *> *adaptiveBannerEnabledRegistry;
|
|
30
|
-
@property (nonatomic, strong) NSMutableDictionary<NSNumber *, NSNumber *> *autoRefreshEnabledRegistry;
|
|
31
|
-
|
|
32
|
-
@end
|
|
10
|
+
#import "AppLovinMAXAdview.h"
|
|
33
11
|
|
|
34
12
|
@implementation AppLovinMAXAdViewManager
|
|
13
|
+
|
|
35
14
|
RCT_EXPORT_MODULE(AppLovinMAXAdView)
|
|
36
15
|
|
|
37
|
-
|
|
16
|
+
RCT_EXPORT_VIEW_PROPERTY(adUnitId, NSString)
|
|
17
|
+
RCT_EXPORT_VIEW_PROPERTY(adFormat, NSString)
|
|
18
|
+
RCT_EXPORT_VIEW_PROPERTY(placement, NSString)
|
|
19
|
+
RCT_EXPORT_VIEW_PROPERTY(customData, NSString)
|
|
20
|
+
RCT_EXPORT_VIEW_PROPERTY(adaptiveBannerEnabled, BOOL)
|
|
21
|
+
RCT_EXPORT_VIEW_PROPERTY(autoRefresh, BOOL)
|
|
22
|
+
|
|
38
23
|
+ (BOOL)requiresMainQueueSetup
|
|
39
24
|
{
|
|
40
25
|
return YES;
|
|
41
26
|
}
|
|
42
27
|
|
|
43
|
-
- (instancetype)init
|
|
44
|
-
{
|
|
45
|
-
self = [super init];
|
|
46
|
-
if ( self )
|
|
47
|
-
{
|
|
48
|
-
self.adUnitIdRegistry = [NSMutableDictionary dictionary];
|
|
49
|
-
self.adFormatRegistry = [NSMutableDictionary dictionary];
|
|
50
|
-
self.placementRegistry = [NSMutableDictionary dictionary];
|
|
51
|
-
self.customDataRegistry = [NSMutableDictionary dictionary];
|
|
52
|
-
self.adaptiveBannerEnabledRegistry = [NSMutableDictionary dictionary];
|
|
53
|
-
self.autoRefreshEnabledRegistry = [NSMutableDictionary dictionary];
|
|
54
|
-
}
|
|
55
|
-
return self;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
28
|
- (UIView *)view
|
|
59
29
|
{
|
|
60
|
-
|
|
61
|
-
return [[UIView alloc] init];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// NOTE: `nonnull` must be annotated here for this RN export to work at runtime
|
|
65
|
-
RCT_EXPORT_METHOD(setPlacement:(nonnull NSNumber *)viewTag toPlacement:(NSString *)placement)
|
|
66
|
-
{
|
|
67
|
-
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
68
|
-
|
|
69
|
-
// NOTE: iOS caches the native view via `viewTag` when you remove it from screen (unlike Android)
|
|
70
|
-
UIView *view = viewRegistry[viewTag];
|
|
71
|
-
if ( !view )
|
|
72
|
-
{
|
|
73
|
-
RCTLogError(@"Cannot find UIView with tag %@", viewTag);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
MAAdView *adView = [self adViewFromContainerView: view];
|
|
78
|
-
if ( adView )
|
|
79
|
-
{
|
|
80
|
-
adView.placement = placement;
|
|
81
|
-
}
|
|
82
|
-
else
|
|
83
|
-
{
|
|
84
|
-
self.placementRegistry[viewTag] = placement;
|
|
85
|
-
}
|
|
86
|
-
}];
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// NOTE: `nonnull` must be annotated here for this RN export to work at runtime
|
|
90
|
-
RCT_EXPORT_METHOD(setCustomData:(nonnull NSNumber *)viewTag toCustomData:(NSString *)customData)
|
|
91
|
-
{
|
|
92
|
-
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
93
|
-
|
|
94
|
-
// NOTE: iOS caches the native view via `viewTag` when you remove it from screen (unlike Android)
|
|
95
|
-
UIView *view = viewRegistry[viewTag];
|
|
96
|
-
if ( !view )
|
|
97
|
-
{
|
|
98
|
-
RCTLogError(@"Cannot find UIView with tag %@", viewTag);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
MAAdView *adView = [self adViewFromContainerView: view];
|
|
103
|
-
if ( adView )
|
|
104
|
-
{
|
|
105
|
-
adView.customData = customData;
|
|
106
|
-
}
|
|
107
|
-
else
|
|
108
|
-
{
|
|
109
|
-
self.customDataRegistry[viewTag] = customData;
|
|
110
|
-
}
|
|
111
|
-
}];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// NOTE: `nonnull` must be annotated here for this RN export to work at runtime
|
|
115
|
-
RCT_EXPORT_METHOD(setAdaptiveBannerEnabled:(nonnull NSNumber *)viewTag toEnabled:(NSString *)enabledStr)
|
|
116
|
-
{
|
|
117
|
-
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
118
|
-
|
|
119
|
-
// NOTE: iOS caches the native view via `viewTag` when you remove it from screen (unlike Android)
|
|
120
|
-
UIView *view = viewRegistry[viewTag];
|
|
121
|
-
if ( !view )
|
|
122
|
-
{
|
|
123
|
-
RCTLogError(@"Cannot find UIView with tag %@", viewTag);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
MAAdView *adView = [self adViewFromContainerView: view];
|
|
128
|
-
if ( adView )
|
|
129
|
-
{
|
|
130
|
-
[adView setExtraParameterForKey: @"adaptive_banner" value: enabledStr];
|
|
131
|
-
}
|
|
132
|
-
else
|
|
133
|
-
{
|
|
134
|
-
self.adaptiveBannerEnabledRegistry[viewTag] = enabledStr;
|
|
135
|
-
}
|
|
136
|
-
}];
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// NOTE: `nonnull` must be annotated here for this RN export to work at runtime
|
|
140
|
-
RCT_EXPORT_METHOD(setAutoRefresh:(nonnull NSNumber *)viewTag toEnabled:(BOOL)enabled)
|
|
141
|
-
{
|
|
142
|
-
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
143
|
-
|
|
144
|
-
// NOTE: iOS caches the native view via `viewTag` when you remove it from screen (unlike Android)
|
|
145
|
-
UIView *view = viewRegistry[viewTag];
|
|
146
|
-
if ( !view )
|
|
147
|
-
{
|
|
148
|
-
RCTLogError(@"Cannot find UIView with tag %@", viewTag);
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
MAAdView *adView = [self adViewFromContainerView: view];
|
|
153
|
-
if ( adView )
|
|
154
|
-
{
|
|
155
|
-
if ( enabled )
|
|
156
|
-
{
|
|
157
|
-
[adView startAutoRefresh];
|
|
158
|
-
}
|
|
159
|
-
else
|
|
160
|
-
{
|
|
161
|
-
[adView stopAutoRefresh];
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
else
|
|
165
|
-
{
|
|
166
|
-
self.autoRefreshEnabledRegistry[viewTag] = @(enabled);
|
|
167
|
-
}
|
|
168
|
-
}];
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// NOTE: `nonnull` must be annotated here for this RN export to work at runtime
|
|
172
|
-
RCT_EXPORT_METHOD(setAdUnitId:(nonnull NSNumber *)viewTag toAdUnitId:(NSString *)adUnitId)
|
|
173
|
-
{
|
|
174
|
-
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
175
|
-
|
|
176
|
-
// NOTE: iOS caches the native view via `viewTag` when you remove it from screen (unlike Android)
|
|
177
|
-
UIView *view = viewRegistry[viewTag];
|
|
178
|
-
if ( !view )
|
|
179
|
-
{
|
|
180
|
-
RCTLogError(@"Cannot find UIView with tag %@", viewTag);
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
self.adUnitIdRegistry[viewTag] = adUnitId;
|
|
185
|
-
|
|
186
|
-
[self attachAdViewIfNeededForViewTag: viewTag
|
|
187
|
-
adUnitIdentifier: self.adUnitIdRegistry[viewTag]
|
|
188
|
-
adFormat: self.adFormatRegistry[viewTag]
|
|
189
|
-
containerView: view];
|
|
190
|
-
}];
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// NOTE: `nonnull` must be annotated here for this RN export to work at runtime
|
|
194
|
-
RCT_EXPORT_METHOD(setAdFormat:(nonnull NSNumber *)viewTag toAdFormat:(NSString *)adFormatStr)
|
|
195
|
-
{
|
|
196
|
-
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
197
|
-
|
|
198
|
-
// NOTE: iOS caches the native view via `viewTag` when you remove it from screen (unlike Android)
|
|
199
|
-
UIView *view = viewRegistry[viewTag];
|
|
200
|
-
if ( !view )
|
|
201
|
-
{
|
|
202
|
-
RCTLogError(@"Cannot find UIView with tag %@", viewTag);
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if ( [@"banner" isEqualToString: adFormatStr] )
|
|
207
|
-
{
|
|
208
|
-
self.adFormatRegistry[viewTag] = DEVICE_SPECIFIC_ADVIEW_AD_FORMAT;
|
|
209
|
-
}
|
|
210
|
-
else if ( [@"mrec" isEqualToString: adFormatStr] )
|
|
211
|
-
{
|
|
212
|
-
self.adFormatRegistry[viewTag] = MAAdFormat.mrec;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
[self attachAdViewIfNeededForViewTag: viewTag
|
|
216
|
-
adUnitIdentifier: self.adUnitIdRegistry[viewTag]
|
|
217
|
-
adFormat: self.adFormatRegistry[viewTag]
|
|
218
|
-
containerView: view];
|
|
219
|
-
}];
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
- (void)attachAdViewIfNeededForViewTag:(NSNumber *)viewTag adUnitIdentifier:(NSString *)adUnitIdentifier adFormat:(MAAdFormat *)adFormat containerView:(UIView *)containerView
|
|
223
|
-
{
|
|
224
|
-
// Run after delay to ensure SDK is attached to main module first
|
|
225
|
-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
226
|
-
|
|
227
|
-
// If ad unit id and format has been set - create and attach AdView
|
|
228
|
-
if ( [adUnitIdentifier al_isValidString] && adFormat )
|
|
229
|
-
{
|
|
230
|
-
MAAdView *adView = [self adViewFromContainerView: containerView];
|
|
231
|
-
|
|
232
|
-
// Check if there's a previously-attached AdView
|
|
233
|
-
if ( adView )
|
|
234
|
-
{
|
|
235
|
-
[adView removeFromSuperview];
|
|
236
|
-
[adView stopAutoRefresh];
|
|
237
|
-
|
|
238
|
-
adView = nil;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
adView = [[MAAdView alloc] initWithAdUnitIdentifier: adUnitIdentifier adFormat: adFormat sdk: AppLovinMAX.shared.sdk];
|
|
242
|
-
adView.frame = (CGRect) { CGPointZero, adFormat.size };
|
|
243
|
-
adView.delegate = AppLovinMAX.shared; // Go through core class for callback forwarding to React Native layer
|
|
244
|
-
adView.revenueDelegate = AppLovinMAX.shared;
|
|
245
|
-
|
|
246
|
-
NSString *placement = self.placementRegistry[viewTag];
|
|
247
|
-
if ( placement )
|
|
248
|
-
{
|
|
249
|
-
[self.placementRegistry removeObjectForKey: viewTag];
|
|
250
|
-
adView.placement = placement;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
NSString *customData = self.customDataRegistry[viewTag];
|
|
254
|
-
if ( customData )
|
|
255
|
-
{
|
|
256
|
-
[self.customDataRegistry removeObjectForKey: viewTag];
|
|
257
|
-
adView.customData = customData;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
NSString *adaptiveBannerEnabledStr = self.adaptiveBannerEnabledRegistry[viewTag];
|
|
261
|
-
if ( [adaptiveBannerEnabledStr al_isValidString] )
|
|
262
|
-
{
|
|
263
|
-
[self.adaptiveBannerEnabledRegistry removeObjectForKey: viewTag];
|
|
264
|
-
[adView setExtraParameterForKey: @"adaptive_banner" value: adaptiveBannerEnabledStr];
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// Set this extra parameter to work around a SDK bug that ignores calls to stopAutoRefresh()
|
|
268
|
-
[adView setExtraParameterForKey: @"allow_pause_auto_refresh_immediately" value: @"true"];
|
|
269
|
-
|
|
270
|
-
NSNumber *autoRefreshEnabled = self.autoRefreshEnabledRegistry[viewTag];
|
|
271
|
-
if ( autoRefreshEnabled )
|
|
272
|
-
{
|
|
273
|
-
if ( [autoRefreshEnabled boolValue] )
|
|
274
|
-
{
|
|
275
|
-
[adView startAutoRefresh];
|
|
276
|
-
}
|
|
277
|
-
else
|
|
278
|
-
{
|
|
279
|
-
[adView stopAutoRefresh];
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
[adView loadAd];
|
|
284
|
-
|
|
285
|
-
[containerView addSubview: adView];
|
|
286
|
-
|
|
287
|
-
CGSize adViewSize = [adFormat adaptiveSizeForWidth: CGRectGetWidth(containerView.frame)];
|
|
288
|
-
[NSLayoutConstraint activateConstraints: @[[adView.widthAnchor constraintEqualToConstant: adViewSize.width],
|
|
289
|
-
[adView.heightAnchor constraintEqualToConstant: adViewSize.height],
|
|
290
|
-
[adView.centerXAnchor constraintEqualToAnchor: containerView.centerXAnchor],
|
|
291
|
-
[adView.centerYAnchor constraintEqualToAnchor: containerView.centerYAnchor]]];
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// MARK: - Helper Functions
|
|
297
|
-
|
|
298
|
-
- (nullable MAAdView *)adViewFromContainerView:(UIView *)view
|
|
299
|
-
{
|
|
300
|
-
return view.subviews.count > 0 ? ((MAAdView *) view.subviews.lastObject) : nil;
|
|
30
|
+
return [[AppLovinMAXAdView alloc] init];
|
|
301
31
|
}
|
|
302
32
|
|
|
303
33
|
@end
|
package/ios/Podfile
CHANGED
|
@@ -35,6 +35,6 @@ target 'AppLovinMAX' do
|
|
|
35
35
|
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
|
|
36
36
|
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
|
|
37
37
|
|
|
38
|
-
pod 'AppLovinSDK', '11.
|
|
38
|
+
pod 'AppLovinSDK', '11.5.1'
|
|
39
39
|
|
|
40
40
|
end
|
package/ios/Podfile.lock
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
PODS:
|
|
2
|
-
- AppLovinSDK (11.
|
|
2
|
+
- AppLovinSDK (11.5.1)
|
|
3
3
|
- boost-for-react-native (1.63.0)
|
|
4
4
|
- DoubleConversion (1.1.6)
|
|
5
5
|
- FBLazyVector (0.63.4)
|
|
@@ -249,7 +249,7 @@ PODS:
|
|
|
249
249
|
- Yoga (1.14.0)
|
|
250
250
|
|
|
251
251
|
DEPENDENCIES:
|
|
252
|
-
- AppLovinSDK (= 11.
|
|
252
|
+
- AppLovinSDK (= 11.5.1)
|
|
253
253
|
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
|
|
254
254
|
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
|
|
255
255
|
- FBReactNativeSpec (from `../node_modules/react-native/Libraries/FBReactNativeSpec`)
|
|
@@ -339,7 +339,7 @@ EXTERNAL SOURCES:
|
|
|
339
339
|
:path: "../node_modules/react-native/ReactCommon/yoga"
|
|
340
340
|
|
|
341
341
|
SPEC CHECKSUMS:
|
|
342
|
-
AppLovinSDK:
|
|
342
|
+
AppLovinSDK: 40398f6ec127e01f53992b2acd663252647c0dbb
|
|
343
343
|
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
|
|
344
344
|
DoubleConversion: cde416483dac037923206447da6e1454df403714
|
|
345
345
|
FBLazyVector: 3bb422f41b18121b71783a905c10e58606f7dc3e
|
|
@@ -368,6 +368,6 @@ SPEC CHECKSUMS:
|
|
|
368
368
|
ReactCommon: 73d79c7039f473b76db6ff7c6b159c478acbbb3b
|
|
369
369
|
Yoga: 4bd86afe9883422a7c4028c00e34790f560923d6
|
|
370
370
|
|
|
371
|
-
PODFILE CHECKSUM:
|
|
371
|
+
PODFILE CHECKSUM: fde6ef203f431a104b9569e9ddb156746ae77c1f
|
|
372
372
|
|
|
373
|
-
COCOAPODS: 1.11.
|
|
373
|
+
COCOAPODS: 1.11.3
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-applovin-max",
|
|
3
3
|
"author": "AppLovin Corporation",
|
|
4
|
-
"version": "3.3.
|
|
4
|
+
"version": "3.3.1",
|
|
5
5
|
"description": "AppLovin MAX React Native Plugin for Android and iOS",
|
|
6
6
|
"homepage": "https://github.com/AppLovin/AppLovin-MAX-React-Native",
|
|
7
7
|
"license": "MIT",
|
|
@@ -11,10 +11,10 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.authors = package["author"]
|
|
12
12
|
|
|
13
13
|
s.platforms = { :ios => "10.0" }
|
|
14
|
-
s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "
|
|
14
|
+
s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_3_3_1" }
|
|
15
15
|
|
|
16
16
|
s.source_files = "ios/AppLovinMAX*.{h,m}"
|
|
17
17
|
|
|
18
18
|
s.dependency "React"
|
|
19
|
-
s.dependency "AppLovinSDK", "11.
|
|
19
|
+
s.dependency "AppLovinSDK", "11.5.1"
|
|
20
20
|
end
|