react-native-applovin-max 6.1.0 → 6.2.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 6010000
39
- versionName "6.1.0"
38
+ versionCode 6020000
39
+ versionName "6.2.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.0.0'
143
+ implementation 'com.applovin:applovin-sdk:12.1.0'
144
144
  }
@@ -151,6 +151,7 @@ public class AppLovinMAXModule
151
151
  // Store these values if pub attempts to set it before initializing
152
152
  private List<String> initializationAdUnitIdsToSet;
153
153
  private String userIdToSet;
154
+ private Boolean mutedToSet;
154
155
  private List<String> testDeviceAdvertisingIdsToSet;
155
156
  private Boolean verboseLoggingToSet;
156
157
  private Boolean creativeDebuggerEnabledToSet;
@@ -331,6 +332,13 @@ public class AppLovinMAXModule
331
332
  debugUserGeographyToSet = null;
332
333
  }
333
334
 
335
+ // Set muted if needed
336
+ if ( mutedToSet != null )
337
+ {
338
+ settings.setMuted( mutedToSet );
339
+ mutedToSet = null;
340
+ }
341
+
334
342
  // Set test device ids if needed
335
343
  if ( testDeviceAdvertisingIdsToSet != null )
336
344
  {
@@ -531,9 +539,15 @@ public class AppLovinMAXModule
531
539
  @ReactMethod
532
540
  public void setMuted(final boolean muted)
533
541
  {
534
- if ( !isPluginInitialized ) return;
535
-
536
- sdk.getSettings().setMuted( muted );
542
+ if ( isPluginInitialized )
543
+ {
544
+ sdk.getSettings().setMuted( muted );
545
+ mutedToSet = null;
546
+ }
547
+ else
548
+ {
549
+ mutedToSet = muted;
550
+ }
537
551
  }
538
552
 
539
553
  @ReactMethod
@@ -2659,6 +2673,63 @@ public class AppLovinMAXModule
2659
2673
  return networkResponseObject;
2660
2674
  }
2661
2675
 
2676
+ // Amazon
2677
+
2678
+ public void setAmazonBannerResult(final Object result, final String adUnitId)
2679
+ {
2680
+ setAmazonResult( result, adUnitId, MaxAdFormat.BANNER );
2681
+ }
2682
+
2683
+ public void setAmazonMRecResult(final Object result, final String adUnitId)
2684
+ {
2685
+ setAmazonResult( result, adUnitId, MaxAdFormat.MREC );
2686
+ }
2687
+
2688
+ public void setAmazonInterstitialResult(final Object result, final String adUnitId)
2689
+ {
2690
+ setAmazonResult( result, adUnitId, MaxAdFormat.INTERSTITIAL );
2691
+ }
2692
+
2693
+ private void setAmazonResult(final Object result, final String adUnitId, final MaxAdFormat adFormat)
2694
+ {
2695
+ if ( sdk == null )
2696
+ {
2697
+ logUninitializedAccessError( "Failed to set Amazon result - SDK not initialized: " + adUnitId );
2698
+ return;
2699
+ }
2700
+
2701
+ if ( result == null )
2702
+ {
2703
+ e( "Failed to set Amazon result - null value" );
2704
+ return;
2705
+ }
2706
+
2707
+ String key = getLocalExtraParameterKeyForAmazonResult( result );
2708
+
2709
+ if ( adFormat == MaxAdFormat.INTERSTITIAL )
2710
+ {
2711
+ MaxInterstitialAd interstitial = retrieveInterstitial( adUnitId, "setAmazonResult" );
2712
+ if ( interstitial == null )
2713
+ {
2714
+ e( "Unable to set Amazon result - unable to retrieve interstitial" );
2715
+ return;
2716
+ }
2717
+
2718
+ interstitial.setLocalExtraParameter( key, result );
2719
+ }
2720
+ else
2721
+ {
2722
+ MaxAdView adView = retrieveAdView( adUnitId, adFormat );
2723
+ adView.setLocalExtraParameter( key, result );
2724
+ }
2725
+ }
2726
+
2727
+ private String getLocalExtraParameterKeyForAmazonResult(final Object /* DTBAdResponse or AdError */ result)
2728
+ {
2729
+ String className = result.getClass().getSimpleName();
2730
+ return "DTBAdResponse".equalsIgnoreCase( className ) ? "amazon_ad_response" : "amazon_ad_error";
2731
+ }
2732
+
2662
2733
  // Lifecycle Events
