react-native-applovin-max 6.2.1 → 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.
@@ -35,8 +35,8 @@ android {
35
35
  defaultConfig {
36
36
  minSdkVersion 16
37
37
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
38
- versionCode 6020100
39
- versionName "6.2.1"
38
+ versionCode 6020300
39
+ versionName "6.2.3"
40
40
  }
41
41
 
42
42
  flavorDimensions("default")
@@ -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
- adView.loadAd();
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
  {
@@ -37,6 +37,8 @@ import com.applovin.mediation.ads.MaxAppOpenAd;
37
37
  import com.applovin.mediation.ads.MaxInterstitialAd;
38
38
  import com.applovin.mediation.ads.MaxRewardedAd;
39
39
  import com.applovin.sdk.AppLovinAdContentRating;
40
+ import com.applovin.sdk.AppLovinCmpError;
41
+ import com.applovin.sdk.AppLovinCmpService;
40
42
  import com.applovin.sdk.AppLovinGender;
41
43
  import com.applovin.sdk.AppLovinMediationProvider;
42
44
  import com.applovin.sdk.AppLovinPrivacySettings;
@@ -668,6 +670,48 @@ public class AppLovinMAXModule
668
670
  debugUserGeographyToSet = userGeography;
669
671
  }
670
672
 
673
+ @ReactMethod
674
+ public void showCmpForExistingUser(final Promise promise)
675
+ {
676
+ if ( sdk == null )
677
+ {
678
+ logUninitializedAccessError( "showCmpForExistingUser", promise );
679
+ return;
680
+ }
681
+
682
+ Activity currentActivity = maybeGetCurrentActivity();
683
+ if ( currentActivity == null )
684
+ {
685
+ promise.reject( new IllegalStateException( "ERROR: Failed to execute showCmpForExistingUser() - unable to get current Activity." ) );
686
+ return;
687
+ }
688
+
689
+ AppLovinCmpService cmpService = sdk.getCmpService();
690
+ cmpService.showCmpForExistingUser( currentActivity, (@Nullable final AppLovinCmpError error) -> {
691
+
692
+ if ( error == null )
693
+ {
694
+ promise.resolve( null );
695
+ return;
696
+ }
697
+
698
+ promise.resolve( error.getCmpCode() );
699
+ } );
700
+ }
701
+
702
+ @ReactMethod
703
+ public void hasSupportedCmp(final Promise promise)
704
+ {
705
+ if ( sdk == null )
706
+ {
707
+ logUninitializedAccessError( "showCmpForExistingUser", promise );
708
+ return;
709
+ }
710
+
711
+ AppLovinCmpService cmpService = sdk.getCmpService();
712
+ promise.resolve( cmpService.hasSupportedCmp() );
713
+ }
714
+
671
715
  // Data Passing
672
716
 
673
717
  @ReactMethod
@@ -2389,7 +2433,20 @@ public class AppLovinMAXModule
2389
2433
 
2390
2434
  public static void logUninitializedAccessError(final String callingMethod)
2391
2435
  {
2392
- e( "ERROR: Failed to execute " + callingMethod + "() - please ensure the AppLovin MAX React Native module has been initialized by calling 'AppLovinMAX.initialize(...);'!" );
2436
+ logUninitializedAccessError( callingMethod, null );
2437
+ }
2438
+
2439
+ public static void logUninitializedAccessError(final String callingMethod, @Nullable final Promise promise)
2440
+ {
2441
+ String message = "ERROR: Failed to execute " + callingMethod + "() - please ensure the AppLovin MAX React Native module has been initialized by calling 'AppLovinMAX.initialize(...);'!";
2442
+
2443
+ if ( promise == null )
2444
+ {
2445
+ e( message );
2446
+ return;
2447
+ }
2448
+
2449
+ promise.reject( new IllegalStateException( message ) );
2393
2450
  }
2394
2451
 
2395
2452
  public static void d(final String message)
@@ -2690,6 +2747,11 @@ public class AppLovinMAXModule
2690
2747
  setAmazonResult( result, adUnitId, MaxAdFormat.INTERSTITIAL );
2691
2748
  }
