react-native-applovin-max 2.1.3 → 2.3.2
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/android/build.gradle +3 -8
- package/android/gradlew.bat +84 -84
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewManager.java +45 -19
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXModule.java +54 -15
- package/ios/AppLovinMAX.h +0 -5
- package/ios/AppLovinMAX.m +55 -26
- package/ios/AppLovinMAX.xcworkspace/xcuserdata/thomasso.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/AppLovinMAXAdViewManager.m +91 -43
- package/ios/Podfile +1 -1
- package/package.json +1 -1
- package/react-native-applovin-max.podspec +2 -2
- package/src/AppLovinMAXAdView.js +106 -8
- package/src/index.js +2 -1
- package/CHANGELOG.md +0 -58
- package/android/.gitignore +0 -23
- package/ios/.DS_Store +0 -0
- package/ios/.gitignore +0 -1
- package/ios/AppLovinMAX.xcworkspace/xcuserdata/thomasso.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -24
- package/ios/Podfile.lock +0 -373
- package/src/.DS_Store +0 -0
package/android/build.gradle
CHANGED
|
@@ -41,8 +41,8 @@ android {
|
|
|
41
41
|
defaultConfig {
|
|
42
42
|
minSdkVersion 16
|
|
43
43
|
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
44
|
-
versionCode
|
|
45
|
-
versionName "2.
|
|
44
|
+
versionCode 2030200
|
|
45
|
+
versionName "2.3.2"
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
flavorDimensions("default")
|
|
@@ -151,10 +151,5 @@ dependencies {
|
|
|
151
151
|
|
|
152
152
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
implementation "com.google.android.gms:play-services-ads-identifier:${versions.playServicesIdentifier}"
|
|
156
|
-
implementation project(':Android-SDK')
|
|
157
|
-
} else {
|
|
158
|
-
implementation 'com.applovin:applovin-sdk:+'
|
|
159
|
-
}
|
|
154
|
+
implementation 'com.applovin:applovin-sdk:+'
|
|
160
155
|
}
|
package/android/gradlew.bat
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
@if "%DEBUG%" == "" @echo off
|
|
2
|
-
@rem ##########################################################################
|
|
3
|
-
@rem
|
|
4
|
-
@rem Gradle startup script for Windows
|
|
5
|
-
@rem
|
|
6
|
-
@rem ##########################################################################
|
|
7
|
-
|
|
8
|
-
@rem Set local scope for the variables with windows NT shell
|
|
9
|
-
if "%OS%"=="Windows_NT" setlocal
|
|
10
|
-
|
|
11
|
-
set DIRNAME=%~dp0
|
|
12
|
-
if "%DIRNAME%" == "" set DIRNAME=.
|
|
13
|
-
set APP_BASE_NAME=%~n0
|
|
14
|
-
set APP_HOME=%DIRNAME%
|
|
15
|
-
|
|
16
|
-
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
17
|
-
set DEFAULT_JVM_OPTS=
|
|
18
|
-
|
|
19
|
-
@rem Find java.exe
|
|
20
|
-
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
21
|
-
|
|
22
|
-
set JAVA_EXE=java.exe
|
|
23
|
-
%JAVA_EXE% -version >NUL 2>&1
|
|
24
|
-
if "%ERRORLEVEL%" == "0" goto init
|
|
25
|
-
|
|
26
|
-
echo.
|
|
27
|
-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
28
|
-
echo.
|
|
29
|
-
echo Please set the JAVA_HOME variable in your environment to match the
|
|
30
|
-
echo location of your Java installation.
|
|
31
|
-
|
|
32
|
-
goto fail
|
|
33
|
-
|
|
34
|
-
:findJavaFromJavaHome
|
|
35
|
-
set JAVA_HOME=%JAVA_HOME:"=%
|
|
36
|
-
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
37
|
-
|
|
38
|
-
if exist "%JAVA_EXE%" goto init
|
|
39
|
-
|
|
40
|
-
echo.
|
|
41
|
-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
|
42
|
-
echo.
|
|
43
|
-
echo Please set the JAVA_HOME variable in your environment to match the
|
|
44
|
-
echo location of your Java installation.
|
|
45
|
-
|
|
46
|
-
goto fail
|
|
47
|
-
|
|
48
|
-
:init
|
|
49
|
-
@rem Get command-line arguments, handling Windows variants
|
|
50
|
-
|
|
51
|
-
if not "%OS%" == "Windows_NT" goto win9xME_args
|
|
52
|
-
|
|
53
|
-
:win9xME_args
|
|
54
|
-
@rem Slurp the command line arguments.
|
|
55
|
-
set CMD_LINE_ARGS=
|
|
56
|
-
set _SKIP=2
|
|
57
|
-
|
|
58
|
-
:win9xME_args_slurp
|
|
59
|
-
if "x%~1" == "x" goto execute
|
|
60
|
-
|
|
61
|
-
set CMD_LINE_ARGS=%*
|
|
62
|
-
|
|
63
|
-
:execute
|
|
64
|
-
@rem Setup the command line
|
|
65
|
-
|
|
66
|
-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
67
|
-
|
|
68
|
-
@rem Execute Gradle
|
|
69
|
-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
|
70
|
-
|
|
71
|
-
:end
|
|
72
|
-
@rem End local scope for the variables with windows NT shell
|
|
73
|
-
if "%ERRORLEVEL%"=="0" goto mainEnd
|
|
74
|
-
|
|
75
|
-
:fail
|
|
76
|
-
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
77
|
-
rem the _cmd.exe /c_ return code!
|
|
78
|
-
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
|
79
|
-
exit /b 1
|
|
80
|
-
|
|
81
|
-
:mainEnd
|
|
82
|
-
if "%OS%"=="Windows_NT" endlocal
|
|
83
|
-
|
|
84
|
-
:omega
|
|
1
|
+
@if "%DEBUG%" == "" @echo off
|
|
2
|
+
@rem ##########################################################################
|
|
3
|
+
@rem
|
|
4
|
+
@rem Gradle startup script for Windows
|
|
5
|
+
@rem
|
|
6
|
+
@rem ##########################################################################
|
|
7
|
+
|
|
8
|
+
@rem Set local scope for the variables with windows NT shell
|
|
9
|
+
if "%OS%"=="Windows_NT" setlocal
|
|
10
|
+
|
|
11
|
+
set DIRNAME=%~dp0
|
|
12
|
+
if "%DIRNAME%" == "" set DIRNAME=.
|
|
13
|
+
set APP_BASE_NAME=%~n0
|
|
14
|
+
set APP_HOME=%DIRNAME%
|
|
15
|
+
|
|
16
|
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
17
|
+
set DEFAULT_JVM_OPTS=
|
|
18
|
+
|
|
19
|
+
@rem Find java.exe
|
|
20
|
+
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
21
|
+
|
|
22
|
+
set JAVA_EXE=java.exe
|
|
23
|
+
%JAVA_EXE% -version >NUL 2>&1
|
|
24
|
+
if "%ERRORLEVEL%" == "0" goto init
|
|
25
|
+
|
|
26
|
+
echo.
|
|
27
|
+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
28
|
+
echo.
|
|
29
|
+
echo Please set the JAVA_HOME variable in your environment to match the
|
|
30
|
+
echo location of your Java installation.
|
|
31
|
+
|
|
32
|
+
goto fail
|
|
33
|
+
|
|
34
|
+
:findJavaFromJavaHome
|
|
35
|
+
set JAVA_HOME=%JAVA_HOME:"=%
|
|
36
|
+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
37
|
+
|
|
38
|
+
if exist "%JAVA_EXE%" goto init
|
|
39
|
+
|
|
40
|
+
echo.
|
|
41
|
+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
|
42
|
+
echo.
|
|
43
|
+
echo Please set the JAVA_HOME variable in your environment to match the
|
|
44
|
+
echo location of your Java installation.
|
|
45
|
+
|
|
46
|
+
goto fail
|
|
47
|
+
|
|
48
|
+
:init
|
|
49
|
+
@rem Get command-line arguments, handling Windows variants
|
|
50
|
+
|
|
51
|
+
if not "%OS%" == "Windows_NT" goto win9xME_args
|
|
52
|
+
|
|
53
|
+
:win9xME_args
|
|
54
|
+
@rem Slurp the command line arguments.
|
|
55
|
+
set CMD_LINE_ARGS=
|
|
56
|
+
set _SKIP=2
|
|
57
|
+
|
|
58
|
+
:win9xME_args_slurp
|
|
59
|
+
if "x%~1" == "x" goto execute
|
|
60
|
+
|
|
61
|
+
set CMD_LINE_ARGS=%*
|
|
62
|
+
|
|
63
|
+
:execute
|
|
64
|
+
@rem Setup the command line
|
|
65
|
+
|
|
66
|
+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
67
|
+
|
|
68
|
+
@rem Execute Gradle
|
|
69
|
+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
|
70
|
+
|
|
71
|
+
:end
|
|
72
|
+
@rem End local scope for the variables with windows NT shell
|
|
73
|
+
if "%ERRORLEVEL%"=="0" goto mainEnd
|
|
74
|
+
|
|
75
|
+
:fail
|
|
76
|
+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
77
|
+
rem the _cmd.exe /c_ return code!
|
|
78
|
+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
|
79
|
+
exit /b 1
|
|
80
|
+
|
|
81
|
+
:mainEnd
|
|
82
|
+
if "%OS%"=="Windows_NT" endlocal
|
|
83
|
+
|
|
84
|
+
:omega
|
|
@@ -2,12 +2,16 @@ package com.applovin.reactnative;
|
|
|
2
2
|
|
|
3
3
|
import com.applovin.mediation.MaxAdFormat;
|
|
4
4
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
5
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
5
6
|
import com.facebook.react.uimanager.SimpleViewManager;
|
|
6
7
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
7
|
-
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
8
8
|
|
|
9
9
|
import org.jetbrains.annotations.NotNull;
|
|
10
10
|
|
|
11
|
+
import java.util.HashMap;
|
|
12
|
+
import java.util.Map;
|
|
13
|
+
|
|
14
|
+
import androidx.annotation.NonNull;
|
|
11
15
|
import androidx.annotation.Nullable;
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -17,14 +21,12 @@ class AppLovinMAXAdViewManager
|
|
|
17
21
|
extends SimpleViewManager<AppLovinMAXAdView>
|
|
18
22
|
{
|
|
19
23
|
// Parent fields
|
|
20
|
-
private ReactApplicationContext reactApplicationContext;
|
|
21
|
-
|
|
22
|
-
// View fields
|
|
23
|
-
private AppLovinMAXAdView adView;
|
|
24
|
+
private final ReactApplicationContext reactApplicationContext;
|
|
24
25
|
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
private
|
|
26
|
+
// Maps from the view to the corresponding ad unit id and ad format.
|
|
27
|
+
// Both must be set before the MaxAdView is created.
|
|
28
|
+
private final Map<AppLovinMAXAdView, String> adUnitIdRegistry = new HashMap<>();
|
|
29
|
+
private final Map<AppLovinMAXAdView, MaxAdFormat> adFormatRegistry = new HashMap<>();
|
|
28
30
|
|
|
29
31
|
public AppLovinMAXAdViewManager(final ReactApplicationContext reactApplicationContext)
|
|
30
32
|
{
|
|
@@ -41,29 +43,53 @@ class AppLovinMAXAdViewManager
|
|
|
41
43
|
protected @NotNull AppLovinMAXAdView createViewInstance(@NotNull final ThemedReactContext reactContext)
|
|
42
44
|
{
|
|
43
45
|
// NOTE: Do not set frame or backgroundColor as RN will overwrite the values set by your custom class in order to match your JavaScript component's layout props - hence wrapper
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
return new AppLovinMAXAdView( reactContext );
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@Override
|
|
50
|
+
public void receiveCommand(@NonNull AppLovinMAXAdView view, String commandId, @Nullable ReadableArray args)
|
|
51
|
+
{
|
|
52
|
+
if ( "setAdUnitId".equals( commandId ) && args != null )
|
|
53
|
+
{
|
|
54
|
+
setAdUnitId( view, args.getString( 0 ) );
|
|
55
|
+
}
|
|
56
|
+
else if ( "setAdFormat".equals( commandId ) && args != null )
|
|
57
|
+
{
|
|
58
|
+
setAdFormat( view, args.getString( 0 ) );
|
|
59
|
+
}
|
|
60
|
+
else
|
|
61
|
+
{
|
|
62
|
+
AppLovinMAXModule.e( "Unable to parse command: " + commandId + " for AdView: + " + view + " with args: " + args );
|
|
63
|
+
}
|
|
46
64
|
}
|
|
47
65
|
|
|
48
|
-
|
|
49
|
-
public void setAdUnitId(final AppLovinMAXAdView view, @Nullable final String adUnitId)
|
|
66
|
+
public void setAdUnitId(final AppLovinMAXAdView view, final String adUnitId)
|
|
50
67
|
{
|
|
51
|
-
|
|
52
|
-
|
|
68
|
+
adUnitIdRegistry.put( view, adUnitId );
|
|
69
|
+
|
|
70
|
+
view.maybeAttachAdView( adUnitIdRegistry.get( view ), adFormatRegistry.get( view ) );
|
|
53
71
|
}
|
|
54
72
|
|
|
55
|
-
|
|
56
|
-
public void setAdFormat(final AppLovinMAXAdView view, @Nullable final String adFormatStr)
|
|
73
|
+
public void setAdFormat(final AppLovinMAXAdView view, final String adFormatStr)
|
|
57
74
|
{
|
|
58
75
|
if ( "banner".equals( adFormatStr ) )
|
|
59
76
|
{
|
|
60
|
-
|
|
77
|
+
adFormatRegistry.put( view, AppLovinMAXModule.getDeviceSpecificBannerAdViewAdFormat( reactApplicationContext ) );
|
|
61
78
|
}
|
|
62
79
|
else if ( "mrec".equals( adFormatStr ) )
|
|
63
80
|
{
|
|
64
|
-
|
|
81
|
+
adFormatRegistry.put( view, MaxAdFormat.MREC );
|
|
65
82
|
}
|
|
66
83
|
|
|
67
|
-
|
|
84
|
+
view.maybeAttachAdView( adUnitIdRegistry.get( view ), adFormatRegistry.get( view ) );
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@Override
|
|
88
|
+
public void onDropViewInstance(@NotNull AppLovinMAXAdView view)
|
|
89
|
+
{
|
|
90
|
+
// NOTE: Android destroys the native MaxAdView and calls this method while iOS caches it when you remove it from screen
|
|
91
|
+
adUnitIdRegistry.remove( view );
|
|
92
|
+
|
|
93
|
+
super.onDropViewInstance( view );
|
|
68
94
|
}
|
|
69
95
|
}
|
|
@@ -46,8 +46,10 @@ import com.facebook.react.bridge.WritableMap;
|
|
|
46
46
|
|
|
47
47
|
import java.util.ArrayList;
|
|
48
48
|
import java.util.HashMap;
|
|
49
|
+
import java.util.HashSet;
|
|
49
50
|
import java.util.List;
|
|
50
51
|
import java.util.Map;
|
|
52
|
+
import java.util.Set;
|
|
51
53
|
import java.util.concurrent.TimeUnit;
|
|
52
54
|
|
|
53
55
|
import androidx.annotation.Nullable;
|
|
@@ -87,13 +89,14 @@ public class AppLovinMAXModule
|
|
|
87
89
|
private final Map<String, MaxRewardedAd> mRewardedAds = new HashMap<>( 2 );
|
|
88
90
|
|
|
89
91
|
// Banner Fields
|
|
90
|
-
private final Map<String, MaxAdView> mAdViews
|
|
91
|
-
private final Map<String, MaxAdFormat> mAdViewAdFormats
|
|
92
|
-
private final Map<String, String> mAdViewPositions
|
|
93
|
-
private final Map<String, Point> mAdViewOffsets
|
|
94
|
-
private final Map<String, Integer> mAdViewWidths
|
|
95
|
-
private final Map<String, MaxAdFormat> mVerticalAdViewFormats
|
|
96
|
-
private final List<String> mAdUnitIdsToShowAfterCreate
|
|
92
|
+
private final Map<String, MaxAdView> mAdViews = new HashMap<>( 2 );
|
|
93
|
+
private final Map<String, MaxAdFormat> mAdViewAdFormats = new HashMap<>( 2 );
|
|
94
|
+
private final Map<String, String> mAdViewPositions = new HashMap<>( 2 );
|
|
95
|
+
private final Map<String, Point> mAdViewOffsets = new HashMap<>( 2 );
|
|
96
|
+
private final Map<String, Integer> mAdViewWidths = new HashMap<>( 2 );
|
|
97
|
+
private final Map<String, MaxAdFormat> mVerticalAdViewFormats = new HashMap<>( 2 );
|
|
98
|
+
private final List<String> mAdUnitIdsToShowAfterCreate = new ArrayList<>( 2 );
|
|
99
|
+
private final Set<String> mDisabledAdaptiveBannerAdUnitIds = new HashSet<>( 2 );
|
|
97
100
|
|
|
98
101
|
public static AppLovinMAXModule getInstance()
|
|
99
102
|
{
|
|
@@ -478,7 +481,7 @@ public class AppLovinMAXModule
|
|
|
478
481
|
@ReactMethod()
|
|
479
482
|
public void setBannerExtraParameter(final String adUnitId, final String key, final String value)
|
|
480
483
|
{
|
|
481
|
-
setAdViewExtraParameters( adUnitId, getDeviceSpecificBannerAdViewAdFormat(),
|
|
484
|
+
setAdViewExtraParameters( adUnitId, getDeviceSpecificBannerAdViewAdFormat(), key, value );
|
|
482
485
|
}
|
|
483
486
|
|
|
484
487
|
@ReactMethod()
|
|
@@ -499,6 +502,12 @@ public class AppLovinMAXModule
|
|
|
499
502
|
destroyAdView( adUnitId, getDeviceSpecificBannerAdViewAdFormat() );
|
|
500
503
|
}
|
|
501
504
|
|
|
505
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
506
|
+
public float getAdaptiveBannerHeightForWidth(final float width)
|
|
507
|
+
{
|
|
508
|
+
return getDeviceSpecificBannerAdViewAdFormat().getAdaptiveSize( (int) width, getCurrentActivity() ).getHeight();
|
|
509
|
+
}
|
|
510
|
+
|
|
502
511
|
// MRECS
|
|
503
512
|
|
|
504
513
|
@ReactMethod()
|
|
@@ -909,7 +918,7 @@ public class AppLovinMAXModule
|
|
|
909
918
|
{
|
|
910
919
|
d( "Setting placement \"" + placement + "\" for " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
|
|
911
920
|
|
|
912
|
-
final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
|
|
921
|
+
final MaxAdView adView = retrieveAdView( adUnitId, adFormat, "", DEFAULT_AD_VIEW_OFFSET );
|
|
913
922
|
if ( adView == null )
|
|
914
923
|
{
|
|
915
924
|
e( adFormat.getLabel() + " does not exist" );
|
|
@@ -1070,7 +1079,7 @@ public class AppLovinMAXModule
|
|
|
1070
1079
|
} );
|
|
1071
1080
|
}
|
|
1072
1081
|
|
|
1073
|
-
private void setAdViewExtraParameters(final String adUnitId, final MaxAdFormat adFormat, final String
|
|
1082
|
+
private void setAdViewExtraParameters(final String adUnitId, final MaxAdFormat adFormat, final String key, final String value)
|
|
1074
1083
|
{
|
|
1075
1084
|
getReactApplicationContext().runOnUiQueueThread( new Runnable()
|
|
1076
1085
|
{
|
|
@@ -1107,6 +1116,20 @@ public class AppLovinMAXModule
|
|
|
1107
1116
|
mAdViewAdFormats.put( adUnitId, forcedAdFormat );
|
|
1108
1117
|
positionAdView( adUnitId, forcedAdFormat );
|
|
1109
1118
|
}
|
|
1119
|
+
else if ( "adaptive_banner".equalsIgnoreCase( key ) )
|
|
1120
|
+
{
|
|
1121
|
+
boolean useAdaptiveBannerAdSize = Boolean.parseBoolean( value );
|
|
1122
|
+
if ( useAdaptiveBannerAdSize )
|
|
1123
|
+
{
|
|
1124
|
+
mDisabledAdaptiveBannerAdUnitIds.remove( adUnitId );
|
|
1125
|
+
}
|
|
1126
|
+
else
|
|
1127
|
+
{
|
|
1128
|
+
mDisabledAdaptiveBannerAdUnitIds.add( adUnitId );
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
positionAdView( adUnitId, adFormat );
|
|
1132
|
+
}
|
|
1110
1133
|
}
|
|
1111
1134
|
} );
|
|
1112
1135
|
}
|
|
@@ -1210,14 +1233,18 @@ public class AppLovinMAXModule
|
|
|
1210
1233
|
return;
|
|
1211
1234
|
}
|
|
1212
1235
|
|
|
1213
|
-
final
|
|
1214
|
-
|
|
1215
|
-
final boolean isWidthDpOverridden = mAdViewWidths.containsKey( adUnitId );
|
|
1236
|
+
final ViewParent parent = adView.getParent();
|
|
1237
|
+
if ( !( parent instanceof RelativeLayout ) ) return;
|
|
1216
1238
|
|
|
1217
|
-
final RelativeLayout relativeLayout = (RelativeLayout)
|
|
1239
|
+
final RelativeLayout relativeLayout = (RelativeLayout) parent;
|
|
1218
1240
|
final Rect windowRect = new Rect();
|
|
1219
1241
|
relativeLayout.getWindowVisibleDisplayFrame( windowRect );
|
|
1220
1242
|
|
|
1243
|
+
final String adViewPosition = mAdViewPositions.get( adUnitId );
|
|
1244
|
+
final Point adViewOffset = mAdViewOffsets.get( adUnitId );
|
|
1245
|
+
final boolean isAdaptiveBannerDisabled = mDisabledAdaptiveBannerAdUnitIds.contains( adUnitId );
|
|
1246
|
+
final boolean isWidthDpOverridden = mAdViewWidths.containsKey( adUnitId );
|
|
1247
|
+
|
|
1221
1248
|
//
|
|
1222
1249
|
// Determine ad width
|
|
1223
1250
|
//
|
|
@@ -1240,7 +1267,19 @@ public class AppLovinMAXModule
|
|
|
1240
1267
|
adViewWidthDp = adFormat.getSize().getWidth();
|
|
1241
1268
|
}
|
|
1242
1269
|
|
|
1243
|
-
|
|
1270
|
+
//
|
|
1271
|
+
// Determine ad height
|
|
1272
|
+
//
|
|
1273
|
+
final int adViewHeightDp;
|
|
1274
|
+
|
|
1275
|
+
if ( ( adFormat == MaxAdFormat.BANNER || adFormat == MaxAdFormat.LEADER ) && !isAdaptiveBannerDisabled )
|
|
1276
|
+
{
|
|
1277
|
+
adViewHeightDp = adFormat.getAdaptiveSize( adViewWidthDp, getCurrentActivity() ).getHeight();
|
|
1278
|
+
}
|
|
1279
|
+
else
|
|
1280
|
+
{
|
|
1281
|
+
adViewHeightDp = adFormat.getSize().getHeight();
|
|
1282
|
+
}
|
|
1244
1283
|
|
|
1245
1284
|
final int widthPx = AppLovinSdkUtils.dpToPx( getCurrentActivity(), adViewWidthDp );
|
|
1246
1285
|
final int heightPx = AppLovinSdkUtils.dpToPx( getCurrentActivity(), adViewHeightDp );
|
package/ios/AppLovinMAX.h
CHANGED
|
@@ -26,11 +26,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
26
26
|
*/
|
|
27
27
|
@property (nonatomic, strong, readonly, class) AppLovinMAX *shared;
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
* Utility method for getting the width and height for a given ad format.
|
|
31
|
-
*/
|
|
32
|
-
+ (CGSize)adViewSizeForAdFormat:(MAAdFormat *)adFormat;
|
|
33
|
-
|
|
34
29
|
/**
|
|
35
30
|
* Dedicated method for retrieving a MAAdView.
|
|
36
31
|
*/
|
package/ios/AppLovinMAX.m
CHANGED
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
@property (nonatomic, strong) NSMutableDictionary<NSString *, NSNumber *> *adViewWidths;
|
|
56
56
|
@property (nonatomic, strong) NSMutableDictionary<NSString *, NSArray<NSLayoutConstraint *> *> *adViewConstraints;
|
|
57
57
|
@property (nonatomic, strong) NSMutableArray<NSString *> *adUnitIdentifiersToShowAfterCreate;
|
|
58
|
+
@property (nonatomic, strong) NSMutableSet<NSString *> *disabledAdaptiveBannerAdUnitIdentifiers;
|
|
58
59
|
@property (nonatomic, strong) UIView *safeAreaBackground;
|
|
59
60
|
@property (nonatomic, strong, nullable) UIColor *publisherBannerBackgroundColor;
|
|
60
61
|
|
|
@@ -105,6 +106,7 @@ RCT_EXPORT_MODULE()
|
|
|
105
106
|
self.adViewWidths = [NSMutableDictionary dictionaryWithCapacity: 2];
|
|
106
107
|
self.adViewConstraints = [NSMutableDictionary dictionaryWithCapacity: 2];
|
|
107
108
|
self.adUnitIdentifiersToShowAfterCreate = [NSMutableArray arrayWithCapacity: 2];
|
|
109
|
+
self.disabledAdaptiveBannerAdUnitIdentifiers = [NSMutableSet setWithCapacity: 2];
|
|
108
110
|
|
|
109
111
|
self.safeAreaBackground = [[UIView alloc] init];
|
|
110
112
|
self.safeAreaBackground.hidden = YES;
|
|
@@ -357,7 +359,7 @@ RCT_EXPORT_METHOD(setBannerBackgroundColor:(NSString *)adUnitIdentifier :(NSStri
|
|
|
357
359
|
[self setAdViewBackgroundColorForAdUnitIdentifier: adUnitIdentifier adFormat: DEVICE_SPECIFIC_ADVIEW_AD_FORMAT hexColorCode: hexColorCode];
|
|
358
360
|
}
|
|
359
361
|
|
|
360
|
-
RCT_EXPORT_METHOD(setBannerPlacement:(
|
|
362
|
+
RCT_EXPORT_METHOD(setBannerPlacement:(NSString *)adUnitIdentifier :(nullable NSString *)placement)
|
|
361
363
|
{
|
|
362
364
|
[self setAdViewPlacement: placement forAdUnitIdentifier: adUnitIdentifier adFormat: DEVICE_SPECIFIC_ADVIEW_AD_FORMAT];
|
|
363
365
|
}
|
|
@@ -397,6 +399,11 @@ RCT_EXPORT_METHOD(destroyBanner:(NSString *)adUnitIdentifier)
|
|
|
397
399
|
[self destroyAdViewWithAdUnitIdentifier: adUnitIdentifier adFormat: DEVICE_SPECIFIC_ADVIEW_AD_FORMAT];
|
|
398
400
|
}
|
|
399
401
|
|
|
402
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getAdaptiveBannerHeightForWidth:(CGFloat)width)
|
|
403
|
+
{
|
|
404
|
+
return @([DEVICE_SPECIFIC_ADVIEW_AD_FORMAT adaptiveSizeForWidth: width].height);
|
|
405
|
+
}
|
|
406
|
+
|
|
400
407
|
#pragma mark - MRECs
|
|
401
408
|
|
|
402
409
|
RCT_EXPORT_METHOD(createMRec:(NSString *)adUnitIdentifier :(NSString *)mrecPosition)
|
|
@@ -404,7 +411,7 @@ RCT_EXPORT_METHOD(createMRec:(NSString *)adUnitIdentifier :(NSString *)mrecPosit
|
|
|
404
411
|
[self createAdViewWithAdUnitIdentifier: adUnitIdentifier adFormat: MAAdFormat.mrec atPosition: mrecPosition withOffset: CGPointZero];
|
|
405
412
|
}
|
|
406
413
|
|
|
407
|
-
RCT_EXPORT_METHOD(setMRecPlacement:(
|
|
414
|
+
RCT_EXPORT_METHOD(setMRecPlacement:(NSString *)adUnitIdentifier :(nullable NSString *)placement)
|
|
408
415
|
{
|
|
409
416
|
[self setAdViewPlacement: placement forAdUnitIdentifier: adUnitIdentifier adFormat: MAAdFormat.mrec];
|
|
410
417
|
}
|
|
@@ -756,7 +763,7 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
756
763
|
|
|
757
764
|
[self log: @"Setting placement \"%@\" for \"%@\" with ad unit identifier \"%@\"", placement, adFormat, adUnitIdentifier];
|
|
758
765
|
|
|
759
|
-
MAAdView *adView = [self retrieveAdViewForAdUnitIdentifier: adUnitIdentifier adFormat: adFormat];
|
|
766
|
+
MAAdView *adView = [self retrieveAdViewForAdUnitIdentifier: adUnitIdentifier adFormat: adFormat atPosition: @"" withOffset: CGPointZero];
|
|
760
767
|
adView.placement = placement;
|
|
761
768
|
});
|
|
762
769
|
}
|
|
@@ -769,7 +776,7 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
769
776
|
CGFloat minWidth = adFormat.size.width;
|
|
770
777
|
if ( width < minWidth )
|
|
771
778
|
{
|
|
772
|
-
[self log: @"The provided with: %f is smaller than the minimum required width: %f for ad format: %@. Please set the width higher than the minimum required.", width, minWidth, adFormat];
|
|
779
|
+
[self log: @"The provided with: %f is smaller than the minimum required width: %f for ad format: %@. Please set the width higher than the minimum required.", width, minWidth, adFormat];
|
|
773
780
|
}
|
|
774
781
|
|
|
775
782
|
self.adViewWidths[adUnitIdentifier] = @(width);
|
|
@@ -813,6 +820,20 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
813
820
|
self.adViewAdFormats[adUnitIdentifier] = adFormat;
|
|
814
821
|
[self positionAdViewForAdUnitIdentifier: adUnitIdentifier adFormat: adFormat];
|
|
815
822
|
}
|
|
823
|
+
else if ( [@"adaptive_banner" isEqualToString: key] )
|
|
824
|
+
{
|
|
825
|
+
BOOL shouldUseAdaptiveBanner = [NSNumber al_numberWithString: value].boolValue;
|
|
826
|
+
if ( shouldUseAdaptiveBanner )
|
|
827
|
+
{
|
|
828
|
+
[self.disabledAdaptiveBannerAdUnitIdentifiers removeObject: adUnitIdentifier];
|
|
829
|
+
}
|
|
830
|
+
else
|
|
831
|
+
{
|
|
832
|
+
[self.disabledAdaptiveBannerAdUnitIdentifiers addObject: adUnitIdentifier];
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
[self positionAdViewForAdUnitIdentifier: adUnitIdentifier adFormat: adFormat];
|
|
836
|
+
}
|
|
816
837
|
});
|
|
817
838
|
}
|
|
818
839
|
|
|
@@ -958,6 +979,7 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
958
979
|
{
|
|
959
980
|
MAAdView *adView = [self retrieveAdViewForAdUnitIdentifier: adUnitIdentifier adFormat: adFormat];
|
|
960
981
|
NSString *adViewPosition = self.adViewPositions[adUnitIdentifier];
|
|
982
|
+
BOOL isAdaptiveBannerDisabled = [self.disabledAdaptiveBannerAdUnitIdentifiers containsObject: adUnitIdentifier];
|
|
961
983
|
BOOL isWidthPtsOverridden = self.adViewWidths[adUnitIdentifier] != nil;
|
|
962
984
|
|
|
963
985
|
NSValue *adViewPositionValue = self.adViewOffsets[adUnitIdentifier];
|
|
@@ -1016,7 +1038,20 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
1016
1038
|
adViewWidth = adFormat.size.width;
|
|
1017
1039
|
}
|
|
1018
1040
|
|
|
1019
|
-
|
|
1041
|
+
//
|
|
1042
|
+
// Determine ad height
|
|
1043
|
+
//
|
|
1044
|
+
CGFloat adViewHeight;
|
|
1045
|
+
|
|
1046
|
+
if ( (adFormat == MAAdFormat.banner || adFormat == MAAdFormat.leader) && !isAdaptiveBannerDisabled )
|
|
1047
|
+
{
|
|
1048
|
+
adViewHeight = [adFormat adaptiveSizeForWidth: adViewWidth].height;
|
|
1049
|
+
}
|
|
1050
|
+
else
|
|
1051
|
+
{
|
|
1052
|
+
adViewHeight = adFormat.size.height;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1020
1055
|
CGSize adViewSize = CGSizeMake(adViewWidth, adViewHeight);
|
|
1021
1056
|
|
|
1022
1057
|
// All positions have constant height
|
|
@@ -1035,6 +1070,21 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
1035
1070
|
// If top of bottom center, stretch width of screen
|
|
1036
1071
|
if ( [adViewPosition isEqual: @"top_center"] || [adViewPosition isEqual: @"bottom_center"] )
|
|
1037
1072
|
{
|
|
1073
|
+
// Non AdMob banners will still be of 50/90 points tall. Set the auto sizing mask such that the inner ad view is pinned to the bottom or top according to the ad view position.
|
|
1074
|
+
if ( !isAdaptiveBannerDisabled )
|
|
1075
|
+
{
|
|
1076
|
+
adView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
|
1077
|
+
|
|
1078
|
+
if ( [@"top_center" isEqual: adViewPosition] )
|
|
1079
|
+
{
|
|
1080
|
+
adView.autoresizingMask |= UIViewAutoresizingFlexibleBottomMargin;
|
|
1081
|
+
}
|
|
1082
|
+
else // bottom_center
|
|
1083
|
+
{
|
|
1084
|
+
adView.autoresizingMask |= UIViewAutoresizingFlexibleTopMargin;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1038
1088
|
// If publisher actually provided a banner background color, span the banner across the realm
|
|
1039
1089
|
if ( self.publisherBannerBackgroundColor && adFormat != MAAdFormat.mrec )
|
|
1040
1090
|
{
|
|
@@ -1115,27 +1165,6 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
1115
1165
|
[NSLayoutConstraint activateConstraints: constraints];
|
|
1116
1166
|
}
|
|
1117
1167
|
|
|
1118
|
-
+ (CGSize)adViewSizeForAdFormat:(MAAdFormat *)adFormat
|
|
1119
|
-
{
|
|
1120
|
-
if ( MAAdFormat.leader == adFormat )
|
|
1121
|
-
{
|
|
1122
|
-
return CGSizeMake(728.0f, 90.0f);
|
|
1123
|
-
}
|
|
1124
|
-
else if ( MAAdFormat.banner == adFormat )
|
|
1125
|
-
{
|
|
1126
|
-
return CGSizeMake(320.0f, 50.0f);
|
|
1127
|
-
}
|
|
1128
|
-
else if ( MAAdFormat.mrec == adFormat )
|
|
1129
|
-
{
|
|
1130
|
-
return CGSizeMake(300.0f, 250.0f);
|
|
1131
|
-
}
|
|
1132
|
-
else
|
|
1133
|
-
{
|
|
1134
|
-
[NSException raise: NSInvalidArgumentException format: @"Invalid ad format"];
|
|
1135
|
-
return CGSizeZero;
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
1168
|
- (NSDictionary<NSString *, id> *)adInfoForAd:(MAAd *)ad
|
|
1140
1169
|
{
|
|
1141
1170
|
return @{@"adUnitId" : ad.adUnitIdentifier,
|