2663
2734
 
2664
2735
  @Override
@@ -1,6 +1,8 @@
1
1
  package com.applovin.reactnative;
2
2
 
3
3
  import android.content.Context;
4
+ import android.os.Handler;
5
+ import android.os.Looper;
4
6
  import android.text.TextUtils;
5
7
  import android.view.View;
6
8
  import android.view.ViewGroup;
@@ -29,8 +31,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
29
31
 
30
32
  import androidx.annotation.Nullable;
31
33
 
32
- import static com.applovin.sdk.AppLovinSdkUtils.runOnUiThreadDelayed;
33
-
34
34
  public class AppLovinMAXNativeAdView
35
35
  extends ReactViewGroup
36
36
  implements MaxAdRevenueListener, View.OnLayoutChangeListener, ViewGroup.OnHierarchyChangeListener
@@ -42,12 +42,15 @@ public class AppLovinMAXNativeAdView
42
42
  private static final int CALL_TO_ACTION_VIEW_TAG = 5;
43
43
  private static final int ADVERTISER_VIEW_TAG = 8;
44
44
 
45
- private final ReactContext reactContext;
45
+ private final ReactContext reactContext;
46
46
  @Nullable
47
- private MaxNativeAdLoader adLoader;
47
+ private MaxNativeAdLoader adLoader;
48
48
  @Nullable
49
- private MaxAd nativeAd;
50
- private final AtomicBoolean isLoading = new AtomicBoolean(); // Guard against repeated ad loads
49
+ private MaxAd nativeAd;
50
+ private final AtomicBoolean isLoading = new AtomicBoolean(); // Guard against repeated ad loads
51
+ private final AtomicBoolean isAdUnitIdSet = new AtomicBoolean();
52
+ private final Handler renderNativeAdHandler = new Handler( Looper.getMainLooper() );
53
+ private final RenderNativeAdTask renderNativeAdTask = new RenderNativeAdTask( this );
51
54
 
52
55
  @Nullable
53
56
  private View mediaView;
@@ -91,8 +94,7 @@ public class AppLovinMAXNativeAdView
91
94
 
92
95
  adUnitId = value;
93
96
 
94
- // Explicitly invoke ad load now that Ad Unit ID is set, but do so after 0.25s to allow other props to set
95
- postDelayed( this::loadAd, 250 );
97
+ isAdUnitIdSet.set( true );
96
98
  }
97
99
 
98
100
  public void setPlacement(@Nullable final String value)
@@ -197,25 +199,7 @@ public class AppLovinMAXNativeAdView
197
199
  // Notify `AppLovinNativeAdView.js`
198
200
  sendAdLoadedReactNativeEventForAd( ad.getNativeAd() );
199
201
 
200
- // After notifying the RN layer - have slight delay to let views bind to this layer in `clickableViews` before registering
201
- runOnUiThreadDelayed( () -> {
202
-
203
- // Loader can be null when the user hides before the properties are fully set
204
- if ( adLoader != null )
205
- {
206
- adLoader.a( clickableViews, AppLovinMAXNativeAdView.this, ad );
207
- adLoader.b( ad );
208
- }
209
-
210
- // Reassure the size of `mediaView` and its children for the networks, such as
211
- // LINE, where the actual ad contents are loaded after `mediaView` is sized.
212
- if ( mediaView != null && mediaView.getParent() != null )
213
- {
214
- sizeToFit( mediaView, (View) mediaView.getParent() );
215
- }
216
-
217
- isLoading.set( false );
218
- }, 500L );
202
+ isLoading.set( false );
219
203
  }
220
204
 
221
205
  @Override
@@ -421,6 +405,48 @@ public class AppLovinMAXNativeAdView
421
405
  }
422
406
  }
423
407
 
