react-native-applovin-max 6.2.2 → 6.3.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.
@@ -35,8 +35,8 @@ android {
35
35
  defaultConfig {
36
36
  minSdkVersion 16
37
37
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
38
- versionCode 6020200
39
- versionName "6.2.2"
38
+ versionCode 6030000
39
+ versionName "6.3.0"
40
40
  }
41
41
 
42
42
  flavorDimensions("default")
@@ -140,5 +140,5 @@ dependencies {
140
140
  // noinspection GradleDynamicVersion
141
141
  api 'com.facebook.react:react-native:+'
142
142
 
143
- implementation 'com.applovin:applovin-sdk:12.1.0'
143
+ implementation 'com.applovin:applovin-sdk:12.2.0'
144
144
  }
@@ -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
  {
@@ -270,7 +270,11 @@ public class AppLovinMAXModule
270
270
  private void performInitialization(final String pluginVersion, final String sdkKey, final Context context, final Promise promise)
271
271
  {
272
272
  // Guard against running init logic multiple times
273
- if ( isPluginInitialized ) return;
273
+ if ( isPluginInitialized )
274
+ {
275
+ promise.resolve( getInitializationMessage() );
276
+ return;
277
+ }
274
278
 
275
279
  isPluginInitialized = true;
276
280
 
@@ -457,15 +461,25 @@ public class AppLovinMAXModule
457
461
  }
458
462
  }.enable();
459
463
 
460
- WritableMap sdkConfiguration = Arguments.createMap();
461
- sdkConfiguration.putString( "countryCode", configuration.getCountryCode() );
462
- sdkConfiguration.putString( "consentFlowUserGeography", getRawAppLovinConsentFlowUserGeography( configuration.getConsentFlowUserGeography() ) );
463
- sdkConfiguration.putBoolean( "isTestModeEnabled", configuration.isTestModeEnabled() );
464
- promise.resolve( sdkConfiguration );
464
+ promise.resolve( getInitializationMessage() );
465
465
  }
466
466
  } );
467
467
  }
468
468
 
469
+ private WritableMap getInitializationMessage()
470
+ {
471
+ WritableMap message = Arguments.createMap();
472
+
473
+ if ( sdkConfiguration != null )
474
+ {
475
+ message.putString( "countryCode", sdkConfiguration.getCountryCode() );
476
+ message.putString( "consentFlowUserGeography", getRawAppLovinConsentFlowUserGeography( sdkConfiguration.getConsentFlowUserGeography() ) );
477
+ message.putBoolean( "isTestModeEnabled", sdkConfiguration.isTestModeEnabled() );
478
+ }
479
+
480
+ return message;
481
+ }
482
+
469
483
  // General Public API
470
484
 
471
485
  @ReactMethod
@@ -673,7 +687,7 @@ public class AppLovinMAXModule
673
687
  @ReactMethod
674
688
  public void showCmpForExistingUser(final Promise promise)