2692
2749
 
2750
+ public void setAmazonRewardedResult(final Object result, final String adUnitId)
2751
+ {
2752
+ setAmazonResult( result, adUnitId, MaxAdFormat.REWARDED );
2753
+ }
2754
+
2693
2755
  private void setAmazonResult(final Object result, final String adUnitId, final MaxAdFormat adFormat)
2694
2756
  {
2695
2757
  if ( sdk == null )
@@ -2711,12 +2773,23 @@ public class AppLovinMAXModule
2711
2773
  MaxInterstitialAd interstitial = retrieveInterstitial( adUnitId, "setAmazonResult" );
2712
2774
  if ( interstitial == null )
2713
2775
  {
2714
- e( "Failed to set Amazon result - unable to retrieve interstitial" );
2776
+ e( "Failed to set Amazon result - unable to find interstitial" );
2715
2777
  return;
2716
2778
  }
2717
2779
 
2718
2780
  interstitial.setLocalExtraParameter( key, result );
2719
2781
  }
2782
+ else if ( adFormat == MaxAdFormat.REWARDED )
2783
+ {
2784
+ MaxRewardedAd rewardedAd = retrieveRewardedAd( adUnitId, "setAmazonResult" );
2785
+ if ( rewardedAd == null )
2786
+ {
2787
+ e( "Failed to set Amazon result - unable to find rewarded ad" );
2788
+ return;
2789
+ }
2790
+
2791
+ rewardedAd.setLocalExtraParameter( key, result );
2792
+ }
2720
2793
  else // MaxAdFormat.BANNER or MaxAdFormat.MREC
2721
2794
  {
2722
2795
  MaxAdView adView = AppLovinMAXAdView.getInstance( adUnitId );
@@ -2732,7 +2805,7 @@ public class AppLovinMAXModule
2732
2805
  }
2733
2806
  else
2734
2807
  {
2735
- e( "Failed to set Amazon result - unable to retrieve " + adFormat );
2808
+ e( "Failed to set Amazon result - unable to find " + adFormat );
2736
2809
  }
2737
2810
  }
2738
2811
  }
@@ -471,7 +471,7 @@ public class AppLovinMAXNativeAdView
471
471
 
472
472
  private static void sizeToFit(final @Nullable View view, final View parentView)