408
+ static class RenderNativeAdTask
409
+ implements Runnable
410
+ {
411
+ private AppLovinMAXNativeAdView nativeAdView;
412
+
413
+ RenderNativeAdTask(AppLovinMAXNativeAdView nativeAdView) { this.nativeAdView = nativeAdView; }
414
+
415
+ @Override
416
+ public void run()
417
+ {
418
+ if ( nativeAdView.adLoader == null ) return;
419
+
420
+ nativeAdView.adLoader.a( nativeAdView.clickableViews, nativeAdView, nativeAdView.nativeAd );
421
+ nativeAdView.adLoader.b( nativeAdView.nativeAd );
422
+
423
+ // LINE needs to be sized a while after its mediaView is attached to the React Native
424
+ if ( nativeAdView.mediaView != null && nativeAdView.mediaView.getParent() != null )
425
+ {
426
+ nativeAdView.renderNativeAdHandler.postDelayed( () -> sizeToFit( nativeAdView.mediaView, (View) nativeAdView.mediaView.getParent() ), 500 );
427
+ }
428
+ }
429
+ }
430
+
431
+ /**
432
+ * Invoked via ViewManager.onAfterUpdateTransaction():
433
+ * 1. after all the JavaScript properties are set when mounting NativeAdView
434
+ * 2. every time one of the asset views is mounted, following the 1st event
435
+ */
436
+ public void onSetProps()
437
+ {
438
+ if ( isAdUnitIdSet.compareAndSet( true, false ) )
439
+ {
440
+ loadAd();
441
+ }
442
+ else
443
+ {
444
+ // Renders the ad only after the last asset view is set
445
+ renderNativeAdHandler.removeCallbacksAndMessages( null );
446
+ renderNativeAdHandler.postDelayed( renderNativeAdTask, 1 );
447
+ }
448
+ }
449
+
424
450
  @Override
425
451
  public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom)
426
452
  {
@@ -148,6 +148,14 @@ public class AppLovinMAXNativeAdViewManager
148
148
  view.setMediaView( value );
149
149
  }
150
150
 
151
+ @Override
152
+ public void onAfterUpdateTransaction(final AppLovinMAXNativeAdView view)
153
+ {
154
+ super.onAfterUpdateTransaction( view );
155
+
156
+ view.onSetProps();
157
+ }
158
+
151
159
  @Override
152
160
  public void onDropViewInstance(@NonNull final AppLovinMAXNativeAdView view)
