react-native-applovin-max 3.2.0 → 3.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.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 AppLovin Corporation
3
+ Copyright (c) 2022 AppLovin Corporation
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -41,8 +41,8 @@ android {
41
41
  defaultConfig {
42
42
  minSdkVersion 16
43
43
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
44
- versionCode 3020000
45
- versionName "3.2.0"
44
+ versionCode 3030000
45
+ versionName "3.3.0"
46
46
  }
47
47
 
48
48
  flavorDimensions("default")
@@ -150,5 +150,5 @@ dependencies {
150
150
 
151
151
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
152
152
 
153
- implementation 'com.applovin:applovin-sdk:11.4.3'
153
+ implementation 'com.applovin:applovin-sdk:11.4.4'
154
154
  }
@@ -74,7 +74,7 @@ class AppLovinMAXAdView
74
74
  return adView;
75
75
  }
76
76
 
77
- public void maybeAttachAdView(final String placement, final String customData, final String adaptiveBannerEnabledStr, final String adUnitId, final MaxAdFormat adFormat)
77
+ public void maybeAttachAdView(final String placement, final String customData, final String adaptiveBannerEnabledStr, final Boolean autoRefreshEnabled, final String adUnitId, final MaxAdFormat adFormat)
78
78
  {
79
79
  final Activity currentActivity = reactContext.getCurrentActivity();
80
80
  if ( currentActivity == null )
@@ -92,6 +92,7 @@ class AppLovinMAXAdView
92
92
  // If ad unit id and format has been set - create and attach AdView
93
93
  if ( !TextUtils.isEmpty( adUnitId ) && adFormat != null )
94
94
  {
95
+ // NOTE: AppLovinMAXModule.getInstance().getSdk() may be null
95
96
  adView = new MaxAdView( adUnitId, adFormat, AppLovinMAXModule.getInstance().getSdk(), currentActivity );
96
97
  adView.setListener( AppLovinMAXModule.getInstance() );
97
98
  adView.setRevenueListener( AppLovinMAXModule.getInstance() );
@@ -111,6 +112,21 @@ class AppLovinMAXAdView
111
112
  adView.setExtraParameter( "adaptive_banner", adaptiveBannerEnabledStr );
112
113
  }
113
114
 
115
+ // Set this extra parameter to work around a SDK bug that ignores calls to stopAutoRefresh()
116
+ adView.setExtraParameter( "allow_pause_auto_refresh_immediately", "true" );
117
+
118
+ if ( autoRefreshEnabled != null )
119
+ {
120
+ if ( autoRefreshEnabled.booleanValue() )
121
+ {
122
+ adView.startAutoRefresh();
123
+ }
124
+ else
125
+ {
126
+ adView.stopAutoRefresh();
127
+ }
128
+ }
129
+
114
130
  adView.loadAd();
115
131
 
116
132
  currentWidthPx = getWidth();
@@ -30,9 +30,10 @@ class AppLovinMAXAdViewManager
30
30
  private final Map<AppLovinMAXAdView, MaxAdFormat> adFormatRegistry = new HashMap<>();
31
31
 
32
32
  // Storage for placement and extra parameters if set before the MAAdView is created
33
- private final Map<AppLovinMAXAdView, String> placementRegistry = new HashMap<>();
34
- private final Map<AppLovinMAXAdView, String> customDataRegistry = new HashMap<>();
35
- private final Map<AppLovinMAXAdView, String> adaptiveBannerEnabledRegistry = new HashMap<>();
33
+ private final Map<AppLovinMAXAdView, String> placementRegistry = new HashMap<>();
34
+ private final Map<AppLovinMAXAdView, String> customDataRegistry = new HashMap<>();
35
+ private final Map<AppLovinMAXAdView, String> adaptiveBannerEnabledRegistry = new HashMap<>();
36
+ private final Map<AppLovinMAXAdView, Boolean> autoRefreshEnabledRegistry = new HashMap<>();
36
37
 
37
38
  public AppLovinMAXAdViewManager(final ReactApplicationContext reactApplicationContext)
38
39
  {
@@ -57,6 +58,12 @@ class AppLovinMAXAdViewManager
57
58
  {
58
59
  if ( args == null ) return;
59
60
 
61
+ if ( "setAutoRefresh".equals( commandId ) )
62
+ {
63
+ setAutoRefresh( view, args.getBoolean( 0 ) );
64
+ return;
65
+ }
66
+
60
67
  String arg = args.getString( 0 );
61
68
  if ( arg == null ) return;
62
69
 
@@ -137,6 +144,30 @@ class AppLovinMAXAdViewManager
137
144
  } );
138
145
  }
139
146
 
147
+ public void setAutoRefresh(final AppLovinMAXAdView view, final boolean enabled)
148
+ {
149
+ // Post to main thread to avoid race condition with actual creation of MaxAdView in maybeAttachAdView()
150
+ view.post( () -> {
151
+
152
+ MaxAdView adView = view.getAdView();
153
+ if ( adView != null )
154
+ {
155
+ if ( enabled )
156
+ {
157
+ adView.startAutoRefresh();
158
+ }
159
+ else
160
+ {
161
+ adView.stopAutoRefresh();
162
+ }
163
+ }
164
+ else
165
+ {
166
+ autoRefreshEnabledRegistry.put( view, enabled );
167
+ }
168
+ } );
169
+ }
170
+
140
171
  public void setAdUnitId(final AppLovinMAXAdView view, final String adUnitId)
141
172
  {
142
173
  adUnitIdRegistry.put( view, adUnitId );
@@ -162,10 +193,12 @@ class AppLovinMAXAdViewManager
162
193
  String placement = placementRegistry.remove( view );
163
194
  String customData = customDataRegistry.remove( view );
164
195
  String adaptiveBannerEnabledStr = adaptiveBannerEnabledRegistry.remove( view );
196
+ Boolean autoRefreshEnabled = autoRefreshEnabledRegistry.remove( view );
165
197
 
166
198
  view.maybeAttachAdView( placement,
167
199
  customData,
168
200
  adaptiveBannerEnabledStr,
201
+ autoRefreshEnabled,
169
202
  adUnitIdRegistry.get( view ),
170
203
  adFormatRegistry.get( view ) );
171
204
  }