473
473
  {
474
- if ( view != null )
474
+ if ( view != null && parentView != null )
475
475
  {
476
476
  view.measure( MeasureSpec.makeMeasureSpec( parentView.getWidth(), MeasureSpec.EXACTLY ),
477
477
  MeasureSpec.makeMeasureSpec( parentView.getHeight(), MeasureSpec.EXACTLY ) );
package/ios/AppLovinMAX.m CHANGED
@@ -554,6 +554,39 @@ RCT_EXPORT_METHOD(setConsentFlowDebugUserGeography:(NSString *)userGeography)
554
554
  self.debugUserGeographyToSet = userGeography;
555
555
  }
556
556
 
557
+ RCT_EXPORT_METHOD(showCmpForExistingUser:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
558
+ {
559
+ if ( !self.sdk )
560
+ {
561
+ [self logUninitializedAccessError: @"showCmpForExistingUser" withPromiseReject: reject];
562
+ return;
563
+ }
564
+
565
+ ALCMPService *cmpService = self.sdk.cmpService;
566
+ [cmpService showCMPForExistingUserWithCompletion:^(ALCMPError * _Nullable error) {
567
+
568
+ if ( !error )
569
+ {
570
+ resolve(nil);
571
+ return;
572
+ }
573
+
574
+ resolve(@(error.code));
575
+ }];
576
+ }
577
+
578
+ RCT_EXPORT_METHOD(hasSupportedCmp:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
579
+ {
580
+ if ( !self.sdk )
581
+ {
582
+ [self logUninitializedAccessError: @"hasSupportedCmp" withPromiseReject: reject];
583
+ return;
584
+ }
585
+
586
+ ALCMPService *cmpService = self.sdk.cmpService;
587
+ resolve(@([cmpService hasSupportedCMP]));
588
+ }
589
+
557
590
  #pragma mark - Data Passing
558
591
 
559
592
  RCT_EXPORT_METHOD(setTargetingDataYearOfBirth:(nonnull NSNumber *)yearOfBirth)
@@ -1995,7 +2028,20 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
1995
2028
 
1996
2029
  - (void)logUninitializedAccessError:(NSString *)callingMethod
1997
2030
  {
1998
- [self log: @"ERROR: Failed to execute %@() - please ensure the AppLovin MAX React Native module has been initialized by calling 'AppLovinMAX.initialize(...);'!", callingMethod];
2031
+ [self logUninitializedAccessError: callingMethod withPromiseReject: nil];
2032
+ }
2033
+
2034
+ - (void)logUninitializedAccessError:(NSString *)callingMethod withPromiseReject:(nullable RCTPromiseRejectBlock)reject
2035
+ {
2036
+ NSString *message = [NSString stringWithFormat:@"ERROR: Failed to execute %@() - please ensure the AppLovin MAX React Native module has been initialized by calling 'AppLovinMAX.initialize(...);'!", callingMethod];
2037
+
2038
+ if ( !reject )
2039
+ {
2040
+ NSLog(@"[%@] [%@] %@", SDK_TAG, TAG, message);
2041
+ return;
2042
+ }
2043
+
2044
+ reject(TAG, message, nil);
1999
2045
  }
2000
2046
 
2001
2047
  - (void)log:(NSString *)format, ...
@@ -2246,6 +2292,11 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
2246
2292
  [self setAmazonResult: result forAdUnitIdentifier: adUnitIdentifier adFormat: MAAdFormat.interstitial];
2247
2293
  }
2248
2294
 
2295
+ - (void)setAmazonResult:(id)result forRewardedAdUnitIdentifier:(NSString *)adUnitIdentifier
2296
+ {
2297
+ [self setAmazonResult: result forAdUnitIdentifier: adUnitIdentifier adFormat: MAAdFormat.rewarded];
2298
+ }
2299
+
2249
2300
  - (void)setAmazonResult:(id /* DTBAdResponse or DTBAdErrorInfo */)result forAdUnitIdentifier:(NSString *)adUnitIdentifier adFormat:(MAAdFormat *)adFormat
2250
2301
  {
2251
2302
  if ( !self.sdk )
@@ -2275,6 +2326,17 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
2275
2326
 
2276
2327
  [interstitial setLocalExtraParameterForKey: key value: result];
2277
2328
  }
2329
+ else if ( adFormat == MAAdFormat.rewarded )
2330
+ {
2331
+ MARewardedAd *rewardedAd = [self retrieveRewardedAdForAdUnitIdentifier: adUnitIdentifier];
2332
+ if ( !rewardedAd )
2333
+ {
2334
+ [self log: @"Failed to set Amazon result - unable to find rewarded ad"];
2335
+ return;
2336
+ }
2337
+
2338
+ [rewardedAd setLocalExtraParameterForKey: key value: result];
2339
+ }
2278
2340
  else // MAAdFormat.banner or MAAdFormat.mrec
2279
2341
  {
2280
2342
  MAAdView *adView = [AppLovinMAXAdView sharedWithAdUnitIdentifier: adUnitIdentifier];
@@ -15,6 +15,8 @@ NS_ASSUME_NONNULL_BEGIN
15
15
 
16
16
  + (MAAdView *)sharedWithAdUnitIdentifier:(NSString *)adUnitIdentifier;
17
17
 
18
+ - (void)loadAd;
19
+
18
20
  @end
19
21
 
20
22
  NS_ASSUME_NONNULL_END
@@ -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.adView loadAd];
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.1",
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 => "release_6_2_1" }
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
- adUnitId,
166
- adFormat,
167
- placement,
168
- customData,
169
- adaptiveBannerEnabled = true,
170
- autoRefresh = true,
171
- extraParameters,
172
- localExtraParameters,
173
- onAdLoaded,
174
- onAdLoadFailed,
175
- onAdDisplayFailed,
176
- onAdClicked,
177
- onAdExpanded,
178
- onAdCollapsed,
179
- onAdRevenuePaid,
180
- style,
181
- ...otherProps
182
- }: AdViewProps & ViewProps) => {
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
+ });
@@ -4,7 +4,88 @@ import type { Configuration } from './types/Configuration';
4
4
 
