react-native-applovin-max 5.7.2 → 6.0.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.
Files changed (50) hide show
  1. package/README.md +1 -1
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/com/applovin/mediation/adapters/GoogleAdManagerMediationAdapter.java.saved +1616 -0
  4. package/android/src/main/java/com/applovin/mediation/adapters/{GoogleMediationAdapter.java.saved → GoogleMediationAdapter.java.old} +126 -49
  5. package/android/src/main/java/com/applovin/mediation/adapters/MintegralMediationAdapter.java.old +1481 -0
  6. package/ios/AppLovinMAX.m +1 -9
  7. package/ios/AppLovinMAX.xcodeproj/project.pbxproj +4 -4
  8. package/ios/AppLovinMAX.xcworkspace/xcuserdata/hiroshi.watanabe.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  9. package/ios/AppLovinMAXNativeAdView.m +8 -1
  10. package/ios/Podfile +1 -1
  11. package/package.json +2 -1
  12. package/react-native-applovin-max.podspec +1 -1
  13. package/src/AdView.tsx +251 -0
  14. package/src/AppLovinMAX.ts +24 -0
  15. package/src/AppOpenAd.ts +128 -0
  16. package/src/BannerAd.ts +175 -0
  17. package/src/EventEmitter.ts +27 -0
  18. package/src/InterstitialAd.ts +128 -0
  19. package/src/MRecAd.ts +147 -0
  20. package/src/Privacy.ts +6 -0
  21. package/src/RewardedAd.ts +144 -0
  22. package/src/TargetingData.ts +168 -0
  23. package/src/index.ts +21 -0
  24. package/src/nativeAd/NativeAdView.tsx +161 -0
  25. package/src/nativeAd/NativeAdViewComponents.tsx +185 -0
  26. package/src/nativeAd/NativeAdViewProvider.tsx +35 -0
  27. package/src/types/AdEvent.ts +26 -0
  28. package/src/types/AdInfo.ts +348 -0
  29. package/src/types/AdProps.ts +60 -0
  30. package/src/types/AdViewProps.ts +36 -0
  31. package/src/types/AppLovinMAX.ts +86 -0
  32. package/src/types/AppOpenAd.ts +3 -0
  33. package/src/types/BannerAd.ts +47 -0
  34. package/src/types/Configuration.ts +11 -0
  35. package/src/types/FullscreenAd.ts +135 -0
  36. package/src/types/InterstitialAd.ts +3 -0
  37. package/src/types/MRecAd.ts +13 -0
  38. package/src/types/NativeAd.ts +50 -0
  39. package/src/types/NativeAdViewProps.ts +17 -0
  40. package/src/types/Privacy.ts +73 -0
  41. package/src/types/RewardedAd.ts +18 -0
  42. package/src/types/ViewAd.ts +158 -0
  43. package/src/types/index.ts +4 -0
  44. package/src/AppLovinMAXAdView.js +0 -231
  45. package/src/AppLovinMAXEventListeners.js +0 -419
  46. package/src/NativeAdComponents.js +0 -208
  47. package/src/NativeAdView.js +0 -164
  48. package/src/NativeAdViewProvider.js +0 -19
  49. package/src/TargetingData.js +0 -104
  50. package/src/index.js +0 -291
@@ -3,7 +3,9 @@ package com.applovin.mediation.adapters;
3
3
  import android.annotation.SuppressLint;
4
4
  import android.app.Activity;
5
5
  import android.content.Context;
6
+ import android.graphics.Rect;
6
7
  import android.graphics.drawable.Drawable;
8
+ import android.os.Build;
7
9
  import android.os.Bundle;
8
10
  import android.preference.PreferenceManager;
9
11
  import android.text.TextUtils;
@@ -12,7 +14,10 @@ import android.view.Display;
12
14
  import android.view.View;
13
15
  import android.view.ViewGroup;
14
16
  import android.view.WindowManager;
17
+ import android.view.WindowMetrics;
18
+ import android.widget.FrameLayout;
15
19
  import android.widget.ImageView;
20
+ import android.widget.RelativeLayout;
16
21
 
17
22
  import com.applovin.impl.sdk.utils.BundleUtils;
18
23
  import com.applovin.mediation.MaxAdFormat;
