react-native-applovin-max 3.2.2 → 3.3.1

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.
@@ -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
  {
@@ -880,12 +931,6 @@ public class AppLovinMAXModule
880
931
  {
881
932
  adView.stopAutoRefresh();
882
933
  }
883
-
884
- adView = sAdViewsToRemove.remove( ad.getAdUnitId() );
885
- if ( adView != null )
886
- {
887
- adView.stopAutoRefresh();
888
- }
889
934
  }
890
935
  else if ( MaxAdFormat.INTERSTITIAL == adFormat )
891
936
  {
@@ -1075,7 +1120,7 @@ public class AppLovinMAXModule
1075
1120
  sendReactNativeEvent( ( MaxAdFormat.MREC == adFormat ) ? "OnMRecAdCollapsedEvent" : "OnBannerAdCollapsedEvent", getAdInfo( ad ) );
1076
1121
  }
1077
1122
 
1078
- @Override
1123
+ @Override
1079
1124
  public void onAdRevenuePaid(final MaxAd ad)
1080
1125
  {
1081
1126
  final MaxAdFormat adFormat = ad.getFormat();
@@ -1434,6 +1479,48 @@ public class AppLovinMAXModule
1434
1479
  } );
1435
1480
  }
1436
1481
 
1482
+ private void startAutoRefresh(final String adUnitId, final MaxAdFormat adFormat)
1483
+ {
1484
+ getReactApplicationContext().runOnUiQueueThread( new Runnable()
1485
+ {
1486
+ @Override
1487
+ public void run()
1488
+ {
1489
+ d( "Starting auto refresh " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1490
+
1491
+ final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
1492
+ if ( adView == null )
1493
+ {
1494
+ e( adFormat.getLabel() + " does not exist" );
1495
+ return;
1496
+ }
1497
+
1498
+ adView.startAutoRefresh();
1499
+ }
1500
+ } );
1501
+ }
1502
+
1503
+ private void stopAutoRefresh(final String adUnitId, final MaxAdFormat adFormat)
1504
+ {
1505
+ getReactApplicationContext().runOnUiQueueThread( new Runnable()
1506
+ {
1507
+ @Override
1508
+ public void run()
1509
+ {
1510
+ d( "Stopping auto refresh " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1511
+
1512
+ final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
1513
+ if ( adView == null )
1514
+ {
1515
+ e( adFormat.getLabel() + " does not exist" );
1516
+ return;
1517
+ }
1518
+
1519
+ adView.stopAutoRefresh();
1520
+ }
1521
+ } );
1522
+ }
1523
+
1437
1524
  @Nullable
1438
1525
  private MaxInterstitialAd retrieveInterstitial(String adUnitId)
1439
1526
  {
@@ -1486,6 +1573,9 @@ public class AppLovinMAXModule
1486
1573
  result.setListener( this );
1487
1574
  result.setRevenueListener( this );
1488
1575
 
1576
+ // Set this extra parameter to work around a SDK bug that ignores calls to stopAutoRefresh()
1577
+ result.setExtraParameter( "allow_pause_auto_refresh_immediately", "true" );
1578
+
1489
1579
  mAdViews.put( adUnitId, result );
1490
1580
  mAdViewPositions.put( adUnitId, adViewPosition );
1491
1581
  mAdViewOffsets.put( adUnitId, adViewOffsetPixels );
@@ -1629,6 +1719,18 @@ public class AppLovinMAXModule
1629
1719
  relativeLayout.setPadding( adViewOffset.x, adViewOffset.y, adViewOffset.x, adViewOffset.y );
1630
1720
  }
1631
1721
 
1722
+ private void setPendingExtraParametersIfNeeded(final AppLovinSdkSettings settings)
1723
+ {
1724
+ if ( extraParametersToSet.size() <= 0 ) return;
1725
+
1726
+ for ( final String key : extraParametersToSet.keySet() )
1727
+ {
1728
+ settings.setExtraParameter( key, extraParametersToSet.get( key ) );
1729
+ }
1730
+
1731
+ extraParametersToSet.clear();
1732
+ }
1733
+
1632
1734
  // Utility Methods
1633
1735
 
1634
1736
  private void logInvalidAdFormat(MaxAdFormat adFormat)
@@ -1770,8 +1872,11 @@ public class AppLovinMAXModule
1770
1872
  WritableMap credentials = Arguments.createMap();
1771
1873
  for ( String key : credentialBundle.keySet() )
1772
1874
  {
1773
- String value = credentialBundle.getString( key, "" );
1774
- credentials.putString( key, value );
1875
+ Object obj = credentialBundle.get( key );
1876
+ if ( obj instanceof String )
1877
+ {
1878
+ credentials.putString( key, (String) obj );
1879
+ }
1775
1880
  }
1776
1881
  networkResponseObject.putMap( "credentials", credentials );
1777
1882
 
@@ -1791,6 +1896,49 @@ public class AppLovinMAXModule
1791
1896
  return networkResponseObject;
1792
1897
  }
1793
1898
 
1899
+ // Lifecycle Events
1900
+
1901
+ @Override
1902
+ public void onHostResume() { }
1903
+
1904
+ @Override
1905
+ public void onHostPause() { }
1906
+
1907
+ @Override
1908
+ public void onHostDestroy()
1909
+ {
1910
+ // Make copy because `destroyAdView()` will remove from `mAdViews`
1911
+ List<MaxAdView> adViews = new ArrayList<>( mAdViews.values() );
1912
+ for ( MaxAdView adView : adViews )
1913
+ {
1914
+ destroyAdView( adView.getAdUnitId(), adView.getAdFormat() );
1915
+ }
1916
+
1917
+ for ( MaxInterstitialAd interstitialAd : mInterstitials.values() )
1918
+ {
1919
+ interstitialAd.destroy();
1920
+ }
1921
+ mInterstitials.clear();
1922
+
1923
+ for ( MaxRewardedAd rewardedAd : mRewardedAds.values() )
1924
+ {
1925
+ rewardedAd.destroy();
1926
+ }
1927
+ mRewardedAds.clear();
1928
+ }
1929
+
1930
+ // Required methods introduced React Native 0.65
1931
+ //
1932
+ // Without these methods, the following warnings are generated.
1933
+ //
1934
+ // WARN new NativeEventEmitter() was called with a non-null argument without the required addListener method.
1935
+ // WARN new NativeEventEmitter() was called with a non-null argument without the required removeListeners method.
1936
+ @ReactMethod
1937
+ public void addListener(String eventName) { }
1938
+
1939
+ @ReactMethod
1940
+ public void removeListeners(Integer count) { }
1941
+
1794
1942
  // React Native Bridge
1795
1943
 
1796
1944
  private void sendReactNativeEvent(final String name, @Nullable final WritableMap params)
package/ios/AppLovinMAX.h CHANGED
@@ -31,6 +31,11 @@ NS_ASSUME_NONNULL_BEGIN
31
31
  */
32
32
  @property (nonatomic, weak, readonly) ALSdk *sdk;
33
33
 
34
+ /**
35
+ * Convenience method for unified logging in the AppLovin module.
36
+ */
37
+ - (void)log:(NSString *)format, ...;
38
+
34
39
  @end
35
40
 
36
41
  NS_ASSUME_NONNULL_END
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;
@@ -183,7 +187,7 @@ RCT_EXPORT_METHOD(initialize:(NSString *)pluginVersion :(NSString *)sdkKey :(RCT
183
187
  // Set verbose logging state if needed
184
188
  if ( self.verboseLoggingToSet )
185
189
  {
186
- self.sdk.settings.isVerboseLogging = self.verboseLoggingToSet.boolValue;
190
+ self.sdk.settings.verboseLoggingEnabled = self.verboseLoggingToSet.boolValue;
187
191
  self.verboseLoggingToSet = nil;
188
192
  }
189
193
 
@@ -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;
@@ -299,7 +312,7 @@ RCT_EXPORT_METHOD(setVerboseLogging:(BOOL)enabled)
299
312
  {
300
313
  if ( [self isPluginInitialized] )
301
314
  {
302
- self.sdk.settings.isVerboseLogging = enabled;
315
+ self.sdk.settings.verboseLoggingEnabled = enabled;
303
316
  self.verboseLoggingToSet = nil;
304
317
  }
305
318
  else
@@ -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]];
@@ -8,6 +8,7 @@
8
8
 
9
9
  /* Begin PBXBuildFile section */
10
10
  1D2890F5251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D2890F4251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m */; };
11
+ 1D3CC34128C18441003E5A07 /* AppLovinMAXAdView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3CC34028C18441003E5A07 /* AppLovinMAXAdView.m */; };
11
12
  1DEA13CD24B9258700D42847 /* AppLovinMAX.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DEA13CC24B9258700D42847 /* AppLovinMAX.m */; };
