react-native-applovin-max 3.3.1 → 4.0.0
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 +3 -3
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXModule.java +20 -3
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdView.java +365 -0
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdViewManager.java +148 -0
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXPackage.java +2 -1
- package/ios/AppLovinMAX.h +5 -0
- package/ios/AppLovinMAX.m +31 -3
- package/ios/AppLovinMAX.xcodeproj/project.pbxproj +14 -2
- package/ios/AppLovinMAX.xcworkspace/xcuserdata/thomasso.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/AppLovinMAXAdView.h +7 -0
- package/ios/AppLovinMAXAdView.m +7 -0
- package/ios/AppLovinMAXNativeAdView.h +27 -0
- package/ios/AppLovinMAXNativeAdView.m +308 -0
- package/ios/AppLovinMAXNativeAdViewManager.h +19 -0
- package/ios/AppLovinMAXNativeAdViewManager.m +60 -0
- package/ios/Podfile +1 -1
- package/ios/Podfile.lock +4 -4
- package/package.json +1 -1
- package/react-native-applovin-max.podspec +2 -2
- package/src/AppLovinMAXAdView.js +1 -1
- package/src/NativeAdComponents.js +156 -0
- package/src/NativeAdView.js +118 -0
- package/src/NativeAdViewProvider.js +19 -0
- package/src/index.js +3 -1
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
1D2890F5251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D2890F4251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m */; };
|
|
11
11
|
1D3CC34128C18441003E5A07 /* AppLovinMAXAdView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3CC34028C18441003E5A07 /* AppLovinMAXAdView.m */; };
|
|
12
12
|
1DEA13CD24B9258700D42847 /* AppLovinMAX.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DEA13CC24B9258700D42847 /* AppLovinMAX.m */; };
|
|
13
|
+
7A47215228D8968100854002 /* AppLovinMAXNativeAdViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A47214F28D8968100854002 /* AppLovinMAXNativeAdViewManager.m */; };
|
|
14
|
+
7A47215728D8968800854002 /* AppLovinMAXNativeAdView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A47215328D8968800854002 /* AppLovinMAXNativeAdView.m */; };
|
|
13
15
|
DE4E5A3D46DDFAE766DFFE58 /* libPods-AppLovinMAX.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EF1B4EBC7187611714984C78 /* libPods-AppLovinMAX.a */; };
|
|
14
16
|
/* End PBXBuildFile section */
|
|
15
17
|
|
|
@@ -33,6 +35,10 @@
|
|
|
33
35
|
1D3CC33F28C18440003E5A07 /* AppLovinMAXAdView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppLovinMAXAdView.h; sourceTree = "<group>"; };
|
|
34
36
|
1D3CC34028C18441003E5A07 /* AppLovinMAXAdView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppLovinMAXAdView.m; sourceTree = "<group>"; };
|
|
35
37
|
1DEA13CC24B9258700D42847 /* AppLovinMAX.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppLovinMAX.m; sourceTree = "<group>"; };
|
|
38
|
+
7A47214F28D8968100854002 /* AppLovinMAXNativeAdViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppLovinMAXNativeAdViewManager.m; sourceTree = "<group>"; };
|
|
39
|
+
7A47215128D8968100854002 /* AppLovinMAXNativeAdViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppLovinMAXNativeAdViewManager.h; sourceTree = "<group>"; };
|
|
40
|
+
7A47215328D8968800854002 /* AppLovinMAXNativeAdView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppLovinMAXNativeAdView.m; sourceTree = "<group>"; };
|
|
41
|
+
7A47215428D8968800854002 /* AppLovinMAXNativeAdView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppLovinMAXNativeAdView.h; sourceTree = "<group>"; };
|
|
36
42
|
B3E7B5881CC2AC0600A0062D /* AppLovinMAX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppLovinMAX.h; sourceTree = "<group>"; };
|
|
37
43
|
EF1B4EBC7187611714984C78 /* libPods-AppLovinMAX.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AppLovinMAX.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
38
44
|
F80C453A02323F11AB9FD612 /* Pods-AppLovinMAX.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AppLovinMAX.release.xcconfig"; path = "Target Support Files/Pods-AppLovinMAX/Pods-AppLovinMAX.release.xcconfig"; sourceTree = "<group>"; };
|
|
@@ -75,9 +81,13 @@
|
|
|
75
81
|
1D3CC34028C18441003E5A07 /* AppLovinMAXAdView.m */,
|
|
76
82
|
1D2890F3251ABC83004F1CC4 /* AppLovinMAXAdViewManager.h */,
|
|
77
83
|
1D2890F4251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m */,
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
7A47215428D8968800854002 /* AppLovinMAXNativeAdView.h */,
|
|
85
|
+
7A47215328D8968800854002 /* AppLovinMAXNativeAdView.m */,
|
|
86
|
+
7A47215128D8968100854002 /* AppLovinMAXNativeAdViewManager.h */,
|
|
87
|
+
7A47214F28D8968100854002 /* AppLovinMAXNativeAdViewManager.m */,
|
|
80
88
|
1E696A0F28A9ED7C75EC4EC0 /* Frameworks */,
|
|
89
|
+
B20EE642686C6BAEB6C5B87A /* Pods */,
|
|
90
|
+
134814211AA4EA7D00B7C361 /* Products */,
|
|
81
91
|
);
|
|
82
92
|
sourceTree = "<group>";
|
|
83
93
|
};
|
|
@@ -173,7 +183,9 @@
|
|
|
173
183
|
isa = PBXSourcesBuildPhase;
|
|
174
184
|
buildActionMask = 2147483647;
|
|
175
185
|
files = (
|
|
186
|
+
7A47215228D8968100854002 /* AppLovinMAXNativeAdViewManager.m in Sources */,
|
|
176
187
|
1D2890F5251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m in Sources */,
|
|
188
|
+
7A47215728D8968800854002 /* AppLovinMAXNativeAdView.m in Sources */,
|
|
177
189
|
1D3CC34128C18441003E5A07 /* AppLovinMAXAdView.m in Sources */,
|
|
178
190
|
1DEA13CD24B9258700D42847 /* AppLovinMAX.m in Sources */,
|
|
179
191
|
);
|
package/ios/AppLovinMAX.xcworkspace/xcuserdata/thomasso.xcuserdatad/UserInterfaceState.xcuserstate
CHANGED
|
Binary file
|
package/ios/AppLovinMAXAdView.h
CHANGED
package/ios/AppLovinMAXAdView.m
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AppLovinMAXNativeAdView.h
|
|
3
|
+
// AppLovin MAX React Native Module
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2022 AppLovin. All rights reserved.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <React/RCTUIManager.h>
|
|
9
|
+
|
|
10
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Represents a container view for a native ad.
|
|
14
|
+
*/
|
|
15
|
+
@interface AppLovinMAXNativeAdView : UIView
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Loads a native ad, called by JavaScript via the View Manager.
|
|
19
|
+
*/
|
|
20
|
+
- (void)loadAd;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
- (instancetype)initWithBridge:(RCTBridge *)bridge;
|
|
24
|
+
|
|
25
|
+
@end
|
|
26
|
+
|
|
27
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AppLovinMAXNativeAdView.m
|
|
3
|
+
// AppLovin MAX React Native Module
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2022 AppLovin. All rights reserved.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <React/RCTUIManagerUtils.h>
|
|
9
|
+
#import <React/RCTImageView.h>
|
|
10
|
+
#import <AppLovinSDK/AppLovinSDK.h>
|
|
11
|
+
#import "AppLovinMAX.h"
|
|
12
|
+
#import "AppLovinMAXNativeAdView.h"
|
|
13
|
+
|
|
14
|
+
@interface MANativeAdLoader()
|
|
15
|
+
- (void)registerClickableViews:(NSArray<UIView *> *)clickableViews
|
|
16
|
+
withContainer:(UIView *)container
|
|
17
|
+
forAd:(MAAd *)ad;
|
|
18
|
+
- (void)handleNativeAdViewRenderedForAd:(MAAd *)ad;
|
|
19
|
+
@end
|
|
20
|
+
|
|
21
|
+
@interface AppLovinMAXNativeAdView()<MANativeAdDelegate>
|
|
22
|
+
|
|
23
|
+
@property (nonatomic, weak) RCTBridge *bridge;
|
|
24
|
+
@property (nonatomic, strong, nullable) MANativeAdLoader *adLoader;
|
|
25
|
+
@property (nonatomic, strong, nullable) MAAd *nativeAd;
|
|
26
|
+
@property (nonatomic, strong) ALAtomicBoolean *isLoading; // Guard against repeated ad loads
|
|
27
|
+
|
|
28
|
+
// JavaScript properties
|
|
29
|
+
@property (nonatomic, copy) NSString *adUnitId;
|
|
30
|
+
@property (nonatomic, copy, nullable) NSString *placement;
|
|
31
|
+
@property (nonatomic, copy, nullable) NSString *customData;
|
|
32
|
+
@property (nonatomic, copy, nullable) NSDictionary *extraParameters;
|
|
33
|
+
|
|
34
|
+
// Callback to `AppLovinNativeAdView.js`
|
|
35
|
+
@property (nonatomic, copy) RCTDirectEventBlock onAdLoaded;
|
|
36
|
+
|
|
37
|
+
// TODO: Allow publisher to select which views are clickable and which isn't via prop
|
|
38
|
+
@property (nonatomic, strong) NSMutableArray<UIView *> *clickableViews;
|
|
39
|
+
|
|
40
|
+
@end
|
|
41
|
+
|
|
42
|
+
@implementation AppLovinMAXNativeAdView
|
|
43
|
+
|
|
44
|
+
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
|
45
|
+
{
|
|
46
|
+
self = [super init];
|
|
47
|
+
if ( self )
|
|
48
|
+
{
|
|
49
|
+
self.bridge = bridge;
|
|
50
|
+
self.isLoading = [[ALAtomicBoolean alloc] init];
|
|
51
|
+
self.clickableViews = [NSMutableArray array];
|
|
52
|
+
}
|
|
53
|
+
return self;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Lazily loaded for when Ad Unit ID is available
|
|
57
|
+
- (nullable MANativeAdLoader *)adLoader
|
|
58
|
+
{
|
|
59
|
+
if ( ![self.adUnitId al_isValidString] ) return nil;
|
|
60
|
+
|
|
61
|
+
if ( ![self.adUnitId isEqualToString: _adLoader.adUnitIdentifier] )
|
|
62
|
+
{
|
|
63
|
+
_adLoader = [[MANativeAdLoader alloc] initWithAdUnitIdentifier: self.adUnitId sdk: [AppLovinMAX shared].sdk];
|
|
64
|
+
_adLoader.nativeAdDelegate = self;
|
|
65
|
+
_adLoader.revenueDelegate = [AppLovinMAX shared];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return _adLoader;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
- (void)didMoveToWindow
|
|
72
|
+
{
|
|
73
|
+
[super didMoveToWindow];
|
|
74
|
+
|
|
75
|
+
if ( !self.window )
|
|
76
|
+
{
|
|
77
|
+
[self destroyCurrentAdIfNeeded];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
- (void)setAdUnitId:(NSString *)adUnitId
|
|
82
|
+
{
|
|
83
|
+
if ( ![adUnitId al_isValidString] ) return;
|
|
84
|
+
|
|
85
|
+
_adUnitId = adUnitId;
|
|
86
|
+
|
|
87
|
+
// Explicitly invoke ad load now that Ad Unit ID is set, but do so after 0.25s to allow other props to set
|
|
88
|
+
dispatchOnMainQueueAfter(0.25, ^{
|
|
89
|
+
[self loadAd];
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Called when Ad Unit ID is set, and via RN layer
|
|
94
|
+
- (void)loadAd
|
|
95
|
+
{
|
|
96
|
+
if ( [self.isLoading compareAndSet: NO update: YES] )
|
|
97
|
+
{
|
|
98
|
+
[[AppLovinMAX shared] log: @"Loading a native ad for Ad Unit ID: %@...", self.adUnitId];
|
|
99
|
+
|
|
100
|
+
self.adLoader.placement = self.placement;
|
|
101
|
+
self.adLoader.customData = self.customData;
|
|
102
|
+
|
|
103
|
+
for ( NSString *key in self.extraParameters )
|
|
104
|
+
{
|
|
105
|
+
[self.adLoader setExtraParameterForKey: key value: self.extraParameters[key]];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
[self.adLoader loadAd];
|
|
109
|
+
}
|
|
110
|
+
else
|
|
111
|
+
{
|
|
112
|
+
[[AppLovinMAX shared] log: @"Ignoring request to load native ad for Ad Unit ID %@, another ad load in progress", self.adUnitId];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
#pragma mark - Views to Replace
|
|
117
|
+
|
|
118
|
+
- (void)setTitleView:(NSNumber *)tag
|
|
119
|
+
{
|
|
120
|
+
if ( !self.nativeAd.nativeAd.title ) return;
|
|
121
|
+
|
|
122
|
+
UIView *view = [self.bridge.uiManager viewForReactTag: tag];
|
|
123
|
+
[self.clickableViews addObject: view];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
- (void)setAdvertiserView:(NSNumber *)tag
|
|
127
|
+
{
|
|
128
|
+
if ( !self.nativeAd.nativeAd.advertiser ) return;
|
|
129
|
+
|
|
130
|
+
UIView *view = [self.bridge.uiManager viewForReactTag: tag];
|
|
131
|
+
[self.clickableViews addObject: view];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
- (void)setBodyView:(NSNumber *)tag
|
|
135
|
+
{
|
|
136
|
+
if ( !self.nativeAd.nativeAd.body ) return;
|
|
137
|
+
|
|
138
|
+
UIView *view = [self.bridge.uiManager viewForReactTag: tag];
|
|
139
|
+
[self.clickableViews addObject: view];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
- (void)setCallToActionView:(NSNumber *)tag
|
|
143
|
+
{
|
|
144
|
+
if ( !self.nativeAd.nativeAd.callToAction ) return;
|
|
145
|
+
|
|
146
|
+
UIView *view = [self.bridge.uiManager viewForReactTag: tag];
|
|
147
|
+
[self.clickableViews addObject: view];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
- (void)setMediaView:(NSNumber *)tag
|
|
151
|
+
{
|
|
152
|
+
if ( !self.nativeAd.nativeAd.mediaView ) return;
|
|
153
|
+
|
|
154
|
+
UIView *view = [self.bridge.uiManager viewForReactTag: tag];
|
|
155
|
+
[self.clickableViews addObject: view];
|
|
156
|
+
|
|
157
|
+
[view addSubview: self.nativeAd.nativeAd.mediaView];
|
|
158
|
+
[self.nativeAd.nativeAd.mediaView al_pinToSuperview];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
- (void)setOptionsView:(NSNumber *)tag
|
|
162
|
+
{
|
|
163
|
+
if ( !self.nativeAd.nativeAd.optionsView ) return;
|
|
164
|
+
|
|
165
|
+
UIView *view = [self.bridge.uiManager viewForReactTag: tag];
|
|
166
|
+
|
|
167
|
+
[view addSubview: self.nativeAd.nativeAd.optionsView];
|
|
168
|
+
[self.nativeAd.nativeAd.optionsView al_pinToSuperview];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
- (void)setIconView:(NSNumber *)tag
|
|
172
|
+
{
|
|
173
|
+
UIView *view = [self.bridge.uiManager viewForReactTag: tag];
|
|
174
|
+
if ( ![view isKindOfClass: [RCTImageView class]] )
|
|
175
|
+
{
|
|
176
|
+
[[AppLovinMAX shared] log: @"Cannot find an icon image view with tag \"%@\" for %@", tag, self.adUnitId];
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
[self.clickableViews addObject: view];
|
|
181
|
+
|
|
182
|
+
MANativeAdImage *icon = self.nativeAd.nativeAd.icon;
|
|
183
|
+
|
|
184
|
+
// Check if "URL" was missing and therefore need to set the image data
|
|
185
|
+
if ( !icon.URL && icon.image )
|
|
186
|
+
{
|
|
187
|
+
RCTImageView *iconImageView = (RCTImageView *) view;
|
|
188
|
+
iconImageView.defaultImage = self.nativeAd.nativeAd.icon.image;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
#pragma mark - Ad Loader Delegate
|
|
193
|
+
|
|
194
|
+
- (void)didLoadNativeAd:(nullable MANativeAdView *)nativeAdView forAd:(MAAd *)ad
|
|
195
|
+
{
|
|
196
|
+
[[AppLovinMAX shared] log: @"Native ad loaded: %@", ad];
|
|
197
|
+
|
|
198
|
+
// Log a warning if it is a template native ad returned - as our plugin will be responsible for re-rendering the native ad's assets
|
|
199
|
+
if ( nativeAdView )
|
|
200
|
+
{
|
|
201
|
+
[self.isLoading set: NO];
|
|
202
|
+
|
|
203
|
+
[[AppLovinMAX shared] log: @"Native ad is of template type, failing ad load..."];
|
|
204
|
+
[[AppLovinMAX shared] handleNativeAdLoadFailureForAdUnitIdentifier: self.adUnitId error: nil];
|
|
205
|
+
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
[self destroyCurrentAdIfNeeded];
|
|
210
|
+
|
|
211
|
+
self.nativeAd = ad;
|
|
212
|
+
|
|
213
|
+
// Notify `AppLovinNativeAdView.js`
|
|
214
|
+
[self sendAdLoadedReactNativeEventForAd: ad.nativeAd];
|
|
215
|
+
|
|
216
|
+
// After notifying the RN layer - have slight delay to let views bind to this layer in `clickableViews` before registering
|
|
217
|
+
dispatchOnMainQueueAfter(0.5, ^{
|
|
218
|
+
|
|
219
|
+
// Notify publisher
|
|
220
|
+
[[AppLovinMAX shared] didLoadAd: ad];
|
|
221
|
+
|
|
222
|
+
[self.adLoader registerClickableViews: self.clickableViews withContainer: self forAd: ad];
|
|
223
|
+
[self.adLoader handleNativeAdViewRenderedForAd: ad];
|
|
224
|
+
|
|
225
|
+
[self.isLoading set: NO];
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
- (void)sendAdLoadedReactNativeEventForAd:(MANativeAd *)ad
|
|
230
|
+
{
|
|
231
|
+
NSMutableDictionary<NSString *, id> *jsNativeAd = [NSMutableDictionary dictionaryWithCapacity: 6];
|
|
232
|
+
|
|
233
|
+
if ( ad.title )
|
|
234
|
+
{
|
|
235
|
+
jsNativeAd[@"title"] = ad.title;
|
|
236
|
+
}
|
|
237
|
+
if ( ad.advertiser )
|
|
238
|
+
{
|
|
239
|
+
jsNativeAd[@"advertiser"] = ad.advertiser;
|
|
240
|
+
}
|
|
241
|
+
if ( ad.body )
|
|
242
|
+
{
|
|
243
|
+
jsNativeAd[@"body"] = ad.body;
|
|
244
|
+
}
|
|
245
|
+
if ( ad.callToAction )
|
|
246
|
+
{
|
|
247
|
+
jsNativeAd[@"callToAction"] = ad.callToAction;
|
|
248
|
+
}
|
|
249
|
+
if ( ad.icon )
|
|
250
|
+
{
|
|
251
|
+
if ( ad.icon.URL )
|
|
252
|
+
{
|
|
253
|
+
jsNativeAd[@"url"] = ad.icon.URL.absoluteString;
|
|
254
|
+
}
|
|
255
|
+
else if ( ad.icon.image )
|
|
256
|
+
{
|
|
257
|
+
jsNativeAd[@"image"] = @(YES);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if ( !isnan(ad.mediaContentAspectRatio) )
|
|
261
|
+
{
|
|
262
|
+
jsNativeAd[@"mediaContentAspectRatio"] = @(ad.mediaContentAspectRatio);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Send to `AppLovinNativeAdView.js` to render the views
|
|
266
|
+
self.onAdLoaded(jsNativeAd);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
- (void)didFailToLoadNativeAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error
|
|
270
|
+
{
|
|
271
|
+
[self.isLoading set: NO];
|
|
272
|
+
|
|
273
|
+
[[AppLovinMAX shared] log: @"Failed to load native ad for Ad Unit ID %@ with error: %@", self.adUnitId, error];
|
|
274
|
+
|
|
275
|
+
// Notify publisher
|
|
276
|
+
[[AppLovinMAX shared] handleNativeAdLoadFailureForAdUnitIdentifier: self.adUnitId error: error];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
- (void)didClickNativeAd:(MAAd *)ad
|
|
280
|
+
{
|
|
281
|
+
[[AppLovinMAX shared] didClickAd: ad];
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
- (void)destroyCurrentAdIfNeeded
|
|
285
|
+
{
|
|
286
|
+
if ( self.nativeAd )
|
|
287
|
+
{
|
|
288
|
+
if ( self.nativeAd.nativeAd )
|
|
289
|
+
{
|
|
290
|
+
if ( self.nativeAd.nativeAd.mediaView )
|
|
291
|
+
{
|
|
292
|
+
[self.nativeAd.nativeAd.mediaView removeFromSuperview];
|
|
293
|
+
}
|
|
294
|
+
if ( self.nativeAd.nativeAd.optionsView )
|
|
295
|
+
{
|
|
296
|
+
[self.nativeAd.nativeAd.optionsView removeFromSuperview];
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
[self.adLoader destroyAd: self.nativeAd];
|
|
301
|
+
|
|
302
|
+
self.nativeAd = nil;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
[self.clickableViews removeAllObjects];
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
@end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AppLovinMAXNativeAdViewManager.h
|
|
3
|
+
// AppLovin MAX React Native Module
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2022 AppLovin. All rights reserved.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <React/RCTViewManager.h>
|
|
9
|
+
|
|
10
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A view manager for AppLovinMAXNativeAdView
|
|
14
|
+
*/
|
|
15
|
+
@interface AppLovinMAXNativeAdViewManager : RCTViewManager
|
|
16
|
+
|
|
17
|
+
@end
|
|
18
|
+
|
|
19
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AppLovinMAXNativeAdViewManager.m
|
|
3
|
+
// AppLovin MAX React Native Module
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2022 AppLovin. All rights reserved.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import "AppLovinMAX.h"
|
|
9
|
+
#import "AppLovinMAXNativeAdViewManager.h"
|
|
10
|
+
#import "AppLovinMAXNativeAdView.h"
|
|
11
|
+
|
|
12
|
+
@implementation AppLovinMAXNativeAdViewManager
|
|
13
|
+
|
|
14
|
+
RCT_EXPORT_MODULE(AppLovinMAXNativeAdView)
|
|
15
|
+
|
|
16
|
+
// Props
|
|
17
|
+
RCT_EXPORT_VIEW_PROPERTY(adUnitId, NSString)
|
|
18
|
+
RCT_EXPORT_VIEW_PROPERTY(placement, NSString)
|
|
19
|
+
RCT_EXPORT_VIEW_PROPERTY(customData, NSString)
|
|
20
|
+
RCT_EXPORT_VIEW_PROPERTY(extraParameters, NSDictionary)
|
|
21
|
+
|
|
22
|
+
// Callback
|
|
23
|
+
RCT_EXPORT_VIEW_PROPERTY(onAdLoaded, RCTDirectEventBlock)
|
|
24
|
+
|
|
25
|
+
// Asset views
|
|
26
|
+
RCT_EXPORT_VIEW_PROPERTY(titleView, NSNumber)
|
|
27
|
+
RCT_EXPORT_VIEW_PROPERTY(advertiserView, NSNumber)
|
|
28
|
+
RCT_EXPORT_VIEW_PROPERTY(bodyView, NSNumber)
|
|
29
|
+
RCT_EXPORT_VIEW_PROPERTY(callToActionView, NSNumber)
|
|
30
|
+
RCT_EXPORT_VIEW_PROPERTY(iconView, NSNumber)
|
|
31
|
+
RCT_EXPORT_VIEW_PROPERTY(optionsView, NSNumber)
|
|
32
|
+
RCT_EXPORT_VIEW_PROPERTY(mediaView, NSNumber)
|
|
33
|
+
|
|
34
|
+
+ (BOOL)requiresMainQueueSetup
|
|
35
|
+
{
|
|
36
|
+
return YES;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (UIView *)view
|
|
40
|
+
{
|
|
41
|
+
return [[AppLovinMAXNativeAdView alloc] initWithBridge: self.bridge];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
RCT_EXPORT_METHOD(loadAd:(nonnull NSNumber *)viewTag)
|
|
45
|
+
{
|
|
46
|
+
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
47
|
+
|
|
48
|
+
UIView *view = viewRegistry[viewTag];
|
|
49
|
+
if ( ![view isKindOfClass: [AppLovinMAXNativeAdView class]] )
|
|
50
|
+
{
|
|
51
|
+
[[AppLovinMAX shared] log: @"Cannot find AppLovinMAXNativeAdView with tag %@", viewTag];
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
AppLovinMAXNativeAdView *nativeAdView = (AppLovinMAXNativeAdView *) view;
|
|
56
|
+
[nativeAdView loadAd];
|
|
57
|
+
}];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@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.5.
|
|
38
|
+
pod 'AppLovinSDK', '11.5.3'
|
|
39
39
|
|
|
40
40
|
end
|
package/ios/Podfile.lock
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
PODS:
|
|
2
|
-
- AppLovinSDK (11.5.
|
|
2
|
+
- AppLovinSDK (11.5.3)
|
|
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.5.
|
|
252
|
+
- AppLovinSDK (= 11.5.3)
|
|
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: 6b10288343b15b31f7037ecd7aa630d6ea117585
|
|
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: 0c10edf9192bf11ff0acfafe564110bde14135a5
|
|
372
372
|
|
|
373
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": "
|
|
4
|
+
"version": "4.0.0",
|
|
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_4_0_0" }
|
|
15
15
|
|
|
16
16
|
s.source_files = "ios/AppLovinMAX*.{h,m}"
|
|
17
17
|
|
|
18
18
|
s.dependency "React"
|
|
19
|
-
s.dependency "AppLovinSDK", "11.5.
|
|
19
|
+
s.dependency "AppLovinSDK", "11.5.3"
|
|
20
20
|
end
|