@@ -45,6 +45,7 @@ import com.applovin.sdk.AppLovinSdkUtils;
45
45
  import com.applovin.sdk.AppLovinUserService;
46
46
  import com.facebook.react.bridge.Arguments;
47
47
  import com.facebook.react.bridge.Callback;
48
+ import com.facebook.react.bridge.LifecycleEventListener;
48
49
  import com.facebook.react.bridge.ReactApplicationContext;
49
50
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
50
51
  import com.facebook.react.bridge.ReactMethod;
@@ -72,7 +73,8 @@ import static com.facebook.react.modules.core.DeviceEventManagerModule.RCTDevice
72
73
  */
73
74
  public class AppLovinMAXModule
74
75
  extends ReactContextBaseJavaModule
75
- implements MaxAdListener, MaxAdViewAdListener, MaxRewardedAdListener, MaxAdRevenueListener
76
+ implements LifecycleEventListener,
77
+ MaxAdListener, MaxAdViewAdListener, MaxRewardedAdListener, MaxAdRevenueListener
76
78
  {
77
79
  private static final String SDK_TAG = "AppLovinSdk";
78
80
  private static final String TAG = "AppLovinMAXModule";
@@ -92,10 +94,12 @@ public class AppLovinMAXModule
92
94
  private int lastRotation;
93
95
 
94
96
  // Store these values if pub attempts to set it before initializing
95
- private String userIdToSet;
96
- private List<String> testDeviceAdvertisingIdsToSet;
97
- private Boolean verboseLoggingToSet;
98
- private Boolean creativeDebuggerEnabledToSet;
97
+ private String userIdToSet;
98
+ private List<String> testDeviceAdvertisingIdsToSet;
99
+ private Boolean verboseLoggingToSet;
100
+ private Boolean creativeDebuggerEnabledToSet;
101
+ private Boolean locationCollectionEnabledToSet;
102
+ private final Map<String, String> extraParametersToSet = new HashMap<>( 8 );
99
103
 
100
104
  // Fullscreen Ad Fields
101
105
  private final Map<String, MaxInterstitialAd> mInterstitials = new HashMap<>( 2 );
@@ -129,6 +133,9 @@ public class AppLovinMAXModule
129
133
 
130
134
  instance = this;
131
135
  sCurrentActivity = reactContext.getCurrentActivity();
136
+
137
+ // Listening to Lifecycle Events
138
+ reactContext.addLifecycleEventListener( this );
132
139
  }
133
140
 
134
141
  @Override
@@ -253,6 +260,15 @@ public class AppLovinMAXModule
253
260
  creativeDebuggerEnabledToSet = null;
254
261
  }
255
262
 
263
+ // Set location collection enabled if needed
264
+ if ( locationCollectionEnabledToSet != null )
265
+ {
266
+ sdk.getSettings().setLocationCollectionEnabled( locationCollectionEnabledToSet );
267
+ locationCollectionEnabledToSet = null;
268
+ }
269
+
270
+ setPendingExtraParametersIfNeeded( sdk.getSettings() );
271
+
256
272
  sdk.initializeSdk( new AppLovinSdk.SdkInitializationListener()
257
273
  {
258
274
  @Override
@@ -408,16 +424,16 @@ public class AppLovinMAXModule
408
424
  }
409
425
 
410
426
  @ReactMethod()
411
- public void setVerboseLogging(final boolean verboseLoggingEnabled)
427
+ public void setVerboseLogging(final boolean enabled)
412
428
  {
413
429
  if ( isPluginInitialized )
414
430
  {
415
- sdk.getSettings().setVerboseLogging( verboseLoggingEnabled );
431
+ sdk.getSettings().setVerboseLogging( enabled );
416
432
  verboseLoggingToSet = null;
417
433
  }
418
434
  else
419
435
  {
420
- verboseLoggingToSet = verboseLoggingEnabled;
436
+ verboseLoggingToSet = enabled;
421
437
  }
422
438
  }
423
439
 
@@ -457,6 +473,27 @@ public class AppLovinMAXModule
457
473
  }
458
474
  }
459
475
 
476
+ @ReactMethod()
477
+ public void setExtraParameter(final String key, @Nullable final String value)
478
+ {
479
+ if ( TextUtils.isEmpty( key ) )
480
+ {
481
+ e( "ERROR: Failed to set extra parameter for null or empty key: " + key );
482
+ return;
483
+ }
484
+
485
+ if ( sdk != null )
486
+ {
487
+ AppLovinSdkSettings settings = sdk.getSettings();
488
+ settings.setExtraParameter( key, value );
489
+ setPendingExtraParametersIfNeeded( settings );
490
+ }
491
+ else
492
+ {
493
+ extraParametersToSet.put( key, value );
494
+ }
495
+ }
496
+
460
497
  @ReactMethod()
461
498
  public void setConsentFlowEnabled(final boolean enabled) {}
462
499
 
@@ -468,18 +505,6 @@ public class AppLovinMAXModule
468
505
 
469
506
  // Data Passing
470
507
 
471
- @ReactMethod()
472
- public void setUserSegment(final String name)
473
- {
474
- if ( sdk == null )
475
- {
476
- logUninitializedAccessError( "setUserSegment" );
477
- return;
478
- }
479
-
480
- sdk.getUserSegment().setName( name );
481
- }
482
-
483
508
  @ReactMethod()
484
509
  public void setTargetingDataYearOfBirth(final int yearOfBirth)
485
510
  {
@@ -629,15 +654,17 @@ public class AppLovinMAXModule
629
654
  }
630
655
 
631
656
  @ReactMethod()
632
- public void setLocationCollectionEnabled(final boolean locationCollectionEnabled)
657
+ public void setLocationCollectionEnabled(final boolean enabled)
633
658
  {
634
- if ( sdk == null )
659
+ if ( isPluginInitialized )
635
660
  {
636
- logUninitializedAccessError( "setLocationCollectionEnabled" );
637
- return;
661
+ sdk.getSettings().setLocationCollectionEnabled( enabled );
662
+ locationCollectionEnabledToSet = null;
663
+ }
664
+ else
665
+ {
666
+ locationCollectionEnabledToSet = enabled;
638
667
  }
639
-
640
- sdk.getSettings().setLocationCollectionEnabled( locationCollectionEnabled );
641
668
  }