5
5
  const NativeAppLovinMAX = NativeModules.AppLovinMAX;
6
6
 
7
- const VERSION = '6.2.1';
7
+ const VERSION = '6.2.3';
8
+
9
+ /**
10
+ * This enum represents the user's geography used to determine the type of consent flow shown to the
11
+ * user.
12
+ */
13
+ export enum ConsentFlowUserGeography {
14
+ /**
15
+ * User's geography is unknown.
16
+ */
17
+ UNKNOWN = 'U',
18
+
19
+ /**
20
+ * The user is in GDPR region.
21
+ */
22
+ GDPR = 'G',
23
+
24
+ /**
25
+ * The user is in a non-GDPR region.
26
+ */
27
+ OTHER = 'O',
28
+ }
29
+
30
+ /**
31
+ * AppLovin SDK-defined app tracking transparency status values (extended to include "unavailable"
32
+ * state on iOS before iOS14).
33
+ */
34
+ export enum AppTrackingStatus {
35
+ /**
36
+ * Device is on iOS before iOS14, AppTrackingTransparency.framework is not available.
37
+ */
38
+ UNAVAILABLE = 'U',
39
+
40
+ /**
41
+ * The user has not yet received an authorization request to authorize access to app-related
42
+ * data that can be used for tracking the user or the device.
43
+ */
44
+ NOT_DETERMINED = 'N',
45
+
46
+ /**
47
+ * Authorization to access app-related data that can be used for tracking the user or the device
48
+ * is restricted.
49
+ */
50
+ RESTRICTED = 'R',
51
+
52
+ /**
53
+ * The user denies authorization to access app-related data that can be used for tracking the
54
+ * user or the device.
55
+ */
56
+ DENIED = 'D',
57
+
58
+ /**
59
+ * The user authorizes access to app-related data that can be used for tracking the user or the
60
+ * device.
61
+ */
62
+ AUTHORIZED = 'A',
63
+ }
64
+
65
+ /**
66
+ * Represents errors for CMP flow.
67
+ */
68
+ export enum CmpError {
69
+ /**
70
+ * Indicates that an unspecified error has occurred.
71
+ */
72
+ UNSPECIFIED = -1,
73
+
74
+ /**
75
+ * Indicates that the CMP has not been integrated correctly.
76
+ */
77
+ INTEGRATION_ERROR = 1,
78
+
79
+ /**
80
+ * Indicates that the CMP form is unavailable.
81
+ */
82
+ FORM_UNAVAILABLE = 2,
83
+
84
+ /**
85
+ * Indicates that the CMP form is not required.
86
+ */
87
+ FORM_NOT_REQUIRED = 3,
88
+ }
8
89
 