153
161
  {
package/ios/AppLovinMAX.m CHANGED
@@ -39,6 +39,7 @@
39
39
  // Store these values if pub attempts to set it before initializing
40
40
  @property (nonatomic, strong, nullable) NSArray<NSString *> *initializationAdUnitIdentifiersToSet;
41
41
  @property (nonatomic, copy, nullable) NSString *userIdentifierToSet;
42
+ @property (nonatomic, strong, nullable) NSNumber *mutedToSet;
42
43
  @property (nonatomic, strong, nullable) NSArray<NSString *> *testDeviceIdentifiersToSet;
43
44
  @property (nonatomic, strong, nullable) NSNumber *verboseLoggingToSet;
44
45
  @property (nonatomic, strong, nullable) NSNumber *creativeDebuggerEnabledToSet;
@@ -225,58 +226,65 @@ RCT_EXPORT_METHOD(initialize:(NSString *)pluginVersion :(NSString *)sdkKey :(RCT
225
226
  }
226
227
 
227
228
  ALSdkSettings *settings = [[ALSdkSettings alloc] init];
228
-
229
+
229
230
  // Selective init
230
231
  if ( self.initializationAdUnitIdentifiersToSet )
231
232
  {
232
233
  settings.initializationAdUnitIdentifiers = self.initializationAdUnitIdentifiersToSet;
233
234
  self.initializationAdUnitIdentifiersToSet = nil;
234
235
  }
235
-
236
+
236
237
  // Deprecated consent flow which automatically moves to the new flow
237
238
  if ( self.consentFlowEnabledToSet )
238
239
  {
239
240
  settings.consentFlowSettings.enabled = self.consentFlowEnabledToSet.boolValue;
240
241
  self.consentFlowEnabledToSet = nil;
241
-
242
+
242
243
  if ( self.privacyPolicyURLToSet )
243
244
  {
244
245
  settings.consentFlowSettings.privacyPolicyURL = self.privacyPolicyURLToSet;
245
246
  self.privacyPolicyURLToSet = nil;
246
247
  }
247
-
248
+
248
249
  if (self.termsOfServiceURLToSet )
249
250
  {
250
251
  settings.consentFlowSettings.termsOfServiceURL = self.termsOfServiceURLToSet;
251
252
  self.termsOfServiceURLToSet = nil;
252
253
  }
253
254
  }
254
-
255
+
255
256
  // New terms and privacy policy flow
256
257
  if ( self.termsAndPrivacyPolicyFlowEnabledToSet )
257
258
  {
258
259
  settings.termsAndPrivacyPolicyFlowSettings.enabled = self.termsAndPrivacyPolicyFlowEnabledToSet.boolValue;
259
260
  self.termsAndPrivacyPolicyFlowEnabledToSet = nil;
260
-
261
+
261
262
  if ( self.privacyPolicyURLToSet )
262
263
  {
263
264
  settings.termsAndPrivacyPolicyFlowSettings.privacyPolicyURL = self.privacyPolicyURLToSet;
264
265
  self.privacyPolicyURLToSet = nil;
265
266
  }
266
-
267
+
267
268
  if ( self.termsOfServiceURLToSet )
268
269
  {
269
270
  settings.termsAndPrivacyPolicyFlowSettings.termsOfServiceURL = self.termsOfServiceURLToSet;
270
271
  self.termsOfServiceURLToSet = nil;
271
272
  }
272
-
273
+
273
274
  if ( self.debugUserGeographyToSet )
274
275
  {
275
276
  settings.termsAndPrivacyPolicyFlowSettings.debugUserGeography = [self toAppLovinConsentFlowUserGeography: self.debugUserGeographyToSet];
276
277
  self.debugUserGeographyToSet = nil;
277
278
  }
278
279
  }
279
-
280
+
281
+ // Set muted if needed
282
+ if ( self.mutedToSet )
283
+ {
284
+ settings.muted = self.mutedToSet;
285
+ self.mutedToSet = nil;
286
+ }
287
+
280
288
  // Set test device ids if needed
281
289
  if ( self.testDeviceIdentifiersToSet )
282
290
  {
@@ -306,7 +314,7 @@ RCT_EXPORT_METHOD(initialize:(NSString *)pluginVersion :(NSString *)sdkKey :(RCT
306
314
  }
307
315
 
308
316
  [self setPendingExtraParametersIfNeeded: settings];
309
-
317
+
310
318
  // Initialize SDK
311
319
  self.sdk = [ALSdk sharedWithKey: sdkKey settings: settings];
312
320
  [self.sdk setPluginVersion: [@"React-Native-" stringByAppendingString: pluginVersion]];
@@ -438,9 +446,15 @@ RCT_EXPORT_METHOD(setUserId:(NSString *)userId)
438
446
 
439
447
  RCT_EXPORT_METHOD(setMuted:(BOOL)muted)
440
448
  {
441
- if ( ![self isPluginInitialized] ) return;
442
-
443
- self.sdk.settings.muted = muted;
449
+ if ( [self isPluginInitialized] )
450
+ {
451
+ self.sdk.settings.muted = muted;
452
+ self.mutedToSet = nil;
453
+ }
454
+ else
455
+ {
456
+ self.mutedToSet = @(muted);
457
+ }
444
458
  }
445
459
 
446
460
  RCT_EXPORT_METHOD(isMuted:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
@@ -834,10 +848,11 @@ RCT_EXPORT_METHOD(setBannerExtraParameter:(NSString *)adUnitIdentifier :(NSStrin
834
848
  [self setAdViewExtraParameterForAdUnitIdentifier: adUnitIdentifier adFormat: DEVICE_SPECIFIC_ADVIEW_AD_FORMAT key: key value: value];
835
849
  }
836
850
 
851
+ // NOTE: Even though iOS is ok with `id` generic types, Android is not - so we wrap it via JSON/ReadableMap
837
852
  RCT_EXPORT_METHOD(setBannerLocalExtraParameter:(NSString *)adUnitIdentifier :(NSDictionary<NSString *, id> *)parameterDict)
838
- {
853
+ {
839
854
  NSString *key = parameterDict.allKeys.firstObject;
840
- id value = parameterDict.allValues.firstObject;
855
+ id value = parameterDict.allValues.firstObject != [NSNull null] ? parameterDict.allValues.firstObject : nil;
841
856
 
842
857
  [self setAdViewLocalExtraParameterForAdUnitIdentifier: adUnitIdentifier adFormat: DEVICE_SPECIFIC_ADVIEW_AD_FORMAT key: key value: value];
843
858
  }
@@ -949,14 +964,15 @@ RCT_EXPORT_METHOD(updateMRecPosition:(NSString *)mrecPosition :(NSString *)adUni
949
964
  }
950
965
 
951
966
  RCT_EXPORT_METHOD(setMRecExtraParameter:(NSString *)adUnitIdentifier :(NSString *)key :(nullable NSString *)value)
952
- {
967
+ {
953
968
  [self setAdViewExtraParameterForAdUnitIdentifier: adUnitIdentifier adFormat: MAAdFormat.mrec key: key value: value];
954
969
  }
955
970
 
971
+ // NOTE: Even though iOS is ok with `id` generic types, Android is not - so we wrap it via JSON/ReadableMap
956
972
  RCT_EXPORT_METHOD(setMRecLocalExtraParameter:(NSString *)adUnitIdentifier :(NSDictionary<NSString *, id> *)parameterDict)
957
973
  {
958
974
  NSString *key = parameterDict.allKeys.firstObject;
959
- id value = parameterDict.allValues.firstObject;
975
+ id value = parameterDict.allValues.firstObject != [NSNull null] ? parameterDict.allValues.firstObject : nil;
960
976
 
961
977
  [self setAdViewLocalExtraParameterForAdUnitIdentifier: adUnitIdentifier adFormat: MAAdFormat.mrec key: key value: value];
962
978
  }
@@ -1067,10 +1083,11 @@ RCT_EXPORT_METHOD(setInterstitialExtraParameter:(NSString *)adUnitIdentifier :(N
1067
1083
  [interstitial setExtraParameterForKey: key value: value];
1068
1084
  }
1069
1085
 
1086
+ // NOTE: Even though iOS is ok with `id` generic types, Android is not - so we wrap it via JSON/ReadableMap
1070
1087
  RCT_EXPORT_METHOD(setInterstitialLocalExtraParameter:(NSString *)adUnitIdentifier :(NSDictionary<NSString *, id> *)parameterDict)
1071
1088
  {
1072
1089
  NSString *key = parameterDict.allKeys.firstObject;
1073
- id value = parameterDict.allValues.firstObject;
1090
+ id value = parameterDict.allValues.firstObject != [NSNull null] ? parameterDict.allValues.firstObject : nil;
1074
1091
 
1075
1092
  MAInterstitialAd *interstitial = [self retrieveInterstitialForAdUnitIdentifier: adUnitIdentifier];
1076
1093
  [interstitial setLocalExtraParameterForKey: key value: value];
@@ -1127,10 +1144,11 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
1127
1144
  [rewardedAd setExtraParameterForKey: key value: value];
1128
1145
  }
1129
1146
 
1147
+ // NOTE: Even though iOS is ok with `id` generic types, Android is not - so we wrap it via JSON/ReadableMap
1130
1148
  RCT_EXPORT_METHOD(setRewardedAdLocalExtraParameter:(NSString *)adUnitIdentifier :(NSDictionary<NSString *, id> *)parameterDict)
1131
1149
  {
1132
1150
  NSString *key = parameterDict.allKeys.firstObject;
1133
- id value = parameterDict.allValues.firstObject;
1151
+ id value = parameterDict.allValues.firstObject != [NSNull null] ? parameterDict.allValues.firstObject : nil;
1134
1152
 
1135
1153
  MARewardedAd *rewardedAd = [self retrieveRewardedAdForAdUnitIdentifier: adUnitIdentifier];
1136
1154
  [rewardedAd setLocalExtraParameterForKey: key value: value];
@@ -1187,10 +1205,11 @@ RCT_EXPORT_METHOD(setAppOpenAdExtraParameter:(NSString *)adUnitIdentifier key:(N
1187
1205
  [appOpenAd setExtraParameterForKey: key value: value];
1188
1206
  }
1189
1207
 
1208
+ // NOTE: Even though iOS is ok with `id` generic types, Android is not - so we wrap it via JSON/ReadableMap
1190
1209
  RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :(NSDictionary<NSString *, id> *)parameterDict)
1191
1210
  {
1192
1211
  NSString *key = parameterDict.allKeys.firstObject;
1193
- id value = parameterDict.allValues.firstObject;
1212
+ id value = parameterDict.allValues.firstObject != [NSNull null] ? parameterDict.allValues.firstObject : nil;
1194
1213
 
1195
1214
  MAAppOpenAd *appOpenAd = [self retrieveAppOpenAdForAdUnitIdentifier: adUnitIdentifier];
1196
1215
  [appOpenAd setLocalExtraParameterForKey: key value: value];
@@ -2060,7 +2079,7 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
2060
2079
  {
2061
2080
  return ALConsentFlowUserGeographyOther;
2062
2081
  }
2063
-
2082
+
2064
2083
  return ALConsentFlowUserGeographyUnknown;
2065
2084
  }
2066
2085
 
@@ -2074,7 +2093,7 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
2074
2093
  {
2075
2094
  return USER_GEOGRAPHY_OTHER;
2076
2095
  }
2077
-
2096
+
2078
2097
  return USER_GEOGRAPHY_UNKNOWN;
2079
2098
  }
2080
2099
 
@@ -2096,7 +2115,7 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
2096
2115
  {
2097
2116
  return APP_TRACKING_STATUS_AUTHORIZED;
2098
2117
  }
2099
-
2118
+
2100
2119
  return APP_TRACKING_STATUS_UNAVAILABLE;
2101
2120
  }
2102
2121
 
@@ -2209,6 +2228,59 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
2209
2228
  return networkResponseDict;
2210
2229
  }
2211
2230
 
2231
+ #pragma mark - Amazon
2232
+
2233
+ - (void)setAmazonResult:(id)result forBannerAdUnitIdentifier:(NSString *)adUnitIdentifier
2234
+ {
2235
+ [self setAmazonResult: result forAdUnitIdentifier: adUnitIdentifier adFormat: MAAdFormat.banner];
2236
+ }
2237
+
2238
+ - (void)setAmazonResult:(id)result forMRecAdUnitIdentifier:(NSString *)adUnitIdentifier
2239
+ {
2240
+ [self setAmazonResult: result forAdUnitIdentifier: adUnitIdentifier adFormat: MAAdFormat.mrec];
2241
+ }
2242
+
2243
+ - (void)setAmazonResult:(id)result forInterstitialAdUnitIdentifier:(NSString *)adUnitIdentifier
2244
+ {
2245
+ [self setAmazonResult: result forAdUnitIdentifier: adUnitIdentifier adFormat: MAAdFormat.interstitial];
2246
+ }
2247
+
2248
+ - (void)setAmazonResult:(id /* DTBAdResponse or DTBAdErrorInfo */)result forAdUnitIdentifier:(NSString *)adUnitIdentifier adFormat:(MAAdFormat *)adFormat
2249
+ {
2250
+ if ( !self.sdk )
2251
+ {
2252
+ NSString *errorMessage = [NSString stringWithFormat: @"Failed to set Amazon result - SDK not initialized: %@", adUnitIdentifier];
2253
+ [self logUninitializedAccessError: errorMessage];
2254
+
2255
+ return;
2256
+ }
2257
+
2258
+ if ( !result )
2259
+ {
2260
+ [self log: @"Failed to set Amazon result - nil value"];
2261
+ return;
2262
+ }
2263
+
2264
+ NSString *key = [self localExtraParameterKeyForAmazonResult: result];
2265
+
2266
+ if ( adFormat == MAAdFormat.interstitial )
2267
+ {
2268
+ MAInterstitialAd *interstitial = [self retrieveInterstitialForAdUnitIdentifier: adUnitIdentifier];
2269
+ [interstitial setLocalExtraParameterForKey: key value: result];
2270
+ }
2271
+ else
2272
+ {
2273
+ MAAdView *adView = [self retrieveAdViewForAdUnitIdentifier: adUnitIdentifier adFormat: adFormat];
2274
+ [adView setLocalExtraParameterForKey: key value: result];
2275
+ }
2276
+ }
2277
+
2278
+ - (NSString *)localExtraParameterKeyForAmazonResult:(id /* DTBAdResponse or DTBAdErrorInfo */)result
2279
+ {
2280
+ NSString *className = NSStringFromClass([result class]);
2281
+ return [@"DTBAdResponse" isEqualToString: className] ? @"amazon_ad_response" : @"amazon_ad_error";
2282
+ }
2283
+
2212
2284
  #pragma mark - React Native Event Bridge
2213
2285
 
2214
2286
  - (void)sendReactNativeEventWithName:(NSString *)name body:(NSDictionary<NSString *, id> *)body
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Bucket
3
+ uuid = "8322C692-8067-489C-89A1-217F139F4039"
4
+ type = "0"
5
+ version = "2.0">
6
+ <Breakpoints>
7
+ <BreakpointProxy
8
+ BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
9
+ <BreakpointContent
10
+ uuid = "1DACA5BD-D4D2-4CD6-BEFD-D951963D77E1"
11
+ shouldBeEnabled = "No"
12
+ ignoreCount = "0"
13
+ continueAfterRunningActions = "No"
14
+ filePath = "AppLovinMAX.m"
15
+ startingColumnNumber = "9223372036854775807"
16
+ endingColumnNumber = "9223372036854775807"
17
+ startingLineNumber = "1304"
18
+ endingLineNumber = "1304"
19
+ landmarkName = "-positionAdViewForAdUnitIdentifier:adFormat:"
20
+ landmarkType = "7">
21
+ </BreakpointContent>
22
+ </BreakpointProxy>
23
+ </Breakpoints>
24
+ </Bucket>
@@ -176,7 +176,8 @@
176
176
 
177
177
  for ( NSString *key in self.localExtraParameters )
178
178
  {
179
- [self.adView setLocalExtraParameterForKey: key value: self.localExtraParameters[key]];
179
+ id value = self.localExtraParameters[key];
180
+ [self.adView setLocalExtraParameterForKey: key value: (value != [NSNull null] ? value : nil)];
180
181
  }
181
182
 
182
183
  if ( [self isAutoRefresh] )
@@ -31,6 +31,7 @@
31
31
  @property (nonatomic, strong, nullable) MANativeAdLoader *adLoader;
32
32
  @property (nonatomic, strong, nullable) MAAd *nativeAd;
33
33
  @property (nonatomic, strong) ALAtomicBoolean *isLoading; // Guard against repeated ad loads
34
+ @property (nonatomic, strong) ALAtomicBoolean *isAdUnitIdSet;
34
35
 
35
36
  // JavaScript properties
36
37
  @property (nonatomic, copy) NSString *adUnitId;
@@ -59,6 +60,7 @@
59
60
  {
60
61
  self.bridge = bridge;
61
62
  self.isLoading = [[ALAtomicBoolean alloc] init];
63
+ self.isAdUnitIdSet = [[ALAtomicBoolean alloc] init];
62
64
  self.clickableViews = [NSMutableArray array];
63
65
  }
64
66
  return self;
@@ -95,10 +97,7 @@
95
97
 
96
98
  _adUnitId = adUnitId;
97
99
 
98
- // Explicitly invoke ad load now that Ad Unit ID is set, but do so after 0.25s to allow other props to set
99
- dispatchOnMainQueueAfter(0.25, ^{
100
- [self loadAd];
101
- });
100
+ [self.isAdUnitIdSet set: YES];
102
101
  }
103
102
 
104
103
  // Called when Ad Unit ID is set, and via RN layer
@@ -124,7 +123,8 @@
124
123
 
125
124
  for ( NSString *key in self.localExtraParameters )
126
125
  {
127
- [self.adLoader setLocalExtraParameterForKey: key value: self.localExtraParameters[key]];
126
+ id value = self.localExtraParameters[key];
127
+ [self.adLoader setLocalExtraParameterForKey: key value: (value != [NSNull null] ? value : nil)];
128
128
  }
129
129
 
130
130
  [self.adLoader loadAd];
@@ -267,6 +267,26 @@
267
267
  [self.nativeAd.nativeAd.mediaView al_pinToSuperview];
268
268
  }
269
269
 
270
+ /**
271
+ * Invoked:
272
+ * 1. after all the JavaScript properties are set when mounting NativeAdView
273
+ * 2. after all the user's asset views are mounted, following the 1st event
274
+ */
275
+ - (void)didSetProps:(NSArray<NSString *> *)changedProps
276
+ {
277
+ if ( [self.isAdUnitIdSet compareAndSet:YES update: NO] )
278
+ {
279
+ [self loadAd];
280
+ }
281
+ else
282
+ {
283
+ if ( !self.adLoader ) return;
284
+
285
+ [self.adLoader registerClickableViews: self.clickableViews withContainer: self forAd: self.nativeAd];
286
+ [self.adLoader handleNativeAdViewRenderedForAd: self.nativeAd];
287
+ }
288
+ }
289
+
270
290
  #pragma mark - Ad Loader Delegate
271
291
 
272
292
  - (void)didLoadNativeAd:(nullable MANativeAdView *)nativeAdView forAd:(MAAd *)ad
@@ -291,14 +311,7 @@
291
311
  // Notify `AppLovinNativeAdView.js`
292
312
  [self sendAdLoadedReactNativeEventForAd: ad.nativeAd];
293
313
 
294
- // After notifying the RN layer - have slight delay to let views bind to this layer in `clickableViews` before registering
295
- dispatchOnMainQueueAfter(0.5, ^{
296
-
297
- [self.adLoader registerClickableViews: self.clickableViews withContainer: self forAd: ad];
298
- [self.adLoader handleNativeAdViewRenderedForAd: ad];
299
-
300
- [self.isLoading set: NO];
301
- });
314
+ [self.isLoading set: NO];
302
315
  }
303
316
 
304
317
  - (void)sendAdLoadedReactNativeEventForAd:(MANativeAd *)ad
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.0.0'
38
+ pod 'AppLovinSDK', '12.1.0'
39
39
 
40
40
  end
package/ios/Podfile.lock CHANGED
@@ -1,5 +1,5 @@
1
1
  PODS:
2
- - AppLovinSDK (12.0.0)
2
+ - AppLovinSDK (12.1.0)
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.0.0)
252
+ - AppLovinSDK (= 12.1.0)
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: 15679e9f576a4d8662e1dc537c9a4ed47d3292a5
342
+ AppLovinSDK: 179d509c258e01a3a77eb8416f0ba843a12ed322
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: dc95f857ab3004d6fc04e845d974091e28859c7b
371
+ PODFILE CHECKSUM: d7248805481768209533def6ca165110984d9914
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.1.0",
4
+ "version": "6.2.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_1_0" }
14
+ s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_6_2_0" }
15
15
 
16
16
  s.source_files = "ios/AppLovinMAX*.{h,m}"
17
17
 
18
18
  s.dependency "React"
19
- s.dependency "AppLovinSDK", "12.0.0"
19
+ s.dependency "AppLovinSDK", "12.1.0"
20
20
  end
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/src.iml" filepath="$PROJECT_DIR$/.idea/src.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="inheritedJdk" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ </component>
8
+ </module>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
5
+ </component>
6
+ </project>
@@ -4,7 +4,7 @@ import type { Configuration } from './types/Configuration';
4
4
 
5
5
  const NativeAppLovinMAX = NativeModules.AppLovinMAX;
6
6
 
7
- const VERSION = '6.1.0';
7
+ const VERSION = '6.2.0';
8
8
 
9
9
  const initialize = async (sdkKey: string): Promise<Configuration> => {
10
10
  return NativeAppLovinMAX.initialize(VERSION, sdkKey);