642
669
 
643
670
  // EVENT TRACKING
@@ -715,6 +742,18 @@ public class AppLovinMAXModule
715
742
  setAdViewExtraParameters( adUnitId, getDeviceSpecificBannerAdViewAdFormat(), key, value );
716
743
  }
717
744
 
745
+ @ReactMethod()
746
+ public void startBannerAutoRefresh(final String adUnitId)
747
+ {
748
+ startAutoRefresh( adUnitId, getDeviceSpecificBannerAdViewAdFormat() );
749
+ }
750
+
751
+ @ReactMethod()
752
+ public void stopBannerAutoRefresh(final String adUnitId)
753
+ {
754
+ stopAutoRefresh( adUnitId, getDeviceSpecificBannerAdViewAdFormat() );
755
+ }
756
+
718
757
  @ReactMethod()
719
758
  public void showBanner(final String adUnitId)
720
759
  {
@@ -765,6 +804,18 @@ public class AppLovinMAXModule
765
804
  updateAdViewPosition( adUnitId, mrecPosition, DEFAULT_AD_VIEW_OFFSET, MaxAdFormat.MREC );
766
805
  }
767
806
 
807
+ @ReactMethod()
808
+ public void startMRecAutoRefresh(final String adUnitId)
809
+ {
810
+ startAutoRefresh( adUnitId, MaxAdFormat.MREC );
811
+ }
812
+
813
+ @ReactMethod()
814
+ public void stopMRecAutoRefresh(final String adUnitId)
815
+ {
816
+ stopAutoRefresh( adUnitId, MaxAdFormat.MREC );
817
+ }
818
+
768
819
  @ReactMethod()
769
820
  public void showMRec(final String adUnitId)
770
821
  {
@@ -1075,7 +1126,7 @@ public class AppLovinMAXModule
1075
1126
  sendReactNativeEvent( ( MaxAdFormat.MREC == adFormat ) ? "OnMRecAdCollapsedEvent" : "OnBannerAdCollapsedEvent", getAdInfo( ad ) );
1076
1127
  }
1077
1128
 
1078
- @Override
1129
+ @Override
1079
1130
  public void onAdRevenuePaid(final MaxAd ad)
1080
1131
  {
1081
1132
  final MaxAdFormat adFormat = ad.getFormat();
@@ -1434,6 +1485,48 @@ public class AppLovinMAXModule
1434
1485
  } );
1435
1486
  }
1436
1487
 
1488
+ private void startAutoRefresh(final String adUnitId, final MaxAdFormat adFormat)
1489
+ {
1490
+ getReactApplicationContext().runOnUiQueueThread( new Runnable()
1491
+ {
1492
+ @Override
1493
+ public void run()
1494
+ {
1495
+ d( "Starting auto refresh " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1496
+
1497
+ final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
1498
+ if ( adView == null )
1499
+ {
1500
+ e( adFormat.getLabel() + " does not exist" );
1501
+ return;
1502
+ }
1503
+
1504
+ adView.startAutoRefresh();
1505
+ }
1506
+ } );
1507
+ }
1508
+
1509
+ private void stopAutoRefresh(final String adUnitId, final MaxAdFormat adFormat)
1510
+ {
1511
+ getReactApplicationContext().runOnUiQueueThread( new Runnable()
1512
+ {
1513
+ @Override
1514
+ public void run()
1515
+ {
1516
+ d( "Stopping auto refresh " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1517
+
1518
+ final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
1519
+ if ( adView == null )
1520
+ {
1521
+ e( adFormat.getLabel() + " does not exist" );
1522
+ return;
1523
+ }
1524
+
1525
+ adView.stopAutoRefresh();
1526
+ }
1527
+ } );
1528
+ }
1529
+
1437
1530
  @Nullable
1438
1531
  private MaxInterstitialAd retrieveInterstitial(String adUnitId)
1439
1532
  {
@@ -1486,6 +1579,9 @@ public class AppLovinMAXModule
1486
1579
  result.setListener( this );
1487
1580
  result.setRevenueListener( this );
1488
1581
 
1582
+ // Set this extra parameter to work around a SDK bug that ignores calls to stopAutoRefresh()
1583
+ result.setExtraParameter( "allow_pause_auto_refresh_immediately", "true" );
1584
+
1489
1585
  mAdViews.put( adUnitId, result );
1490
1586
  mAdViewPositions.put( adUnitId, adViewPosition );
1491
1587
  mAdViewOffsets.put( adUnitId, adViewOffsetPixels );
@@ -1629,6 +1725,18 @@ public class AppLovinMAXModule
1629
1725
  relativeLayout.setPadding( adViewOffset.x, adViewOffset.y, adViewOffset.x, adViewOffset.y );
1630
1726
  }
1631
1727
 
1728
+ private void setPendingExtraParametersIfNeeded(final AppLovinSdkSettings settings)
1729
+ {
1730
+ if ( extraParametersToSet.size() <= 0 ) return;
1731
+
1732
+ for ( final String key : extraParametersToSet.keySet() )
1733
+ {
1734
+ settings.setExtraParameter( key, extraParametersToSet.get( key ) );
1735
+ }
1736
+
1737
+ extraParametersToSet.clear();
1738
+ }
1739
+
1632
1740
  // Utility Methods
1633
1741
 
1634
1742
  private void logInvalidAdFormat(MaxAdFormat adFormat)
@@ -1722,6 +1830,7 @@ public class AppLovinMAXModule
1722
1830
  adInfo.putString( "placement", !TextUtils.isEmpty( ad.getPlacement() ) ? ad.getPlacement() : "" );
1723
1831
  adInfo.putDouble( "revenue", ad.getRevenue() );
1724
1832
  adInfo.putMap( "waterfall", createAdWaterfallInfo( ad.getWaterfall() ) );
1833
+ adInfo.putString( "dspName", !TextUtils.isEmpty( ad.getDspName() ) ? ad.getDspName() : "" );
1725
1834
 
1726
1835
  return adInfo;
1727
1836
  }
@@ -1769,8 +1878,11 @@ public class AppLovinMAXModule
1769
1878
  WritableMap credentials = Arguments.createMap();
1770
1879
  for ( String key : credentialBundle.keySet() )
1771
1880
  {
1772
- String value = credentialBundle.getString( key, "" );
1773
- credentials.putString( key, value );
1881
+ Object obj = credentialBundle.get( key );
1882
+ if ( obj instanceof String )
1883
+ {
1884
+ credentials.putString( key, (String) obj );
1885
+ }
1774
1886
  }
1775
1887
  networkResponseObject.putMap( "credentials", credentials );
1776
1888
 
@@ -1790,6 +1902,37 @@ public class AppLovinMAXModule
1790
1902
  return networkResponseObject;
1791
1903
  }