@@ -34,7 +39,6 @@ import com.applovin.mediation.adapter.parameters.MaxAdapterInitializationParamet
34
39
  import com.applovin.mediation.adapter.parameters.MaxAdapterParameters;
35
40
  import com.applovin.mediation.adapter.parameters.MaxAdapterResponseParameters;
36
41
  import com.applovin.mediation.adapter.parameters.MaxAdapterSignalCollectionParameters;
37
- //import com.applovin.mediation.adapters.google.BuildConfig;
38
42
  import com.applovin.mediation.nativeAds.MaxNativeAd;
39
43
  import com.applovin.mediation.nativeAds.MaxNativeAdView;
40
44
  import com.applovin.sdk.AppLovinSdk;
@@ -73,7 +77,6 @@ import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAd;
73
77
  import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAdLoadCallback;
74
78
 
75
79
  import java.lang.ref.WeakReference;
76
- import java.util.Arrays;
77
80
  import java.util.Collections;
78
81
  import java.util.List;
79
82
  import java.util.Map;
@@ -180,7 +183,7 @@ public class GoogleMediationAdapter
180
183
  @Override
181
184
  public String getAdapterVersion()
182
185
  {
183
- return "22.1.0.2"; //BuildConfig.VERSION_NAME;
186
+ return "22.4.0.0"; //BuildConfig.VERSION_NAME;
184
187
  }
185
188
 
186
189
  @Override
@@ -653,16 +656,7 @@ public class GoogleMediationAdapter
653
656
  adView.setAdListener( new AdViewListener( placementId, adFormat, listener ) );
654
657
 
655
658
  // Check if adaptive banner sizes should be used
656
- boolean isAdaptiveBanner;
657
- if ( isBiddingAd )
658
- {
659
- // Temporarily manually disable adaptive banner traffic for Google bidding until they resolve sizing issue
660
- isAdaptiveBanner = false;
661
- }
662
- else
663
- {
664
- isAdaptiveBanner = parameters.getServerParameters().getBoolean( "adaptive_banner", false );
665
- }
659
+ boolean isAdaptiveBanner = parameters.getServerParameters().getBoolean( "adaptive_banner", false );
666
660
 
667
661
  adView.setAdSize( toAdSize( adFormat, isAdaptiveBanner, parameters, context ) );
668
662
 
@@ -783,12 +777,26 @@ public class GoogleMediationAdapter
783
777
  }
784
778
  }
785
779
 
786
- WindowManager windowManager = (WindowManager) context.getSystemService( Context.WINDOW_SERVICE );
787
- Display display = windowManager.getDefaultDisplay();
788
- DisplayMetrics outMetrics = new DisplayMetrics();
789
- display.getMetrics( outMetrics );
780
+ int deviceWidthPx = getApplicationWindowWidth( context );
781
+ return AppLovinSdkUtils.pxToDp( context, deviceWidthPx );
782
+ }
790
783
 
791
- return AppLovinSdkUtils.pxToDp( context, outMetrics.widthPixels );
784
+ public static int getApplicationWindowWidth(final Context context)
785
+ {
786
+ WindowManager windowManager = (WindowManager) context.getSystemService( Context.WINDOW_SERVICE );
787
+ if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.R )
788
+ {
789
+ WindowMetrics windowMetrics = windowManager.getCurrentWindowMetrics();
790
+ Rect applicationBounds = windowMetrics.getBounds();
791
+ return applicationBounds.width();
792
+ }
793
+ else
794
+ {
795
+ Display display = windowManager.getDefaultDisplay();
796
+ DisplayMetrics outMetrics = new DisplayMetrics();
797
+ display.getMetrics( outMetrics );
798
+ return outMetrics.widthPixels;
799
+ }
792
800
  }
793
801
 
794
802
  private AdFormat toAdFormat(final MaxAdapterSignalCollectionParameters parameters)
@@ -815,6 +823,11 @@ public class GoogleMediationAdapter
815
823
  {
816
824
  return AdFormat.REWARDED_INTERSTITIAL;
817
825
  }
826
+ // NOTE: App open ads were added in AppLovin v11.5.0 and must be checked after all the other ad formats to avoid throwing an exception
827
+ else if ( adFormat == MaxAdFormat.APP_OPEN )
828
+ {
829
+ return AdFormat.APP_OPEN_AD;
830
+ }
818
831
  else