9
90
  const initialize = async (sdkKey: string): Promise<Configuration> => {
10
91
  return NativeAppLovinMAX.initialize(VERSION, sdkKey);
package/src/Privacy.ts CHANGED
@@ -3,60 +3,4 @@ import type { PrivacyType } from './types/Privacy';
3
3
 
4
4
  const { AppLovinMAX } = NativeModules;
5
5
 
6
- /**
7
- * This enum represents the user's geography used to determine the type of consent flow shown to the
8
- * user.
9
- */
10
- export enum ConsentFlowUserGeography {
11
- /**
12
- * User's geography is unknown.
13
- */
14
- UNKNOWN = 'U',
15
-
16
- /**
17
- * The user is in GDPR region.
18
- */
19
- GDPR = 'G',
20
-
21
- /**
22
- * The user is in a non-GDPR region.
23
- */
24
- OTHER = 'O',
25
- }
26
-
27
- /**
28
- * AppLovin SDK-defined app tracking transparency status values (extended to include "unavailable"
29
- * state on iOS before iOS14).
30
- */
31
- export enum AppTrackingStatus {
32
- /**
33
- * Device is on iOS before iOS14, AppTrackingTransparency.framework is not available.
34
- */
35
- UNAVAILABLE = 'U',
36
-
37
- /**
38
- * The user has not yet received an authorization request to authorize access to app-related
39
- * data that can be used for tracking the user or the device.
40
- */
41
- NOT_DETERMINED = 'N',
42
-
43
- /**
44
- * Authorization to access app-related data that can be used for tracking the user or the device
45
- * is restricted.
46
- */
47
- RESTRICTED = 'R',
48
-
49
- /**
50
- * The user denies authorization to access app-related data that can be used for tracking the
51
- * user or the device.
52
- */
53
- DENIED = 'D',
54
-
55
- /**
56
- * The user authorizes access to app-related data that can be used for tracking the user or the
57
- * device.
58
- */
59
- AUTHORIZED = 'A',
60
- }
61
-
62
6
  export const Privacy: PrivacyType = AppLovinMAX;
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { default, AppLovinMAX } from './AppLovinMAX';
2
- export { Privacy, ConsentFlowUserGeography, AppTrackingStatus } from './Privacy';
1
+ export { default, AppLovinMAX, ConsentFlowUserGeography, AppTrackingStatus, CmpError } from './AppLovinMAX';
2
+ export { Privacy } from './Privacy';
3
3
  export { TargetingData, AdContentRating, UserGender } from './TargetingData';
4
4
  export { InterstitialAd } from './InterstitialAd';
5
5
  export { RewardedAd } from './RewardedAd';
@@ -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
  */
@@ -1,4 +1,5 @@
1
1
  import type { Configuration } from './Configuration';
2
+ import type { ConsentFlowUserGeography, CmpError } from '../AppLovinMAX';
2
3
 
3
4
  /**
4
5
  * Represents the AppLovinMAX module.
@@ -90,4 +91,61 @@ export type AppLovinMAXType = {
90
91
  * @param enabled Defaults to true.
91
92
  */
92
93
  setLocationCollectionEnabled(enabled: boolean): void;
94
+
95
+ /**
96
+ * @deprecated Use {@link setTermsAndPrivacyPolicyFlowEnabled()} instead.
97
+ *
98
+ * Enables the MAX Terms Flow.
99
+ *
100
+ * @param enabled true to enable the MAX Terms Flow.
101
+ */
102
+ setConsentFlowEnabled(enabled: boolean): void;
103
+
104
+ /**
105
+ * Enables the MAX Terms and Privacy Policy Flow.
106
+ *
107
+ * @param enabled true to enable the MAX Terms and Privacy Policy Flow.
108
+ */
109
+ setTermsAndPrivacyPolicyFlowEnabled(enabled: boolean): void;
110
+
111
+ /**
112
+ * The URL of your company’s privacy policy, as a string. This is required in order to enable
113
+ * the Terms Flow.
114
+ *
115
+ * @param urlString The URL string to point your company’s privacy policy.
116
+ */
117
+ setPrivacyPolicyUrl(urlString: string): void;
118
+
119
+ /**
120
+ * The URL of your company’s terms of service, as a string. This is optional; you can enable
121
+ * the Terms Flow with or without it.
122
+ *
123
+ * @param urlString The URL string to point your company’s terms of service.
124
+ */
125
+ setTermsOfServiceUrl(urlString: string): void;
126
+
127
+ /**
128
+ * Set debug user geography. You may use this to test CMP flow by setting this to {@link ConsentFlowUserGeography.GDPR}.
129
+ *
130
+ * @note The debug geography is used only when the app is in debug mode.
131
+ */
132
+ setConsentFlowDebugUserGeography(userGeography: ConsentFlowUserGeography): void;
133
+
134
+ /**
135
+ * Shows the CMP flow to an existing user.
136
+ * Note that this resets the user’s existing consent information.
137
+ *
138
+ * The function returns when the flow finishes showing. On success, returns null. On failure,
139
+ * returns one of the {@link CmpError} codes.
140
+ *
141
+ * @return {Promise<CmpError|null>}
142
+ */
143
+ showCmpForExistingUser(): Promise<CmpError | null>;
144
+
145
+ /**
146
+ * Returns true if a supported CMP SDK is detected.
147
+ *
148
+ * @return {boolean}
149
+ */
150
+ hasSupportedCmp(): Promise<boolean>;
93
151
  };