1792
1904
 
1905
+ // Lifecycle Events
1906
+
1907
+ @Override
1908
+ public void onHostResume() { }
1909
+
1910
+ @Override
1911
+ public void onHostPause() { }
1912
+
1913
+ @Override
1914
+ public void onHostDestroy()
1915
+ {
1916
+ // Make copy because `destroyAdView()` will remove from `mAdViews`
1917
+ List<MaxAdView> adViews = new ArrayList<>( mAdViews.values() );
1918
+ for ( MaxAdView adView : adViews )
1919
+ {
1920
+ destroyAdView( adView.getAdUnitId(), adView.getAdFormat() );
1921
+ }
1922
+
1923
+ for ( MaxInterstitialAd interstitialAd : mInterstitials.values() )
1924
+ {
1925
+ interstitialAd.destroy();
1926
+ }
1927
+ mInterstitials.clear();
1928
+
1929
+ for ( MaxRewardedAd rewardedAd : mRewardedAds.values() )
1930
+ {
1931
+ rewardedAd.destroy();
1932
+ }
1933
+ mRewardedAds.clear();
1934
+ }
1935
+
1793
1936
  // React Native Bridge
1794
1937
 
1795
1938
  private void sendReactNativeEvent(final String name, @Nullable final WritableMap params)
package/ios/AppLovinMAX.m CHANGED
@@ -40,6 +40,9 @@
40
40
  @property (nonatomic, strong, nullable) NSArray<NSString *> *testDeviceIdentifiersToSet;
41
41
  @property (nonatomic, strong, nullable) NSNumber *verboseLoggingToSet;
42
42
  @property (nonatomic, strong, nullable) NSNumber *creativeDebuggerEnabledToSet;
43
+ @property (nonatomic, strong, nullable) NSNumber *locationCollectionEnabledToSet;
44
+ @property (nonatomic, strong) NSMutableDictionary<NSString *, NSString *> *extraParametersToSet;
45
+
43
46
  @property (nonatomic, strong, nullable) NSNumber *consentFlowEnabledToSet;
44
47
  @property (nonatomic, strong, nullable) NSURL *privacyPolicyURLToSet;
45
48
  @property (nonatomic, strong, nullable) NSURL *termsOfServiceURLToSet;
@@ -108,6 +111,7 @@ RCT_EXPORT_MODULE()
108
111
  self.adViewConstraints = [NSMutableDictionary dictionaryWithCapacity: 2];
109
112
  self.adUnitIdentifiersToShowAfterCreate = [NSMutableArray arrayWithCapacity: 2];
110
113
  self.disabledAdaptiveBannerAdUnitIdentifiers = [NSMutableSet setWithCapacity: 2];
114
+ self.extraParametersToSet = [NSMutableDictionary dictionaryWithCapacity: 8];
111
115
 
112
116
  self.safeAreaBackground = [[UIView alloc] init];
113
117
  self.safeAreaBackground.hidden = YES;