819
832
  {
820
833
  return AdFormat.UNKNOWN;
@@ -854,17 +867,16 @@ public class GoogleMediationAdapter
854
867
  // Requested by Google for signal collection
855
868
  networkExtras.putString( "query_info_type", isDv360Bidding ? "requester_type_3" : "requester_type_2" );
856
869
 
857
- // Temporarily manually disable adaptive banner traffic for Google bidding until they resolve sizing issue
858
- // if ( AppLovinSdk.VERSION_CODE >= 11_00_00_00 && adFormat.isAdViewAd() )
859
- // {
860
- // Object isAdaptiveBannerObj = parameters.getLocalExtraParameters().get( "adaptive_banner" );
861
- // if ( isAdaptiveBannerObj instanceof String && "true".equalsIgnoreCase( (String) isAdaptiveBannerObj ) )
862
- // {
863
- // AdSize adaptiveAdSize = toAdSize( adFormat, true, parameters, context );
864
- // networkExtras.putInt( "adaptive_banner_w", adaptiveAdSize.getWidth() );
865
- // networkExtras.putInt( "adaptive_banner_h", adaptiveAdSize.getHeight() );
866
- // }
867
- // }
870
+ if ( AppLovinSdk.VERSION_CODE >= 11_00_00_00 && adFormat.isAdViewAd() )
871
+ {
872
+ Object isAdaptiveBannerObj = parameters.getLocalExtraParameters().get( "adaptive_banner" );
873
+ if ( isAdaptiveBannerObj instanceof String && "true".equalsIgnoreCase( (String) isAdaptiveBannerObj ) )
874
+ {
875
+ AdSize adaptiveAdSize = toAdSize( adFormat, true, parameters, context );
876
+ networkExtras.putInt( "adaptive_banner_w", adaptiveAdSize.getWidth() );
877
+ networkExtras.putInt( "adaptive_banner_h", adaptiveAdSize.getHeight() );
878
+ }
879
+ }
868
880
 
869
881
  if ( parameters instanceof MaxAdapterResponseParameters )
870
882
  {
@@ -906,6 +918,13 @@ public class GoogleMediationAdapter
906
918
  .putInt( "gad_rdp", 1 )
907
919
  .commit();
908
920
  }
921
+ else
922
+ {
923
+ PreferenceManager.getDefaultSharedPreferences( context )
924
+ .edit()
925
+ .remove( "gad_rdp" )
926
+ .commit();
927
+ }
909
928
 
910
929
  if ( AppLovinSdk.VERSION_CODE >= 11_00_00_00 )
911
930
  {
@@ -1674,38 +1693,96 @@ public class GoogleMediationAdapter
1674
1693
  }
1675
1694
  }
1676
1695
 
1696
+ //
1697
+ // Logic required for proper media view rendering in plugins (e.g. Flutter / React Native)
1698
+ //
1699
+
1677
1700
  View mediaView = getMediaView();
1678
- ViewGroup midContainer = ( mediaView != null ) ? (ViewGroup) mediaView.getParent() : null;
1701
+ if ( mediaView == null ) return true;
1679
1702
 
