react-native-applovin-max 5.2.2 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,8 +35,8 @@ android {
35
35
  defaultConfig {
36
36
  minSdkVersion 16
37
37
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
38
- versionCode 5020200
39
- versionName "5.2.2"
38
+ versionCode 5030000
39
+ versionName "5.3.0"
40
40
  }
41
41
 
42
42
  flavorDimensions("default")
@@ -434,37 +434,37 @@ public class AppLovinMAXModule
434
434
  @ReactMethod
435
435
  public void setHasUserConsent(final boolean hasUserConsent)
436
436
  {
437
- AppLovinPrivacySettings.setHasUserConsent( hasUserConsent, maybeGetCurrentActivity() );
437
+ AppLovinPrivacySettings.setHasUserConsent( hasUserConsent, getReactApplicationContext() );
438
438
  }
439
439
 
440
440
  @ReactMethod
441
441
  public void hasUserConsent(final Promise promise)
442
442
  {
443
- promise.resolve( AppLovinPrivacySettings.hasUserConsent( maybeGetCurrentActivity() ) );
443
+ promise.resolve( AppLovinPrivacySettings.hasUserConsent( getReactApplicationContext() ) );
444
444
  }
445
445
 
446
446
  @ReactMethod
447
447
  public void setIsAgeRestrictedUser(final boolean isAgeRestrictedUser)
448
448
  {
449
- AppLovinPrivacySettings.setIsAgeRestrictedUser( isAgeRestrictedUser, maybeGetCurrentActivity() );
449
+ AppLovinPrivacySettings.setIsAgeRestrictedUser( isAgeRestrictedUser, getReactApplicationContext() );
450
450
  }
451
451
 
452
452
  @ReactMethod
453
453
  public void isAgeRestrictedUser(final Promise promise)
454
454
  {
455
- promise.resolve( AppLovinPrivacySettings.isAgeRestrictedUser( maybeGetCurrentActivity() ) );
455
+ promise.resolve( AppLovinPrivacySettings.isAgeRestrictedUser( getReactApplicationContext() ) );
456
456
  }
457
457
 
458
458
  @ReactMethod
459
459
  public void setDoNotSell(final boolean doNotSell)
460
460
  {
461
- AppLovinPrivacySettings.setDoNotSell( doNotSell, maybeGetCurrentActivity() );
461
+ AppLovinPrivacySettings.setDoNotSell( doNotSell, getReactApplicationContext() );
462
462
  }
463
463
 
464
464
  @ReactMethod
465
465
  public void isDoNotSell(final Promise promise)
466
466
  {
467
- promise.resolve( AppLovinPrivacySettings.isDoNotSell( maybeGetCurrentActivity() ) );
467
+ promise.resolve( AppLovinPrivacySettings.isDoNotSell( getReactApplicationContext() ) );
468
468
  }
469
469
 
470
470
  @ReactMethod
@@ -1697,11 +1697,7 @@ public class AppLovinMAXModule
1697
1697
 
1698
1698
  if ( adView.getParent() == null )
1699
1699
  {
1700
- final Activity currentActivity = maybeGetCurrentActivity();
1701
- final RelativeLayout relativeLayout = new RelativeLayout( currentActivity );
1702
- currentActivity.addContentView( relativeLayout, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT,
1703
- LinearLayout.LayoutParams.MATCH_PARENT ) );
1704
- relativeLayout.addView( adView );
1700
+ maybeAttachToCurrentActivity( adView );
1705
1701
 
1706
1702
  // Position ad view immediately so if publisher sets color before ad loads, it will not be the size of the screen
1707
1703
  mAdViewAdFormats.put( adUnitId, adFormat );
@@ -1826,6 +1822,8 @@ public class AppLovinMAXModule
1826
1822
  return;
1827
1823
  }
1828
1824
 
1825
+ maybeAttachToCurrentActivity( adView );
1826
+
1829
1827
  adView.setVisibility( View.VISIBLE );
1830
1828
  adView.startAutoRefresh();
1831
1829
  }
@@ -2030,6 +2028,22 @@ public class AppLovinMAXModule
2030
2028
  } );
2031
2029
  }
2032
2030
 
2031
+ private void maybeAttachToCurrentActivity(final MaxAdView adView)
2032
+ {
2033
+ if ( adView.getParent() == null )
2034
+ {
2035
+ final Activity currentActivity = maybeGetCurrentActivity();
2036
+ if ( currentActivity != null )
2037
+ {
2038
+ final RelativeLayout relativeLayout = new RelativeLayout( getReactApplicationContext() );
2039
+ relativeLayout.addView( adView );
2040
+
2041
+ currentActivity.addContentView( relativeLayout, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT,
2042
+ LinearLayout.LayoutParams.MATCH_PARENT ) );
2043
+ }
2044
+ }
2045
+ }
2046
+
2033
2047
  @Nullable