@@ -194,6 +198,15 @@ RCT_EXPORT_METHOD(initialize:(NSString *)pluginVersion :(NSString *)sdkKey :(RCT
194
198
  self.creativeDebuggerEnabledToSet = nil;
195
199
  }
196
200
 
201
+ // Set location collection enabled if needed
202
+ if ( self.locationCollectionEnabledToSet )
203
+ {
204
+ self.sdk.settings.locationCollectionEnabled = self.locationCollectionEnabledToSet.boolValue;
205
+ self.locationCollectionEnabledToSet = nil;
206
+ }
207
+
208
+ [self setPendingExtraParametersIfNeeded: self.sdk.settings];
209
+
197
210
  [self.sdk initializeSdkWithCompletionHandler:^(ALSdkConfiguration *configuration)
198
211
  {
199
212
  [self log: @"SDK initialized"];
@@ -215,7 +228,7 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(isTablet)
215
228
 
216
229
  RCT_EXPORT_METHOD(showMediationDebugger)
217
230
  {
218
- if ( !_sdk )
231
+ if ( !self.sdk )
219
232
  {
220
233
  [self logUninitializedAccessError: @"showMediationDebugger"];
221
234
  return;
@@ -334,6 +347,26 @@ RCT_EXPORT_METHOD(setCreativeDebuggerEnabled:(BOOL)enabled)
334
347
  }
335
348
  }
336
349
 
350
+ RCT_EXPORT_METHOD(setExtraParameter:(NSString *)key :(nullable NSString *)value)
351
+ {
352
+ if ( ![key al_isValidString] )
353
+ {
354
+ [self log: @"[%@] Failed to set extra parameter for nil or empty key: %@", TAG, key];
355
+ return;
356
+ }
357
+
358
+ if ( self.sdk )
359
+ {
360
+ ALSdkSettings *settings = self.sdk.settings;
361
+ [settings setExtraParameterForKey: key value: value];
362
+ [self setPendingExtraParametersIfNeeded: settings];
363
+ }
364
+ else
365
+ {
366
+ self.extraParametersToSet[key] = value;
367
+ }
368
+ }
369
+
337
370
  RCT_EXPORT_METHOD(setConsentFlowEnabled:(BOOL)enabled)
338
371
  {
339
372
  self.consentFlowEnabledToSet = @(enabled);
@@ -351,20 +384,9 @@ RCT_EXPORT_METHOD(setTermsOfServiceUrl:(NSString *)urlString)
351
384
 
352
385
  #pragma mark - Data Passing
353
386
 
354
- RCT_EXPORT_METHOD(setUserSegment:(nullable NSString *)name)
355
- {
356
- if ( !_sdk )
357
- {
358
- [self logUninitializedAccessError: @"setUserSegment"];
359
- return;
360
- }
361
-
362
- self.sdk.userSegment.name = name;
363
- }
364
-
365
387
  RCT_EXPORT_METHOD(setTargetingDataYearOfBirth:(nonnull NSNumber *)yearOfBirth)
366
388
  {
367
- if ( !_sdk )
389
+ if ( !self.sdk )
368
390
  {
369
391
  [self logUninitializedAccessError: @"setTargetingDataYearOfBirth"];
370
392
  return;
@@ -375,7 +397,7 @@ RCT_EXPORT_METHOD(setTargetingDataYearOfBirth:(nonnull NSNumber *)yearOfBirth)
375
397
 
376
398
  RCT_EXPORT_METHOD(setTargetingDataGender:(nullable NSString *)gender)
377
399
  {
378
- if ( !_sdk )
400
+ if ( !self.sdk )
379
401
  {
380
402
  [self logUninitializedAccessError: @"setTargetingDataGender"];
381
403
  return;
@@ -401,7 +423,7 @@ RCT_EXPORT_METHOD(setTargetingDataGender:(nullable NSString *)gender)
401
423
 
402
424
  RCT_EXPORT_METHOD(setTargetingDataMaximumAdContentRating:(nonnull NSNumber *)maximumAdContentRating)
403
425
  {
404
- if ( !_sdk )
426
+ if ( !self.sdk )
405
427
  {
406
428
  [self logUninitializedAccessError: @"setTargetingDataMaximumAdContentRating"];
407
429
  return;
@@ -429,7 +451,7 @@ RCT_EXPORT_METHOD(setTargetingDataMaximumAdContentRating:(nonnull NSNumber *)max
429
451
 
430
452
  RCT_EXPORT_METHOD(setTargetingDataEmail:(nullable NSString *)email)
431
453
  {
432
- if ( !_sdk )
454
+ if ( !self.sdk )
433
455
  {
434
456
  [self logUninitializedAccessError: @"setTargetingDataEmail"];
435
457
  return;
@@ -440,7 +462,7 @@ RCT_EXPORT_METHOD(setTargetingDataEmail:(nullable NSString *)email)
440
462
 
441
463
  RCT_EXPORT_METHOD(setTargetingDataPhoneNumber:(nullable NSString *)phoneNumber)
442
464
  {
443
- if ( !_sdk )
465
+ if ( !self.sdk )
444
466
  {
445
467
  [self logUninitializedAccessError: @"setTargetingDataPhoneNumber"];
446
468
  return;
@@ -451,7 +473,7 @@ RCT_EXPORT_METHOD(setTargetingDataPhoneNumber:(nullable NSString *)phoneNumber)
451
473
 
452
474
  RCT_EXPORT_METHOD(setTargetingDataKeywords:(nullable NSArray<NSString *> *)keywords)
453
475
  {
454
- if ( !_sdk )
476
+ if ( !self.sdk )
455
477
  {
456
478
  [self logUninitializedAccessError: @"setTargetingDataKeywords"];
457
479
  return;
@@ -462,7 +484,7 @@ RCT_EXPORT_METHOD(setTargetingDataKeywords:(nullable NSArray<NSString *> *)keywo
462
484
 
463
485
  RCT_EXPORT_METHOD(setTargetingDataInterests:(nullable NSArray<NSString *> *)interests)
464
486
  {
465
- if ( !_sdk )
487
+ if ( !self.sdk )
466
488
  {
467
489
  [self logUninitializedAccessError: @"setTargetingDataInterests"];
468
490
  return;
@@ -473,7 +495,7 @@ RCT_EXPORT_METHOD(setTargetingDataInterests:(nullable NSArray<NSString *> *)inte
473
495
 
474
496
  RCT_EXPORT_METHOD(clearAllTargetingData)
475
497
  {
476
- if ( !_sdk )
498
+ if ( !self.sdk )
477
499
  {
478
500
  [self logUninitializedAccessError: @"clearAllTargetingData"];
479
501
  return;
@@ -482,15 +504,17 @@ RCT_EXPORT_METHOD(clearAllTargetingData)
482
504
  [self.sdk.targetingData clearAll];
483
505
  }
484
506
 
485
- RCT_EXPORT_METHOD(setLocationCollectionEnabled:(BOOL)locationCollectionEnabled)
507
+ RCT_EXPORT_METHOD(setLocationCollectionEnabled:(BOOL)enabled)
486
508
  {
487
- if ( !_sdk )
509
+ if ( [self isPluginInitialized] )
488
510
  {
489
- [self logUninitializedAccessError: @"setLocationCollectionEnabled"];
490
- return;
511
+ self.sdk.settings.locationCollectionEnabled = enabled;
512
+ self.locationCollectionEnabledToSet = nil;
513
+ }
514
+ else
515
+ {
516
+ self.locationCollectionEnabledToSet = @(enabled);
491
517
  }
492
-
493
- self.sdk.settings.locationCollectionEnabled = locationCollectionEnabled;
494
518
  }
495
519
 
496
520
  #pragma mark - Event Tracking
@@ -548,6 +572,16 @@ RCT_EXPORT_METHOD(setBannerExtraParameter:(NSString *)adUnitIdentifier :(NSStrin
548
572
  [self setAdViewExtraParameterForAdUnitIdentifier: adUnitIdentifier adFormat: DEVICE_SPECIFIC_ADVIEW_AD_FORMAT key: key value: value];
549
573
  }
550
574
 
575
+ RCT_EXPORT_METHOD(startBannerAutoRefresh:(NSString *)adUnitIdentifier)
576
+ {
577
+ [self startAutoRefresh: adUnitIdentifier adFormat: DEVICE_SPECIFIC_ADVIEW_AD_FORMAT];
578
+ }
579
+
580
+ RCT_EXPORT_METHOD(stopBannerAutoRefresh:(NSString *)adUnitIdentifier)
581
+ {
582
+ [self stopAutoRefresh: adUnitIdentifier adFormat: DEVICE_SPECIFIC_ADVIEW_AD_FORMAT];
583
+ }
584
+
551
585
  RCT_EXPORT_METHOD(showBanner:(NSString *)adUnitIdentifier)
552
586
  {
553
587
  [self showAdViewWithAdUnitIdentifier: adUnitIdentifier adFormat: DEVICE_SPECIFIC_ADVIEW_AD_FORMAT];
@@ -590,6 +624,16 @@ RCT_EXPORT_METHOD(updateMRecPosition:(NSString *)mrecPosition :(NSString *)adUni
590
624
  [self updateAdViewPosition: mrecPosition withOffset: CGPointZero forAdUnitIdentifier: adUnitIdentifier adFormat: MAAdFormat.mrec];
591
625
  }
592
626
 
627
+ RCT_EXPORT_METHOD(startMRecAutoRefresh:(NSString *)adUnitIdentifier)
628
+ {
629
+ [self startAutoRefresh: adUnitIdentifier adFormat: MAAdFormat.mrec];
630
+ }
631
+
632
+ RCT_EXPORT_METHOD(stopMRecAutoRefresh:(NSString *)adUnitIdentifier)
633
+ {
634
+ [self stopAutoRefresh: adUnitIdentifier adFormat: MAAdFormat.mrec];
635
+ }
636
+
593
637
  RCT_EXPORT_METHOD(showMRec:(NSString *)adUnitIdentifier)
594
638
  {
595
639
  [self showAdViewWithAdUnitIdentifier: adUnitIdentifier adFormat: MAAdFormat.mrec];
@@ -1052,6 +1096,28 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
1052
1096
  });
1053
1097
  }
1054
1098
 
1099
+ - (void)startAutoRefresh:(NSString *)adUnitIdentifier adFormat:(MAAdFormat *)adFormat
1100
+ {
1101
+ dispatch_async(dispatch_get_main_queue(), ^{
1102
+
1103
+ [self log: @"Starting auto refresh \"%@\" with ad unit identifier \"%@\"", adFormat, adUnitIdentifier];
1104
+
1105
+ MAAdView *view = [self retrieveAdViewForAdUnitIdentifier: adUnitIdentifier adFormat: adFormat];
1106
+ [view startAutoRefresh];
1107
+ });
1108
+ }
1109
+
1110
+ - (void)stopAutoRefresh:(NSString *)adUnitIdentifier adFormat:(MAAdFormat *)adFormat
1111
+ {
1112
+ dispatch_async(dispatch_get_main_queue(), ^{
1113
+
1114
+ [self log: @"Stopping auto refresh \"%@\" with ad unit identifier \"%@\"", adFormat, adUnitIdentifier];
1115
+
1116
+ MAAdView *view = [self retrieveAdViewForAdUnitIdentifier: adUnitIdentifier adFormat: adFormat];
1117
+ [view stopAutoRefresh];
1118
+ });
1119
+ }
1120
+
1055
1121
  - (void)showAdViewWithAdUnitIdentifier:(NSString *)adUnitIdentifier adFormat:(MAAdFormat *)adFormat
1056
1122
  {
1057
1123
  dispatch_async(dispatch_get_main_queue(), ^{
@@ -1155,6 +1221,9 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
1155
1221
  result.userInteractionEnabled = NO;
1156
1222
  result.translatesAutoresizingMaskIntoConstraints = NO;
1157
1223
 
1224
+ // Set this extra parameter to work around a SDK bug that ignores calls to stopAutoRefresh()
1225
+ [result setExtraParameterForKey: @"allow_pause_auto_refresh_immediately" value: @"true"];
1226
+
1158
1227
  self.adViews[adUnitIdentifier] = result;
1159
1228
  self.adViewPositions[adUnitIdentifier] = adViewPosition;
1160
1229
  self.adViewOffsets[adUnitIdentifier] = [NSValue valueWithCGPoint: offset];
@@ -1359,6 +1428,18 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
1359
1428
  [NSLayoutConstraint activateConstraints: constraints];
1360
1429
  }
1361
1430
 
1431
+ - (void)setPendingExtraParametersIfNeeded:(ALSdkSettings *)settings
1432
+ {
1433
+ if ( self.extraParametersToSet.count <= 0 ) return;
1434
+
1435
+ for ( NSString *key in self.extraParametersToSet.allKeys )
1436
+ {
1437
+ [settings setExtraParameterForKey: key value: self.extraParametersToSet[key]];
1438
+ }
1439
+
1440
+ [self.extraParametersToSet removeAllObjects];
1441
+ }
1442
+
1362
1443
  - (void)logInvalidAdFormat:(MAAdFormat *)adFormat
1363
1444
  {
1364
1445
  [self log: @"invalid ad format: %@, from %@", adFormat, [NSThread callStackSymbols]];
@@ -1388,7 +1469,8 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
1388
1469
  @"networkName" : ad.networkName,
1389
1470
  @"placement" : ad.placement ?: @"",
1390
1471
  @"revenue" : @(ad.revenue),
1391
- @"waterfall": [self createAdWaterfallInfo: ad.waterfall]};
1472
+ @"waterfall": [self createAdWaterfallInfo: ad.waterfall],
1473
+ @"dspName" : ad.DSPName ?: @""};
1392
1474
  }
1393
1475
 
1394
1476
  #pragma mark - Waterfall Information
@@ -27,6 +27,7 @@
27
27
  @property (nonatomic, strong) NSMutableDictionary<NSNumber *, NSString *> *placementRegistry;
28
28
  @property (nonatomic, strong) NSMutableDictionary<NSNumber *, NSString *> *customDataRegistry;
29
29
  @property (nonatomic, strong) NSMutableDictionary<NSNumber *, NSString *> *adaptiveBannerEnabledRegistry;
30
+ @property (nonatomic, strong) NSMutableDictionary<NSNumber *, NSNumber *> *autoRefreshEnabledRegistry;
30
31
 
31
32
  @end
32
33
 
@@ -49,6 +50,7 @@ RCT_EXPORT_MODULE(AppLovinMAXAdView)
49
50
  self.placementRegistry = [NSMutableDictionary dictionary];
50
51
  self.customDataRegistry = [NSMutableDictionary dictionary];
51
52
  self.adaptiveBannerEnabledRegistry = [NSMutableDictionary dictionary];
53
+ self.autoRefreshEnabledRegistry = [NSMutableDictionary dictionary];
52
54
  }
53
55
  return self;
54
56
  }
@@ -134,6 +136,38 @@ RCT_EXPORT_METHOD(setAdaptiveBannerEnabled:(nonnull NSNumber *)viewTag toEnabled
134
136
  }];
135
137
  }
136
138
 
139
+ // NOTE: `nonnull` must be annotated here for this RN export to work at runtime
140
+ RCT_EXPORT_METHOD(setAutoRefresh:(nonnull NSNumber *)viewTag toEnabled:(BOOL)enabled)
141
+ {
142
+ [self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
143
+
144
+ // NOTE: iOS caches the native view via `viewTag` when you remove it from screen (unlike Android)
145
+ UIView *view = viewRegistry[viewTag];
146
+ if ( !view )
147
+ {
148
+ RCTLogError(@"Cannot find UIView with tag %@", viewTag);
149
+ return;
150
+ }
151
+
152
+ MAAdView *adView = [self adViewFromContainerView: view];
153
+ if ( adView )
154
+ {
155
+ if ( enabled )
156
+ {
157
+ [adView startAutoRefresh];
158
+ }
159
+ else
160
+ {
161
+ [adView stopAutoRefresh];
162
+ }
163
+ }
164
+ else
165
+ {
166
+ self.autoRefreshEnabledRegistry[viewTag] = @(enabled);
167
+ }
168
+ }];
169
+ }
170
+
137
171
  // NOTE: `nonnull` must be annotated here for this RN export to work at runtime
138
172
  RCT_EXPORT_METHOD(setAdUnitId:(nonnull NSNumber *)viewTag toAdUnitId:(NSString *)adUnitId)
139
173
  {
@@ -230,6 +264,22 @@ RCT_EXPORT_METHOD(setAdFormat:(nonnull NSNumber *)viewTag toAdFormat:(NSString *
230
264
  [adView setExtraParameterForKey: @"adaptive_banner" value: adaptiveBannerEnabledStr];
231
265
  }
232
266
 
267
+ // Set this extra parameter to work around a SDK bug that ignores calls to stopAutoRefresh()
268
+ [adView setExtraParameterForKey: @"allow_pause_auto_refresh_immediately" value: @"true"];
269
+
270
+ NSNumber *autoRefreshEnabled = self.autoRefreshEnabledRegistry[viewTag];
271
+ if ( autoRefreshEnabled )
272
+ {
273
+ if ( [autoRefreshEnabled boolValue] )
274
+ {
275
+ [adView startAutoRefresh];
276
+ }
277
+ else
278
+ {
279
+ [adView stopAutoRefresh];
280
+ }
281
+ }
282
+
233
283
  [adView loadAd];
234
284
 
235
285
  [containerView addSubview: adView];
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.4.2'
38
+ pod 'AppLovinSDK', '11.4.3'
39
39
 
40
40
  end
package/ios/Podfile.lock CHANGED
@@ -1,5 +1,5 @@
1
1
  PODS:
2
- - AppLovinSDK (11.4.2)
2
+ - AppLovinSDK (11.4.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.4.2)
252
+ - AppLovinSDK (= 11.4.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: 119a0b2a743f9d9c6002c58776b1013778a65084
342
+ AppLovinSDK: 221dfbdff620be0ff227ed5b018b97b1f3d15713
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: 485c4fe7a35ea71547f789315321ae261127772e
371
+ PODFILE CHECKSUM: 26bc18f6057a79b7f583981eaa607d7b30a63d74
372
372
 
373
373
  COCOAPODS: 1.11.2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-applovin-max",
3
3
  "author": "AppLovin Corporation",
4
- "version": "3.2.0",
4
+ "version": "3.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_3_2_0" }
14
+ s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_3_3_0" }
15
15
 
16
16
  s.source_files = "ios/AppLovinMAX*.{h,m}"
17
17
 
18
18
  s.dependency "React"
19
- s.dependency "AppLovinSDK", "11.4.2"
19
+ s.dependency "AppLovinSDK", "11.4.3"
20
20
  end
@@ -1,7 +1,53 @@
1
- import { requireNativeComponent, UIManager, findNodeHandle } from "react-native";
1
+ import { NativeModules, requireNativeComponent, UIManager, findNodeHandle, View, Text, StyleSheet } from "react-native";
2
2
  import PropTypes from "prop-types";
3
3
  import React from "react";
4
- import AppLovinMAX from "./index.js";
4
+
5
+ const { AppLovinMAX } = NativeModules;
6
+
7
+ export const AdFormat = {
8
+ BANNER: "banner",
9
+ MREC: "mrec",
10
+ };
11
+
12
+ export const AdViewPosition = {
13
+ TOP_CENTER: "top_center",
14
+ TOP_LEFT: "top_left",
15
+ TOP_RIGHT: "top_right",
16
+ CENTERED: "centered",
17
+ CENTER_LEFT: "center_left",
18
+ CENTER_RIGHT: "center_right",
19
+ BOTTOM_LEFT: "bottom_left",
20
+ BOTTOM_CENTER: "bottom_center",
21
+ BOTTOM_RIGHT: "bottom_right",
22
+ };
23
+
24
+ const AdViewWrapper = (props) => {
25
+ const {style, ...rest} = props;
26
+ return (
27
+ AppLovinMAX.isInitialized() ?
28
+ <AdView {...style} {...rest}/>
29
+ :
30
+ <View style={[styles.container, style]} {...rest}>
31
+ {
32
+ console.warn('[AppLovinSdk] [AppLovinMAX] <AdView/> has been mounted before AppLovin initialization')
33
+ }
34
+ </View>
35
+ )
36
+ };
37
+
38
+ const styles = StyleSheet.create({
39
+ container: {
40
+ flexDirection: 'column',
41
+ justifyContent: 'flex-end',
42
+ alignItems: 'center',
43
+ backgroundColor: 'black',
44
+ borderColor: 'whitesmoke',
45
+ borderWidth: 1,
46
+ },
47
+ message: {
48
+ color: 'white',
49
+ },
50
+ });
5
51
 
6
52
  class AdView extends React.Component {
7
53
 
@@ -15,6 +61,7 @@ class AdView extends React.Component {
15
61
  this.setPlacement(this.props.placement);
16
62
  this.setCustomData(this.props.customData);
17
63
  this.setAdaptiveBannerEnabled(this.props.adaptiveBannerEnabled);
64
+ this.setAutoRefresh(this.props.autoRefresh);
18
65
  }
19
66
 
20
67
  componentDidUpdate(prevProps) {
@@ -38,6 +85,10 @@ class AdView extends React.Component {
38
85
  if (prevProps.adaptiveBannerEnabled !== this.props.adaptiveBannerEnabled) {
39
86
  this.setAdaptiveBannerEnabled(this.props.adaptiveBannerEnabled);
40
87
  }
88
+
89
+ if (prevProps.autoRefresh !== this.props.autoRefresh) {
90
+ this.setAutoRefresh(this.props.autoRefresh);
91
+ }
41
92
  }
42
93
 
43
94
  render() {
@@ -52,7 +103,7 @@ class AdView extends React.Component {
52
103
  // Helper Functions
53
104
 
54
105
  sizeForAdFormat(adFormat) {
55
- if (adFormat === AppLovinMAX.AdFormat.BANNER) {
106
+ if (adFormat === AdFormat.BANNER) {
56
107
 
57
108
  var width = AppLovinMAX.isTablet() ? 728 : 320;
58
109
  var height;
@@ -120,7 +171,7 @@ class AdView extends React.Component {
120
171
  // If the ad unit id or ad format are unset, we can't set the value
121
172
  if (adUnitId == null || adFormat == null) return;
122
173
 
123
- if (adFormat === AppLovinMAX.AdFormat.BANNER) {
174
+ if (adFormat === AdFormat.BANNER) {
124
175
  if (enabled === true || enabled === false) {
125
176
  UIManager.dispatchViewManagerCommand(
126
177
  findNodeHandle(this),
@@ -130,6 +181,22 @@ class AdView extends React.Component {
130
181
  }
131
182
  }
132
183
  }
184
+
185
+ setAutoRefresh(enabled) {
186
+ var adUnitId = this.props.adUnitId;
187
+ var adFormat = this.props.adFormat;
188
+
189
+ // If the ad unit id or ad format are unset, we can't set the autorefresh.
190
+ if (adUnitId == null || adFormat == null) return;
191
+
192
+ if (enabled === true || enabled === false) {
193
+ UIManager.dispatchViewManagerCommand(
194
+ findNodeHandle(this),
195
+ Platform.OS === 'android' ? "setAutoRefresh" : UIManager.getViewManagerConfig("AppLovinMAXAdView").Commands.setAutoRefresh,
196
+ [enabled]
197
+ );
198
+ }
199
+ }
133
200
  }
134
201
 
135
202
  AdView.propTypes = {
@@ -157,9 +224,14 @@ AdView.propTypes = {
157
224
  * A boolean value representing whether or not to enable adaptive banners. Note that adaptive banners are enabled by default as of v2.3.0.
158
225
  */
159
226
  adaptiveBannerEnabled: PropTypes.bool,
227
+
228
+ /**
229
+ * A boolean value representing whether or not to enable auto-refresh. Note that auto-refresh is enabled by default.
230
+ */
231
+ autoRefresh: PropTypes.bool,
160
232
  };
161
233
 
162
234
  // requireNativeComponent automatically resolves 'AppLovinMAXAdView' to 'AppLovinMAXAdViewManager'
163
235
  var AppLovinMAXAdView = requireNativeComponent("AppLovinMAXAdView", AdView);
164
236
 
165
- export default AdView;
237
+ export default AdViewWrapper;
@@ -1,4 +1,6 @@
1
- import AppLovinMAX from "./index.js";
1
+ import { NativeModules } from "react-native";
2
+
3
+ const { AppLovinMAX } = NativeModules;
2
4
 
3
5
  const AdContentRating = {
4
6
  None: 0,
package/src/index.js CHANGED
@@ -1,11 +1,10 @@
1
1
  import { NativeModules, NativeEventEmitter } from "react-native";
2
- import AdView from "./AppLovinMAXAdView";
2
+ import AdView, { AdFormat, AdViewPosition } from "./AppLovinMAXAdView";
3
3
  import { TargetingData as targetingData, AdContentRating, UserGender } from "./TargetingData";
4
- import { UserSegment as userSegment } from "./UserSegment";
5
4
 
6
5
  const { AppLovinMAX } = NativeModules;
7
6
 
8
- const VERSION = "3.2.0";
7
+ const VERSION = "3.3.0";
9
8
 
10
9
  /**
11
10
  * This enum represents whether or not the consent dialog should be shown for this user.
@@ -28,25 +27,6 @@ const ConsentDialogState = {
28
27
  DOES_NOT_APPLY: 2,
29
28
  };
30
29
 
31
- const AdFormat = {
32
- BANNER: "banner",
33
- MREC: "mrec",
34
- };
35
-
36
- const AdViewPosition = {
37
- TOP_CENTER: "top_center",
38
- TOP_LEFT: "top_left",
39
- TOP_RIGHT: "top_right",
40
- CENTERED: "centered",
41
- CENTER_LEFT: "center_left",
42
- CENTER_RIGHT: "center_right",
43
- BOTTOM_LEFT: "bottom_left",
44
- BOTTOM_CENTER: "bottom_center",
45
- BOTTOM_RIGHT: "bottom_right",
46
- };
47
-
48
- // const AdView = AppLovinMAXAdView;
49
-
50
30
  const emitter = new NativeEventEmitter(AppLovinMAX);
51
31
  const subscriptions = {};
52
32
 
@@ -104,7 +84,6 @@ const showRewardedAd = (adUnitId, ...args) => {
104
84
  export default {
105
85
  ...AppLovinMAX,
106
86
  AdView,
107
- userSegment,
108
87
  targetingData,
109
88
  AdContentRating,
110
89
  UserGender,
@@ -1,12 +0,0 @@
1
- import AppLovinMAX from "./index.js";
2
-
3
- let UserSegment = {
4
-
5
- set name(value) {
6
- AppLovinMAX.setUserSegment(value);
7
- },
8
- };
9
-
10
- export {
11
- UserSegment,
12
- };