react-native-applovin-max 6.2.2 → 6.2.3
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 +2 -2
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdView.java +21 -1
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewManager.java +30 -0
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXModule.java +5 -0
- package/ios/AppLovinMAX.m +5 -0
- package/ios/AppLovinMAXAdView.h +2 -0
- package/ios/AppLovinMAXAdView.m +21 -1
- package/ios/AppLovinMAXAdViewManager.m +18 -0
- package/package.json +1 -1
- package/react-native-applovin-max.podspec +1 -1
- package/src/AdView.tsx +51 -24
- package/src/AppLovinMAX.ts +1 -1
- package/src/types/AdViewProps.ts +16 -0
package/android/build.gradle
CHANGED
|
@@ -43,6 +43,7 @@ class AppLovinMAXAdView
|
|
|
43
43
|
private String customData;
|
|
44
44
|
private boolean adaptiveBannerEnabled;
|
|
45
45
|
private boolean autoRefresh;
|
|
46
|
+
private boolean loadOnMount;
|
|
46
47
|
@Nullable
|
|
47
48
|
private Map<String, Object> extraParameters;
|
|
48
49
|
@Nullable
|
|
@@ -146,6 +147,11 @@ class AppLovinMAXAdView
|
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
149
|
|
|
150
|
+
public void setLoadOnMount(final boolean enabled)
|
|
151
|
+
{
|
|
152
|
+
loadOnMount = enabled;
|
|
153
|
+
}
|
|
154
|
+
|
|
149
155
|
public void setExtraParameters(@Nullable final ReadableMap readableMap)
|
|
150
156
|
{
|
|
151
157
|
if ( readableMap != null )
|
|
@@ -273,7 +279,10 @@ class AppLovinMAXAdView
|
|
|
273
279
|
adView.stopAutoRefresh();
|
|
274
280
|
}
|
|
275
281
|
|
|
276
|
-
|
|
282
|
+
if ( loadOnMount )
|
|
283
|
+
{
|
|
284
|
+
adView.loadAd();
|
|
285
|
+
}
|
|
277
286
|
|
|
278
287
|
addView( adView );
|
|
279
288
|
|
|
@@ -281,6 +290,17 @@ class AppLovinMAXAdView
|
|
|
281
290
|
}, 250 );
|
|
282
291
|
}
|
|
283
292
|
|
|
293
|
+
public void loadAd()
|
|
294
|
+
{
|
|
295
|
+
if ( adView == null )
|
|
296
|
+
{
|
|
297
|
+
AppLovinMAXModule.e( "Attempting to load uninitialized MaxAdView for " + adUnitId );
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
adView.loadAd();
|
|
302
|
+
}
|
|
303
|
+
|
|
284
304
|
public void destroy()
|
|
285
305
|
{
|
|
286
306
|
if ( adView != null )
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.applovin.reactnative;
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
4
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
4
5
|
import com.facebook.react.bridge.ReadableMap;
|
|
5
6
|
import com.facebook.react.common.MapBuilder;
|
|
6
7
|
import com.facebook.react.uimanager.SimpleViewManager;
|
|
@@ -9,6 +10,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
|
|
9
10
|
|
|
10
11
|
import java.util.Map;
|
|
11
12
|
|
|
13
|
+
import androidx.annotation.NonNull;
|
|
12
14
|
import androidx.annotation.Nullable;
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -17,6 +19,8 @@ import androidx.annotation.Nullable;
|
|
|
17
19
|
class AppLovinMAXAdViewManager
|
|
18
20
|
extends SimpleViewManager<AppLovinMAXAdView>
|
|
19
21
|
{
|
|
22
|
+
private static final int COMMAND_LOAD_AD = 1;
|
|
23
|
+
|
|
20
24
|
public AppLovinMAXAdViewManager(final ReactApplicationContext reactApplicationContext) { }
|
|
21
25
|
|
|
22
26
|
@Override
|
|
@@ -41,6 +45,26 @@ class AppLovinMAXAdViewManager
|
|
|
41
45
|
.build();
|
|
42
46
|
}
|
|
43
47
|
|
|
48
|
+
@Nullable
|
|
49
|
+
@Override
|
|
50
|
+
public Map<String, Integer> getCommandsMap()
|
|
51
|
+
{
|
|
52
|
+
return MapBuilder.of(
|
|
53
|
+
"loadAd", COMMAND_LOAD_AD
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Override
|
|
58
|
+
public void receiveCommand(@NonNull final AppLovinMAXAdView view, final int commandId, @Nullable final ReadableArray args)
|
|
59
|
+
{
|
|
60
|
+
switch ( commandId )
|
|
61
|
+
{
|
|
62
|
+
case COMMAND_LOAD_AD:
|
|
63
|
+
view.loadAd();
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
44
68
|
@Override
|
|
45
69
|
protected AppLovinMAXAdView createViewInstance(final ThemedReactContext reactContext)
|
|
46
70
|
{
|
|
@@ -84,6 +108,12 @@ class AppLovinMAXAdViewManager
|
|
|
84
108
|
view.setAutoRefresh( enabled );
|
|
85
109
|
}
|
|
86
110
|
|
|
111
|
+
@ReactProp(name = "loadOnMount")
|
|
112
|
+
public void setLoadOnMount(final AppLovinMAXAdView view, final boolean enabled)
|
|
113
|
+
{
|
|
114
|
+
view.setLoadOnMount( enabled );
|
|
115
|
+
}
|
|
116
|
+
|
|
87
117
|
@ReactProp(name = "extraParameters")
|
|
88
118
|
public void setExtraParameters(final AppLovinMAXAdView view, @Nullable final ReadableMap value)
|
|
89
119
|
{
|
|
@@ -2747,6 +2747,11 @@ public class AppLovinMAXModule
|
|
|
2747
2747
|
setAmazonResult( result, adUnitId, MaxAdFormat.INTERSTITIAL );
|
|
2748
2748
|
}
|
|
2749
2749
|
|
|
2750
|
+
public void setAmazonRewardedResult(final Object result, final String adUnitId)
|
|
2751
|
+
{
|
|
2752
|
+
setAmazonResult( result, adUnitId, MaxAdFormat.REWARDED );
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2750
2755
|
private void setAmazonResult(final Object result, final String adUnitId, final MaxAdFormat adFormat)
|
|
2751
2756
|
{
|
|
2752
2757
|
if ( sdk == null )
|
package/ios/AppLovinMAX.m
CHANGED
|
@@ -2292,6 +2292,11 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
|
|
|
2292
2292
|
[self setAmazonResult: result forAdUnitIdentifier: adUnitIdentifier adFormat: MAAdFormat.interstitial];
|
|
2293
2293
|
}
|
|
2294
2294
|
|
|
2295
|
+
- (void)setAmazonResult:(id)result forRewardedAdUnitIdentifier:(NSString *)adUnitIdentifier
|
|
2296
|
+
{
|
|
2297
|
+
[self setAmazonResult: result forAdUnitIdentifier: adUnitIdentifier adFormat: MAAdFormat.rewarded];
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2295
2300
|
- (void)setAmazonResult:(id /* DTBAdResponse or DTBAdErrorInfo */)result forAdUnitIdentifier:(NSString *)adUnitIdentifier adFormat:(MAAdFormat *)adFormat
|
|
2296
2301
|
{
|
|
2297
2302
|
if ( !self.sdk )
|
package/ios/AppLovinMAXAdView.h
CHANGED
package/ios/AppLovinMAXAdView.m
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
@property (nonatomic, copy, nullable) NSString *customData;
|
|
21
21
|
@property (nonatomic, assign, readonly, getter=isAdaptiveBannerEnabled) BOOL adaptiveBannerEnabled;
|
|
22
22
|
@property (nonatomic, assign, readonly, getter=isAutoRefresh) BOOL autoRefresh;
|
|
23
|
+
@property (nonatomic, assign, readonly, getter=isLoadOnMount) BOOL loadOnMount;
|
|
23
24
|
@property (nonatomic, copy, nullable) NSDictionary *extraParameters;
|
|
24
25
|
@property (nonatomic, copy, nullable) NSDictionary *localExtraParameters;
|
|
25
26
|
|
|
@@ -135,6 +136,11 @@ static NSMutableDictionary<NSString *, MAAdView *> *adViewInstances;
|
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
|
|
139
|
+
- (void)setLoadOnMount:(BOOL)loadOnMount
|
|
140
|
+
{
|
|
141
|
+
_loadOnMount = loadOnMount;
|
|
142
|
+
}
|
|
143
|
+
|
|
138
144
|
- (void)attachAdViewIfNeeded
|
|
139
145
|
{
|
|
140
146
|
// Re-assign in case of race condition
|
|
@@ -202,7 +208,10 @@ static NSMutableDictionary<NSString *, MAAdView *> *adViewInstances;
|
|
|
202
208
|
[self.adView stopAutoRefresh];
|
|
203
209
|
}
|
|
204
210
|
|
|
205
|
-
[self
|
|
211
|
+
if ( [self isLoadOnMount] )
|
|
212
|
+
{
|
|
213
|
+
[self.adView loadAd];
|
|
214
|
+
}
|
|
206
215
|
|
|
207
216
|
[self addSubview: self.adView];
|
|
208
217
|
|
|
@@ -215,6 +224,17 @@ static NSMutableDictionary<NSString *, MAAdView *> *adViewInstances;
|
|
|
215
224
|
});
|
|
216
225
|
}
|
|
217
226
|
|
|
227
|
+
- (void)loadAd
|
|
228
|
+
{
|
|
229
|
+
if ( !self.adView )
|
|
230
|
+
{
|
|
231
|
+
[[AppLovinMAX shared] log: @"Attempting to load uninitialized MAAdView for %@", self.adUnitId];
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
[self.adView loadAd];
|
|
236
|
+
}
|
|
237
|
+
|
|
218
238
|
- (void)didMoveToWindow
|
|
219
239
|
{
|
|
220
240
|
[super didMoveToWindow];
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// Copyright © 2020 AppLovin. All rights reserved.
|
|
7
7
|
//
|
|
8
8
|
|
|
9
|
+
#import "AppLovinMAX.h"
|
|
9
10
|
#import "AppLovinMAXAdViewManager.h"
|
|
10
11
|
#import "AppLovinMAXAdview.h"
|
|
11
12
|
|
|
@@ -19,6 +20,7 @@ RCT_EXPORT_VIEW_PROPERTY(placement, NSString)
|
|
|
19
20
|
RCT_EXPORT_VIEW_PROPERTY(customData, NSString)
|
|
20
21
|
RCT_EXPORT_VIEW_PROPERTY(adaptiveBannerEnabled, BOOL)
|
|
21
22
|
RCT_EXPORT_VIEW_PROPERTY(autoRefresh, BOOL)
|
|
23
|
+
RCT_EXPORT_VIEW_PROPERTY(loadOnMount, BOOL)
|
|
22
24
|
RCT_EXPORT_VIEW_PROPERTY(extraParameters, NSDictionary)
|
|
23
25
|
RCT_EXPORT_VIEW_PROPERTY(localExtraParameters, NSDictionary)
|
|
24
26
|
|
|
@@ -40,4 +42,20 @@ RCT_EXPORT_VIEW_PROPERTY(onAdRevenuePaidEvent, RCTDirectEventBlock)
|
|
|
40
42
|
return [[AppLovinMAXAdView alloc] init];
|
|
41
43
|
}
|
|
42
44
|
|
|
45
|
+
RCT_EXPORT_METHOD(loadAd:(nonnull NSNumber *)viewTag)
|
|
46
|
+
{
|
|
47
|
+
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
48
|
+
|
|
49
|
+
UIView *view = viewRegistry[viewTag];
|
|
50
|
+
if ( ![view isKindOfClass: [AppLovinMAXAdView class]] )
|
|
51
|
+
{
|
|
52
|
+
[[AppLovinMAX shared] log: @"Cannot find AppLovinMAXAdView with tag %@", viewTag];
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
AppLovinMAXAdView *adView = (AppLovinMAXAdView *) view;
|
|
57
|
+
[adView loadAd];
|
|
58
|
+
}];
|
|
59
|
+
}
|
|
60
|
+
|
|
43
61
|
@end
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-applovin-max",
|
|
3
3
|
"author": "AppLovin Corporation",
|
|
4
|
-
"version": "6.2.
|
|
4
|
+
"version": "6.2.3",
|
|
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,7 +11,7 @@ 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_6_2_3" }
|
|
15
15
|
|
|
16
16
|
s.source_files = "ios/AppLovinMAX*.{h,m}"
|
|
17
17
|
|
package/src/AdView.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
3
|
-
import { NativeModules, requireNativeComponent, StyleSheet } from 'react-native';
|
|
4
|
-
import type { ViewProps, ViewStyle, StyleProp } from 'react-native';
|
|
2
|
+
import { useEffect, useState, useRef, useCallback, useImperativeHandle, forwardRef } from 'react';
|
|
3
|
+
import { NativeModules, requireNativeComponent, StyleSheet, UIManager, findNodeHandle } from 'react-native';
|
|
4
|
+
import type { ViewProps, ViewStyle, StyleProp, NativeMethods } from 'react-native';
|
|
5
5
|
import type { AdDisplayFailedInfo, AdInfo, AdLoadFailedInfo, AdRevenueInfo } from './types/AdInfo';
|
|
6
6
|
import type { AdNativeEvent } from './types/AdEvent';
|
|
7
|
-
import type { AdViewProps } from './types/AdViewProps';
|
|
7
|
+
import type { AdViewProps, AdViewHandler } from './types/AdViewProps';
|
|
8
8
|
|
|
9
9
|
const { AppLovinMAX } = NativeModules;
|
|
10
10
|
|
|
@@ -65,6 +65,8 @@ type AdViewNativeEvents = {
|
|
|
65
65
|
|
|
66
66
|
const AdViewComponent = requireNativeComponent<AdViewProps & ViewProps & AdViewNativeEvents>('AppLovinMAXAdView');
|
|
67
67
|
|
|
68
|
+
type AdViewType = React.Component<AdViewProps> & NativeMethods;
|
|
69
|
+
|
|
68
70
|
const ADVIEW_SIZE = {
|
|
69
71
|
banner: { width: 320, height: 50 },
|
|
70
72
|
leader: { width: 728, height: 90 },
|
|
@@ -161,28 +163,51 @@ const sizeAdViewDimensions = (
|
|
|
161
163
|
* />
|
|
162
164
|
* ```
|
|
163
165
|
*/
|
|
164
|
-
export const AdView = (
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
166
|
+
export const AdView = forwardRef<AdViewHandler, AdViewProps & ViewProps>(function AdView(
|
|
167
|
+
{
|
|
168
|
+
adUnitId,
|
|
169
|
+
adFormat,
|
|
170
|
+
placement,
|
|
171
|
+
customData,
|
|
172
|
+
adaptiveBannerEnabled = true,
|
|
173
|
+
autoRefresh = true,
|
|
174
|
+
loadOnMount = true,
|
|
175
|
+
extraParameters,
|
|
176
|
+
localExtraParameters,
|
|
177
|
+
onAdLoaded,
|
|
178
|
+
onAdLoadFailed,
|
|
179
|
+
onAdDisplayFailed,
|
|
180
|
+
onAdClicked,
|
|
181
|
+
onAdExpanded,
|
|
182
|
+
onAdCollapsed,
|
|
183
|
+
onAdRevenuePaid,
|
|
184
|
+
style,
|
|
185
|
+
...otherProps
|
|
186
|
+
},
|
|
187
|
+
ref
|
|
188
|
+
) {
|
|
189
|
+
const adViewRef = useRef<AdViewType | null>(null);
|
|
183
190
|
const [isInitialized, setIsInitialized] = useState<boolean>(false);
|
|
184
191
|
const [dimensions, setDimensions] = useState({});
|
|
185
192
|
|
|
193
|
+
const loadAd = () => {
|
|
194
|
+
if (adViewRef.current) {
|
|
195
|
+
UIManager.dispatchViewManagerCommand(
|
|
196
|
+
findNodeHandle(adViewRef.current),
|
|
197
|
+
UIManager.getViewManagerConfig('AppLovinMAXAdView').Commands.loadAd,
|
|
198
|
+
undefined
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
useImperativeHandle(ref, () => ({ loadAd }), []);
|
|
204
|
+
|
|
205
|
+
const saveElement = useCallback((element: AdViewType | null) => {
|
|
206
|
+
if (element) {
|
|
207
|
+
adViewRef.current = element;
|
|
208
|
+
}
|
|
209
|
+
}, []);
|
|
210
|
+
|
|
186
211
|
useEffect(() => {
|
|
187
212
|
AppLovinMAX.isInitialized().then((result: boolean) => {
|
|
188
213
|
setIsInitialized(result);
|
|
@@ -244,12 +269,14 @@ export const AdView = ({
|
|
|
244
269
|
|
|
245
270
|
return (
|
|
246
271
|
<AdViewComponent
|
|
272
|
+
ref={saveElement}
|
|
247
273
|
adUnitId={adUnitId}
|
|
248
274
|
adFormat={adFormat}
|
|
249
275
|
placement={placement}
|
|
250
276
|
customData={customData}
|
|
251
277
|
adaptiveBannerEnabled={adaptiveBannerEnabled}
|
|
252
278
|
autoRefresh={autoRefresh}
|
|
279
|
+
loadOnMount={loadOnMount}
|
|
253
280
|
extraParameters={extraParameters}
|
|
254
281
|
localExtraParameters={localExtraParameters}
|
|
255
282
|
onAdLoadedEvent={onAdLoadedEvent}
|
|
@@ -263,4 +290,4 @@ export const AdView = ({
|
|
|
263
290
|
{...otherProps}
|
|
264
291
|
/>
|
|
265
292
|
);
|
|
266
|
-
};
|
|
293
|
+
});
|
package/src/AppLovinMAX.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Configuration } from './types/Configuration';
|
|
|
4
4
|
|
|
5
5
|
const NativeAppLovinMAX = NativeModules.AppLovinMAX;
|
|
6
6
|
|
|
7
|
-
const VERSION = '6.2.
|
|
7
|
+
const VERSION = '6.2.3';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* This enum represents the user's geography used to determine the type of consent flow shown to the
|
package/src/types/AdViewProps.ts
CHANGED
|
@@ -2,6 +2,16 @@ import type { AdProps } from './AdProps';
|
|
|
2
2
|
import type { AdInfo } from './AdInfo';
|
|
3
3
|
import type { AdFormat } from '../AdView';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* A handler of {@link AdView}.
|
|
7
|
+
*/
|
|
8
|
+
export type AdViewHandler = {
|
|
9
|
+
/**
|
|
10
|
+
* If the {@link loadOnMount} attribute is set to false, you can call this API to start loading ads in this AdView.
|
|
11
|
+
*/
|
|
12
|
+
loadAd(): void;
|
|
13
|
+
};
|
|
14
|
+
|
|
5
15
|
/**
|
|
6
16
|
* Represents an {@link AdView} - Banner / MREC.
|
|
7
17
|
*/
|
|
@@ -23,6 +33,12 @@ export type AdViewProps = AdProps & {
|
|
|
23
33
|
*/
|
|
24
34
|
autoRefresh?: boolean;
|
|
25
35
|
|
|
36
|
+
/**
|
|
37
|
+
* A boolean value representing whether or not to load an ad as soon as {@link AdView} is
|
|
38
|
+
* mounted. Note that the default value is true.
|
|
39
|
+
*/
|
|
40
|
+
loadOnMount?: boolean;
|
|
41
|
+
|
|
26
42
|
/**
|
|
27
43
|
* A callback fuction that {@link AdView} fires when it expands the ad.
|
|
28
44
|
*/
|