675
689
  {
676
- if ( sdk == null )
690
+ if ( !isPluginInitialized )
677
691
  {
678
692
  logUninitializedAccessError( "showCmpForExistingUser", promise );
679
693
  return;
@@ -686,8 +700,7 @@ public class AppLovinMAXModule
686
700
  return;
687
701
  }
688
702
 
689
- AppLovinCmpService cmpService = sdk.getCmpService();
690
- cmpService.showCmpForExistingUser( currentActivity, (@Nullable final AppLovinCmpError error) -> {
703
+ sdk.getCmpService().showCmpForExistingUser( currentActivity, (@Nullable final AppLovinCmpError error) -> {
691
704
 
692
705
  if ( error == null )
693
706
  {
@@ -695,21 +708,25 @@ public class AppLovinMAXModule
695
708
  return;
696
709
  }
697
710
 
698
- promise.resolve( error.getCmpCode() );
711
+ WritableMap params = Arguments.createMap();
712
+ params.putInt( "code", error.getCode().getValue() );
713
+ params.putString( "message", error.getMessage() );
714
+ params.putInt( "cmpCode", error.getCmpCode() );
715
+ params.putString( "cmpMessage", error.getCmpMessage() );
716
+ promise.resolve( params );
699
717
  } );
700
718
  }
701
719
 
702
720
  @ReactMethod
703
721
  public void hasSupportedCmp(final Promise promise)
704
722
  {
705
- if ( sdk == null )
723
+ if ( !isPluginInitialized )
706
724
  {
707
725
  logUninitializedAccessError( "showCmpForExistingUser", promise );
708
726
  return;
709
727
  }
710
728
 
711
- AppLovinCmpService cmpService = sdk.getCmpService();
712
- promise.resolve( cmpService.hasSupportedCmp() );
729
+ promise.resolve( sdk.getCmpService().hasSupportedCmp() );
713
730
  }
714
731
 
715
732
  // Data Passing
@@ -1538,7 +1555,7 @@ public class AppLovinMAXModule
1538
1555
  {
1539
1556
  String name;
1540
1557
  MaxAdFormat adFormat = ad.getFormat();
1541
- if ( MaxAdFormat.BANNER == adFormat || MaxAdFormat.LEADER == adFormat || MaxAdFormat.MREC == adFormat )
1558
+ if ( adFormat.isAdViewAd() )
1542
1559
  {
1543
1560
  name = ( MaxAdFormat.MREC == adFormat ) ? ON_MREC_AD_LOADED_EVENT : ON_BANNER_AD_LOADED_EVENT;
1544
1561
 
@@ -1728,7 +1745,7 @@ public class AppLovinMAXModule
1728
1745
  public void onAdExpanded(final MaxAd ad)
1729
1746
  {
1730
1747
  final MaxAdFormat adFormat = ad.getFormat();
1731
- if ( adFormat != MaxAdFormat.BANNER && adFormat != MaxAdFormat.LEADER && adFormat != MaxAdFormat.MREC )
1748
+ if ( !adFormat.isAdViewAd() )
1732
1749
  {
1733
1750
  logInvalidAdFormat( adFormat );
1734
1751
  return;
@@ -1741,7 +1758,7 @@ public class AppLovinMAXModule
1741
1758
  public void onAdCollapsed(final MaxAd ad)
1742
1759
  {
1743
1760
  final MaxAdFormat adFormat = ad.getFormat();
1744
- if ( adFormat != MaxAdFormat.BANNER && adFormat != MaxAdFormat.LEADER && adFormat != MaxAdFormat.MREC )
1761
+ if ( !adFormat.isAdViewAd() )
1745
1762
  {
1746
1763
  logInvalidAdFormat( adFormat );
1747
1764
  return;
@@ -2747,6 +2764,11 @@ public class AppLovinMAXModule
2747
2764
  setAmazonResult( result, adUnitId, MaxAdFormat.INTERSTITIAL );
2748
2765
  }
2749
2766
 
2767
+ public void setAmazonRewardedResult(final Object result, final String adUnitId)
2768
+ {
2769
+ setAmazonResult( result, adUnitId, MaxAdFormat.REWARDED );
2770
+ }
2771
+
2750
2772
  private void setAmazonResult(final Object result, final String adUnitId, final MaxAdFormat adFormat)
2751
2773
  {
2752
2774
  if ( sdk == null )
package/ios/AppLovinMAX.m CHANGED
@@ -206,7 +206,11 @@ RCT_EXPORT_METHOD(isInitialized:(RCTPromiseResolveBlock)resolve :(RCTPromiseReje
206
206
  RCT_EXPORT_METHOD(initialize:(NSString *)pluginVersion :(NSString *)sdkKey :(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
207
207
  {
208
208
  // Guard against running init logic multiple times
209
- if ( [self isPluginInitialized] ) return;
209
+ if ( [self isPluginInitialized] )
210
+ {
211
+ resolve([self initializationMessage]);
212
+ return;
213
+ }
210
214
 
211
215
  self.pluginInitialized = YES;
212
216
 
@@ -377,13 +381,25 @@ RCT_EXPORT_METHOD(initialize:(NSString *)pluginVersion :(NSString *)sdkKey :(RCT
377
381
  self.sdkConfiguration = configuration;
378
382
  self.sdkInitialized = YES;
379
383
 
380
- resolve(@{@"countryCode" : self.sdk.configuration.countryCode,
381
- @"appTrackingStatus" : [self fromAppLovinAppTrackingStatus: self.sdk.configuration.appTrackingTransparencyStatus],
382
- @"consentFlowUserGeography" : [self fromAppLovinConsentFlowUserGeography: self.sdk.configuration.consentFlowUserGeography],
383
- @"isTestModeEnabled" : @(self.sdk.configuration.isTestModeEnabled)});
384
+ resolve([self initializationMessage]);
384
385
  }];
385
386
  }
386
387
 
388
+ - (NSDictionary<NSString *, id> *)initializationMessage
389
+ {
390
+ NSMutableDictionary<NSString *, id> *message = [NSMutableDictionary dictionaryWithCapacity: 4];
391
+
392
+ if ( self.sdkConfiguration )
393
+ {
394
+ message[@"countryCode"] = self.sdkConfiguration.countryCode;
395
+ message[@"appTrackingStatus"] = [self fromAppLovinAppTrackingStatus: self.sdk.configuration.appTrackingTransparencyStatus];
396
+ message[@"consentFlowUserGeography"] = [self fromAppLovinConsentFlowUserGeography: self.sdk.configuration.consentFlowUserGeography];
397
+ message[@"isTestModeEnabled"] = @(self.sdkConfiguration.isTestModeEnabled);
398
+ }
399
+
400
+ return message;
401
+ }
402
+
387
403
  #pragma mark - General Public API
388
404
 
389
405
  RCT_EXPORT_METHOD(isTablet:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
@@ -556,14 +572,13 @@ RCT_EXPORT_METHOD(setConsentFlowDebugUserGeography:(NSString *)userGeography)
556
572
 
557
573
  RCT_EXPORT_METHOD(showCmpForExistingUser:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
558
574
  {
559
- if ( !self.sdk )
575
+ if ( ![self isPluginInitialized] )
560
576
  {
561
577
  [self logUninitializedAccessError: @"showCmpForExistingUser" withPromiseReject: reject];
562
578
  return;
563
579
  }
564
580
 
565
- ALCMPService *cmpService = self.sdk.cmpService;
566
- [cmpService showCMPForExistingUserWithCompletion:^(ALCMPError * _Nullable error) {
581
+ [self.sdk.cmpService showCMPForExistingUserWithCompletion:^(ALCMPError * _Nullable error) {
567
582
 
568
583
  if ( !error )
569
584
  {
@@ -571,20 +586,22 @@ RCT_EXPORT_METHOD(showCmpForExistingUser:(RCTPromiseResolveBlock)resolve :(RCTPr
571
586
  return;
572
587
  }
573
588
 
574
- resolve(@(error.code));
589
+ resolve(@{@"code" : @(error.code),
590
+ @"message" : error.message ?: @"",
591
+ @"cmpCode" : @(error.cmpCode),
592
+ @"cmpMessage" : error.cmpMessage ?: @""});
575
593
  }];
576
594
  }
577
595
 
578
596
  RCT_EXPORT_METHOD(hasSupportedCmp:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
579
597
  {
580
- if ( !self.sdk )
598
+ if ( ![self isPluginInitialized] )
581
599
  {
582
600
  [self logUninitializedAccessError: @"hasSupportedCmp" withPromiseReject: reject];
583
601
  return;
584
602
  }
585
603
 
586
- ALCMPService *cmpService = self.sdk.cmpService;
587
- resolve(@([cmpService hasSupportedCMP]));
604
+ resolve(@([self.sdk.cmpService hasSupportedCMP]));
588
605
  }
589
606
 
590
607
  #pragma mark - Data Passing
@@ -1255,7 +1272,7 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
1255
1272
  {
1256
1273
  NSString *name;
1257
1274
  MAAdFormat *adFormat = ad.format;
1258
- if ( MAAdFormat.banner == adFormat || MAAdFormat.leader == adFormat || MAAdFormat.mrec == adFormat )
1275
+ if ( [adFormat isAdViewAd] )
1259
1276
  {
1260
1277
  MAAdView *adView = [self retrieveAdViewForAdUnitIdentifier: ad.adUnitIdentifier adFormat: adFormat];
1261
1278
  // An ad is now being shown, enable user interaction.
@@ -1431,7 +1448,7 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
1431
1448
  - (void)didExpandAd:(MAAd *)ad
1432
1449
  {
1433
1450
  MAAdFormat *adFormat = ad.format;
1434
- if ( adFormat != MAAdFormat.banner && adFormat != MAAdFormat.leader && adFormat != MAAdFormat.mrec )
1451
+ if ( ![adFormat isAdViewAd] )
1435
1452
  {
1436
1453
  [self logInvalidAdFormat: adFormat];
1437
1454
  return;
@@ -1444,7 +1461,7 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
1444
1461
  - (void)didCollapseAd:(MAAd *)ad
1445
1462
  {
1446
1463
  MAAdFormat *adFormat = ad.format;
1447
- if ( adFormat != MAAdFormat.banner && adFormat != MAAdFormat.leader && adFormat != MAAdFormat.mrec )
1464
+ if ( ![adFormat isAdViewAd] )
1448
1465
  {
1449
1466
  [self logInvalidAdFormat: adFormat];
1450
1467
  return;
@@ -1867,7 +1884,7 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
1867
1884
 
1868
1885
  // Deactivate any previous constraints and reset visibility state so that the safe area background can be positioned again.
1869
1886
  [NSLayoutConstraint deactivateConstraints: self.safeAreaBackground.constraints];
1870
- self.safeAreaBackground.hidden = NO;
1887
+ self.safeAreaBackground.hidden = adView.hidden;
1871
1888
 
1872
1889
  //
1873
1890
  // Determine ad width
@@ -2292,6 +2309,11 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
2292
2309
  [self setAmazonResult: result forAdUnitIdentifier: adUnitIdentifier adFormat: MAAdFormat.interstitial];
2293
2310
  }
2294
2311
 
2312
+ - (void)setAmazonResult:(id)result forRewardedAdUnitIdentifier:(NSString *)adUnitIdentifier
2313
+ {
2314
+ [self setAmazonResult: result forAdUnitIdentifier: adUnitIdentifier adFormat: MAAdFormat.rewarded];
2315
+ }
2316
+
2295
2317
  - (void)setAmazonResult:(id /* DTBAdResponse or DTBAdErrorInfo */)result forAdUnitIdentifier:(NSString *)adUnitIdentifier adFormat:(MAAdFormat *)adFormat
2296
2318
  {
2297
2319
  if ( !self.sdk )
@@ -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/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', '12.1.0'
38
+ pod 'AppLovinSDK', '12.2.1'
39
39
 
40
40
  end
package/ios/Podfile.lock CHANGED
@@ -1,5 +1,5 @@
1
1
  PODS:
2
- - AppLovinSDK (12.1.0)
2
+ - AppLovinSDK (12.2.1)
3
3
  - boost-for-react-native (1.63.0)
4
4
  - DoubleConversion (1.1.6)
5
5
  - FBLazyVector (0.63.5)
@@ -249,7 +249,7 @@ PODS:
249
249
  - Yoga (1.14.0)
250
250
 
251
251
  DEPENDENCIES:
252
- - AppLovinSDK (= 12.1.0)
252
+ - AppLovinSDK (= 12.2.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: 179d509c258e01a3a77eb8416f0ba843a12ed322
342
+ AppLovinSDK: ed2ea453fc6cc836f4f829046865e6731010c139
343
343
  boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
344
344
  DoubleConversion: cde416483dac037923206447da6e1454df403714
345
345
  FBLazyVector: 352a8ca9bbc8e2f097d680747a8c97ecef12d469
@@ -368,6 +368,6 @@ SPEC CHECKSUMS:
368
368
  ReactCommon: b9ff54b6dd22ba4a776eda22d7f83ec27544ca35
369
369
  Yoga: 0276e9f20976c8568e107cfc1163a8629051adc0
370
370
 
371
- PODFILE CHECKSUM: d7248805481768209533def6ca165110984d9914
371
+ PODFILE CHECKSUM: f5dc83bbecf23ce4ab6cb8ef2384fddaad9e6760
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": "6.2.2",
4
+ "version": "6.3.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 => "release_6_2_2" }
14
+ s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_6_3_0" }
15
15
 
16
16
  s.source_files = "ios/AppLovinMAX*.{h,m}"
17
17
 
18
18
  s.dependency "React"
19
- s.dependency "AppLovinSDK", "12.1.0"
19
+ s.dependency "AppLovinSDK", "12.2.1"
20
20
  end
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,7 @@ import type { Configuration } from './types/Configuration';
4
4
 
5
5
  const NativeAppLovinMAX = NativeModules.AppLovinMAX;
6
6
 
7
- const VERSION = '6.2.2';
7
+ const VERSION = '6.3.0';
8
8
 
9
9
  /**
10
10
  * This enum represents the user's geography used to determine the type of consent flow shown to the
@@ -65,7 +65,7 @@ export enum AppTrackingStatus {
65
65
  /**
66
66
  * Represents errors for CMP flow.
67
67
  */
68
- export enum CmpError {
68
+ export enum CMPErrorCode {
69
69
  /**
70
70
  * Indicates that an unspecified error has occurred.
71
71
  */
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { default, AppLovinMAX, ConsentFlowUserGeography, AppTrackingStatus, CmpError } from './AppLovinMAX';
1
+ export { default, AppLovinMAX, ConsentFlowUserGeography, AppTrackingStatus, CMPErrorCode } from './AppLovinMAX';
2
2
  export { Privacy } from './Privacy';
3
3
  export { TargetingData, AdContentRating, UserGender } from './TargetingData';
4
4
  export { InterstitialAd } from './InterstitialAd';
@@ -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,5 +1,6 @@
1
1
  import type { Configuration } from './Configuration';
2
- import type { ConsentFlowUserGeography, CmpError } from '../AppLovinMAX';
2
+ import type { CMPError } from './CMPError';
3
+ import type { ConsentFlowUserGeography } from '../AppLovinMAX';
3
4
 
4
5
  /**
5
6
  * Represents the AppLovinMAX module.
@@ -63,8 +64,8 @@ export type AppLovinMAXType = {
63
64
  setVerboseLogging(verboseLoggingEnabled: boolean): void;
64
65
 
65
66
  /**
66
- * Enables devices to receive test ads by passing in the advertising identifier (IDFA) of each
67
- * test device. Refer to AppLovin logs for the IDFA of your current device.
67
+ * Enables devices to receive test ads by passing in the advertising identifier (IDFA or IDFV) of
68
+ * each test device. Refer to AppLovin logs for the IDFA or IDFV of your current device.
68
69
  *
69
70
  * @param advertisingIds A list of the advertising ids.
70
71
  */
@@ -136,11 +137,11 @@ export type AppLovinMAXType = {
136
137
  * Note that this resets the user’s existing consent information.
137
138
  *
138
139
  * The function returns when the flow finishes showing. On success, returns null. On failure,
139
- * returns one of the {@link CmpError} codes.
140
+ * returns one of the {@link CMPError} codes.
140
141
  *
141
- * @return {Promise<CmpError|null>}
142
+ * @return {Promise<CMPError|null>}
142
143
  */
143
- showCmpForExistingUser(): Promise<CmpError | null>;
144
+ showCmpForExistingUser(): Promise<CMPError | null>;
144
145
 
145
146
  /**
146
147
  * Returns true if a supported CMP SDK is detected.
@@ -0,0 +1,23 @@
1
+ import type { CMPErrorCode } from '../AppLovinMAX';
2
+
3
+ export type CMPError = {
4
+ /**
5
+ * The error code for this error.
6
+ */
7
+ code: CMPErrorCode;
8
+
9
+ /**
10
+ * The error message for this error.
11
+ */
12
+ message: string;
13
+
14
+ /**
15
+ * The error code returned by the CMP.
16
+ */
17
+ cmpCode: number;
18
+
19
+ /**
20
+ * The error message returned by the CMP.
21
+ */
22
+ cmpMessage: string;
23
+ };
@@ -1,4 +1,5 @@
1
1
  export * from './Configuration';
2
+ export * from './CMPError';
2
3
  export * from './AdInfo';
3
4
  export * from './AdViewProps';
4
5
  export * from './NativeAdViewProps';