2034
2048
  private MaxInterstitialAd retrieveInterstitial(final String adUnitId, final String callingMethod)
2035
2049
  {
@@ -357,6 +357,13 @@ public class AppLovinMAXNativeAdView
357
357
  adLoader.b( ad );
358
358
  }
359
359
 
360
+ // Reassure the size of `mediaView` and its children for the networks, such as
361
+ // LINE, where the actual ad contents are loaded after `mediaView` is sized.
362
+ if ( mediaView != null )
363
+ {
364
+ sizeToFit( mediaView, (ReactViewGroup) mediaView.getParent() );
365
+ }
366
+
360
367
  isLoading.set( false );
361
368
  }, 500L );
362
369
  }
@@ -396,22 +403,11 @@ public class AppLovinMAXNativeAdView
396
403
  nativeAdInfo.putDouble( "starRating", ad.getStarRating().doubleValue() );
397
404
  }
398
405
 
406
+ // The aspect ratio can be 0.0f when it is not provided by the network.
399
407
  float aspectRatio = ad.getMediaContentAspectRatio();
400
- if ( !Float.isNaN( aspectRatio ) )
401
- {
402
- // The aspect ratio can be 0.0f when it is not provided by the network.
403
- if ( Math.signum( aspectRatio ) == 0 )
404
- {
405
- nativeAdInfo.putDouble( "mediaContentAspectRatio", 1.0 );
406
- }
407
- else
408
- {
409
- nativeAdInfo.putDouble( "mediaContentAspectRatio", aspectRatio );
410
- }
411
- }
412
- else
408
+ if ( aspectRatio > 0 )
413
409
  {
414
- nativeAdInfo.putDouble( "mediaContentAspectRatio", 1.0 );
410
+ nativeAdInfo.putDouble( "mediaContentAspectRatio", aspectRatio );
415
411
  }
416
412
 
417
413
  nativeAdInfo.putBoolean( "isIconImageAvailable", ( ad.getIcon() != null ) );
@@ -305,21 +305,10 @@
305
305
  nativeAdInfo[@"callToAction"] = ad.callToAction;
306
306
  nativeAdInfo[@"starRating"] = ad.starRating;
307
307
 
308
- if ( !isnan(ad.mediaContentAspectRatio) )
308
+ // The aspect ratio can be 0.0f when it is not provided by the network.
309
+ if ( ad.mediaContentAspectRatio > 0 )
309
310
  {
310
- // The aspect ratio can be 0.0f when it is not provided by the network.
311
- if ( fabs(ad.mediaContentAspectRatio) < FLT_EPSILON )
312
- {
313
- nativeAdInfo[@"mediaContentAspectRatio"] = @(1.0);
314
- }
315
- else
316
- {
317
- nativeAdInfo[@"mediaContentAspectRatio"] = @(ad.mediaContentAspectRatio);
318
- }
319
- }
320
- else
321
- {
322
- nativeAdInfo[@"mediaContentAspectRatio"] = @(1.0);
311
+ nativeAdInfo[@"mediaContentAspectRatio"] = @(ad.mediaContentAspectRatio);
323
312
  }
324
313
 
325
314
  nativeAdInfo[@"isIconImageAvailable"] = @(ad.icon != nil);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-applovin-max",
3
3
  "author": "AppLovin Corporation",
4
- "version": "5.2.2",
4
+ "version": "5.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,7 +11,7 @@ Pod::Spec.new do |s|
11
11
  s.authors = package["author"]
12
12
 
13
13
  s.platforms = { :ios => "10.0" }
14
- s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_5_2_2" }
14
+ s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_5_3_0" }
15
15
 
16
16
  s.source_files = "ios/AppLovinMAX*.{h,m}"
17
17
 
@@ -94,12 +94,12 @@ export const IconView = (props) => {
94
94
  const {nativeAd, nativeAdView} = useContext(NativeAdViewContext);
95
95
 
96
96
  useEffect(() => {
97
- if (!nativeAdView || !nativeAd.image) return;
97
+ if (!nativeAdView || !nativeAd.image || !imageRef.current) return;
98
98
 
99
99
  nativeAdView.setNativeProps({
100
100
  iconView: findNodeHandle(imageRef.current),
101
101
  });
102
- }, [nativeAd, nativeAdView]);
102
+ }, [nativeAd, nativeAdView, imageRef.current]);
103
103
 
104
104
  if (!nativeAdView) return null;
105
105
 
package/src/index.js CHANGED
@@ -6,7 +6,7 @@ import EventListeners from "./AppLovinMAXEventListeners";
6
6
 
7
7
  const { AppLovinMAX } = NativeModules;
8
8
 
9
- const VERSION = "5.2.2";
9
+ const VERSION = "5.3.0";
10
10
 
11
11
  /*---------*/
12
12
  /* BANNERS */