12
13
  DE4E5A3D46DDFAE766DFFE58 /* libPods-AppLovinMAX.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EF1B4EBC7187611714984C78 /* libPods-AppLovinMAX.a */; };
13
14
  /* End PBXBuildFile section */
@@ -29,6 +30,8 @@
29
30
  134814201AA4EA6300B7C361 /* libAppLovinMAX.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAppLovinMAX.a; sourceTree = BUILT_PRODUCTS_DIR; };
30
31
  1D2890F3251ABC83004F1CC4 /* AppLovinMAXAdViewManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppLovinMAXAdViewManager.h; sourceTree = "<group>"; };
31
32
  1D2890F4251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppLovinMAXAdViewManager.m; sourceTree = "<group>"; };
33
+ 1D3CC33F28C18440003E5A07 /* AppLovinMAXAdView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppLovinMAXAdView.h; sourceTree = "<group>"; };
34
+ 1D3CC34028C18441003E5A07 /* AppLovinMAXAdView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppLovinMAXAdView.m; sourceTree = "<group>"; };
32
35
  1DEA13CC24B9258700D42847 /* AppLovinMAX.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppLovinMAX.m; sourceTree = "<group>"; };
33
36
  B3E7B5881CC2AC0600A0062D /* AppLovinMAX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppLovinMAX.h; sourceTree = "<group>"; };
34
37
  EF1B4EBC7187611714984C78 /* libPods-AppLovinMAX.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AppLovinMAX.a"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -68,6 +71,8 @@
68
71
  children = (
69
72
  B3E7B5881CC2AC0600A0062D /* AppLovinMAX.h */,
70
73
  1DEA13CC24B9258700D42847 /* AppLovinMAX.m */,
74
+ 1D3CC33F28C18440003E5A07 /* AppLovinMAXAdView.h */,
75
+ 1D3CC34028C18441003E5A07 /* AppLovinMAXAdView.m */,
71
76
  1D2890F3251ABC83004F1CC4 /* AppLovinMAXAdViewManager.h */,
72
77
  1D2890F4251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m */,
73
78
  134814211AA4EA7D00B7C361 /* Products */,
@@ -169,6 +174,7 @@
169
174
  buildActionMask = 2147483647;
170
175
  files = (
171
176
  1D2890F5251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m in Sources */,
177
+ 1D3CC34128C18441003E5A07 /* AppLovinMAXAdView.m in Sources */,
172
178
  1DEA13CD24B9258700D42847 /* AppLovinMAX.m in Sources */,
173
179
  );
174
180
  runOnlyForDeploymentPostprocessing = 0;