@@ -1,4 +1,4 @@
1
- import type { ConsentFlowUserGeography, AppTrackingStatus } from '../Privacy';
1
+ import type { ConsentFlowUserGeography, AppTrackingStatus } from '../AppLovinMAX';
2
2
 
3
3
  /**
4
4
  * Encapsulates data for the AppLovinMAX SDK configuration.
@@ -1,5 +1,3 @@
1
- import type { ConsentFlowUserGeography } from '../Privacy';
2
-
3
1
  export type PrivacyType = {
4
2
  /**********************************************************************************/
5
3
  /* Privacy */
@@ -40,47 +38,4 @@ export type PrivacyType = {
40
38
  * Checks if the user opted out of the sale of their personal information.
41
39
  */
42
40
  isDoNotSell(): Promise<boolean>;
43
-
44
- /**********************************************************************************/
45
- /* TERM FLow */
46
- /**********************************************************************************/
47
-
48
- /**
49
- * @deprecated Use {@link setTermsAndPrivacyPolicyFlowEnabled()} instead.
50
- *
51
- * Enables the MAX Terms Flow.
52
- *
53
- * @param enabled true to enable the MAX Terms Flow.
54
- */
55
- setConsentFlowEnabled(enabled: boolean): void;
56
-
57
- /**
58
- * Enables the MAX Terms and Privacy Policy Flow.
59
- *
60
- * @param enabled true to enable the MAX Terms and Privacy Policy Flow.
61
- */
62
- setTermsAndPrivacyPolicyFlowEnabled(enabled: boolean): void;
63
-
64
- /**
65
- * The URL of your company’s privacy policy, as a string. This is required in order to enable
66
- * the Terms Flow.
67
- *
68
- * @param urlString The URL string to point your company’s privacy policy.
69
- */
70
- setPrivacyPolicyUrl(urlString: string): void;
71
-
72
- /**
73
- * The URL of your company’s terms of service, as a string. This is optional; you can enable
74
- * the Terms Flow with or without it.
75
- *
76
- * @param urlString The URL string to point your company’s terms of service.
77
- */
78
- setTermsOfServiceUrl(urlString: string): void;
79
-
80
- /**
81
- * Set debug user geography. You may use this to test CMP flow by setting this to {@link ConsentFlowUserGeography.GDPR}.
82
- *
83
- * @note The debug geography is used only when the app is in debug mode.
84
- */
85
- setConsentFlowDebugUserGeography(userGeography: ConsentFlowUserGeography): void;
86
41
  };