1680
- // mediaView must be already added to the container unless the user skipped it, but the
1681
- // parent may not be the container, although it should be within the hierarchy
1682
- if ( midContainer != null /*&& container.findViewById( midContainer.getId() ) != null */ )
1683
- {
1684
- // The Google Native Ad View needs to be inserted between mediaView and midContainer
1685
- // for mediaView to be visible
1686
- midContainer.removeView( mediaView );
1687
- nativeAdView.addView( mediaView );
1688
- midContainer.addView( nativeAdView );
1703
+ ViewGroup pluginContainer = (ViewGroup) mediaView.getParent();
1704
+ if ( pluginContainer == null ) return true;
1689
1705
 
1706
+ // Re-parent mediaView - mediaView must be a child of nativeAdView for Google native ads
1707
+
1708
+ // 1. Remove mediaView from the plugin
1709
+ pluginContainer.removeView( mediaView );
1710
+
1711
+ // NOTE: Will be false for React Native (will extend `ReactViewGroup`), but true for Flutter
1712
+ boolean hasPluginLayout = ( pluginContainer instanceof RelativeLayout || pluginContainer instanceof FrameLayout );
1713
+ if ( !hasPluginLayout )
1714
+ {
1690
1715
  if ( mediaView instanceof MediaView )
1691
1716
  {
1692
- nativeAdView.setMediaView( (MediaView) mediaView );
1693
- }
1694
- else if ( mediaView instanceof ImageView )
1695
- {
1696
- nativeAdView.setImageView( mediaView );
1717
+ MediaView googleMediaView = (MediaView) mediaView;
1718
+ MediaContent googleMediaContent = googleMediaView.getMediaContent();
1719
+ if ( googleMediaContent != null && googleMediaContent.hasVideoContent() )
1720
+ {
1721
+ mediaView = new AutoMeasuringMediaView( container.getContext() );
1722
+ googleMediaView.setMediaContent( nativeAd.getMediaContent() );
1723
+ }
1697
1724
  }
1725
+ }
1698
1726
 
1699
- nativeAdView.setNativeAd( nativeAd );
1727
+ // 2. Add mediaView to nativeAdView
1728
+ ViewGroup.LayoutParams mediaViewLayout = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT );
1729
+ nativeAdView.addView( mediaView, mediaViewLayout );
1700
1730
 
1701
- // stretch nativeAdView out to midContainer
1702
- nativeAdView.measure( View.MeasureSpec.makeMeasureSpec( midContainer.getWidth(), View.MeasureSpec.EXACTLY ),
1703
- View.MeasureSpec.makeMeasureSpec( midContainer.getHeight(), View.MeasureSpec.EXACTLY ) );
1704
- nativeAdView.layout( 0, 0, midContainer.getWidth(), midContainer.getHeight() );
1731
+ // Set mediaView or imageView based on the instance type
1732
+ if ( mediaView instanceof MediaView )
1733
+ {
1734
+ nativeAdView.setMediaView( (MediaView) mediaView );
1735
+ }
1736
+ else if ( mediaView instanceof ImageView )
1737
+ {
1738
+ nativeAdView.setImageView( (ImageView) mediaView );
1739
+ }
1740
+
1741
+ nativeAdView.setNativeAd( nativeAd );
1742
+
1743
+ // 3. Add nativeAdView to the plugin
1744
+ ViewGroup.LayoutParams nativeAdViewLayout = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT );
1745
+
1746
+ if ( hasPluginLayout )
1747
+ {
1748
+ pluginContainer.addView( nativeAdView, nativeAdViewLayout );
1749
+ }
1750
+ else
1751
+ {
1752
+ nativeAdView.measure(
1753
+ View.MeasureSpec.makeMeasureSpec( pluginContainer.getWidth(), View.MeasureSpec.EXACTLY ),
1754
+ View.MeasureSpec.makeMeasureSpec( pluginContainer.getHeight(), View.MeasureSpec.EXACTLY ) );
1755
+ nativeAdView.layout( 0, 0, pluginContainer.getWidth(), pluginContainer.getHeight() );
1756
+ pluginContainer.addView( nativeAdView );
1705
1757
  }
1706
1758
  }
1707
1759
 
1708
1760
  return true;
1709
1761
  }
1710
1762
  }
1763
+
1764
+ private static class AutoMeasuringMediaView
1765
+ extends MediaView
1766
+ {
1767
+ AutoMeasuringMediaView(final Context context) { super( context ); }
1768
+
1769
+ @Override
1770
+ protected void onAttachedToWindow()
1771
+ {
1772
+ super.onAttachedToWindow();
1773
+ requestLayout();
1774
+ }
1775
+
1776
+ @Override
1777
+ public void requestLayout()
1778
+ {
1779
+ super.requestLayout();
1780
+ post( () -> {
1781
+ measure(
1782
+ MeasureSpec.makeMeasureSpec( getWidth(), MeasureSpec.EXACTLY ),
1783
+ MeasureSpec.makeMeasureSpec( getHeight(), MeasureSpec.EXACTLY ) );
1784
+ layout( getLeft(), getTop(), getRight(), getBottom() );
1785
+ } );
1786
+ }
1787
+ }
1711
1788
  }