react-native-applovin-max 4.1.6 → 5.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.
@@ -1,7 +1,4 @@
1
1
  buildscript {
2
- // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
- def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['AppLovinMAX_kotlinVersion']
4
-
5
2
  ext.versions = [
6
3
  'minSdk' : 16,
7
4
  'compileSdk' : 29,
@@ -17,15 +14,12 @@ buildscript {
17
14
 
18
15
  dependencies {
19
16
  classpath 'com.android.tools.build:gradle:3.5.4'
20
- // noinspection DifferentKotlinGradleVersion
21
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
22
17
 
23
18
  classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.21.0"
24
19
  }
25
20
  }
26
21
 
27
22
  apply plugin: 'com.android.library'
28
- apply plugin: 'kotlin-android'
29
23
 
30
24
  def getExtOrDefault(name) {
31
25
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['AppLovinMAX_' + name]
@@ -41,8 +35,8 @@ android {
41
35
  defaultConfig {
42
36
  minSdkVersion 16
43
37
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
44
- versionCode 4010600
45
- versionName "4.1.6"
38
+ versionCode 5000000
39
+ versionName "5.0.0"
46
40
  }
47
41
 
48
42
  flavorDimensions("default")
@@ -142,13 +136,9 @@ repositories {
142
136
  }
143
137
  }
144
138
 
145
- def kotlin_version = getExtOrDefault('kotlinVersion')
146
-
147
139
  dependencies {
148
140
  // noinspection GradleDynamicVersion
149
141
  api 'com.facebook.react:react-native:+'
150
142
 
151
- implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
152
-
153
143
  implementation 'com.applovin:applovin-sdk:11.8.0'
154
144
  }
@@ -1,4 +1,3 @@
1
- AppLovinMAX_kotlinVersion=1.3.50
2
1
  AppLovinMAX_compileSdkVersion=28
3
2
  AppLovinMAX_buildToolsVersion=28.0.3
4
3
  AppLovinMAX_targetSdkVersion=28
@@ -7,12 +7,18 @@ import android.text.TextUtils;
7
7
  import com.applovin.mediation.MaxAd;
8
8
  import com.applovin.mediation.MaxAdFormat;
9
9
  import com.applovin.mediation.MaxAdListener;
10
+ import com.applovin.mediation.MaxAdRevenueListener;
10
11
  import com.applovin.mediation.MaxAdViewAdListener;
11
12
  import com.applovin.mediation.MaxError;
12
13
  import com.applovin.mediation.ads.MaxAdView;
14
+ import com.facebook.react.bridge.ReadableMap;
15
+ import com.facebook.react.bridge.WritableMap;
13
16
  import com.facebook.react.uimanager.ThemedReactContext;
17
+ import com.facebook.react.uimanager.events.RCTEventEmitter;
14
18
  import com.facebook.react.views.view.ReactViewGroup;
15
19
 
20
+ import java.util.Map;
21
+
16
22
  import androidx.annotation.Nullable;
17
23
 
18
24
  /**
@@ -20,23 +26,30 @@ import androidx.annotation.Nullable;
20
26
  */
21
27
  class AppLovinMAXAdView
22
28
  extends ReactViewGroup
23
- implements MaxAdListener, MaxAdViewAdListener
29
+ implements MaxAdListener, MaxAdViewAdListener, MaxAdRevenueListener
24
30
  {
25
31
  private final ThemedReactContext reactContext;
26
32
 
27
- private @Nullable MaxAdView adView;
28
-
29
- private String adUnitId;
30
- private MaxAdFormat adFormat;
31
- private @Nullable String placement;
32
- private @Nullable String customData;
33
- private boolean adaptiveBannerEnabled;
34
- private boolean autoRefresh;
33
+ @Nullable
34
+ private MaxAdView adView;
35
+
36
+ private String adUnitId;
37
+ private MaxAdFormat adFormat;
38
+ @Nullable
39
+ private String placement;
40
+ @Nullable
41
+ private String customData;
42
+ private boolean adaptiveBannerEnabled;
43
+ private boolean autoRefresh;
44
+ @Nullable
45
+ private Map<String, Object> extraParameters;
46
+ @Nullable
47
+ private Map<String, Object> localExtraParameters;
35
48
 
36
49
  public AppLovinMAXAdView(final Context context)
37
50
  {
38
51
  super( context );
39
- this.reactContext = (ThemedReactContext) context;
52
+ reactContext = (ThemedReactContext) context;
40
53
  }
41
54
 
42
55
  public void setAdUnitId(final String value)
@@ -62,11 +75,11 @@ class AppLovinMAXAdView
62
75
  return;
63
76
  }
64
77
 
65
- if ( "banner".equals( value ) )
78
+ if ( MaxAdFormat.BANNER.getLabel().equals( value ) )
66
79
  {
67
80
  adFormat = AppLovinMAXModule.getDeviceSpecificBannerAdViewAdFormat( reactContext );
68
81
  }
69
- else if ( "mrec".equals( value ) )
82
+ else if ( MaxAdFormat.MREC.getLabel().equals( value ) )
70
83
  {
71
84
  adFormat = MaxAdFormat.MREC;
72
85
  }
@@ -126,6 +139,22 @@ class AppLovinMAXAdView
126
139
  }
127
140
  }
128
141
 
142
+ public void setExtraParameters(@Nullable final ReadableMap readableMap)
143
+ {
144
+ if ( readableMap != null )
145
+ {
146
+ extraParameters = readableMap.toHashMap();
147
+ }
148
+ }
149
+
150
+ public void setLocalExtraParameters(@Nullable final ReadableMap readableMap)
151
+ {
152
+ if ( readableMap != null )
153
+ {
154
+ localExtraParameters = readableMap.toHashMap();
155
+ }
156
+ }
157
+
129
158
  @Override
130
159
  public void requestLayout()
131
160
  {
@@ -184,6 +213,12 @@ class AppLovinMAXAdView
184
213
  // Run after 0.25 sec delay to allow all properties to set
185
214
  postDelayed( () -> {
186
215
 
216
+ if ( AppLovinMAXModule.getInstance().getSdk() == null )
217
+ {
218
+ AppLovinMAXModule.logUninitializedAccessError( "AppLovinMAXAdView.maybeAttachAdView" );
219
+ return;
220
+ }
221
+
187
222
  if ( TextUtils.isEmpty( adUnitId ) )
188
223
  {
189
224
  AppLovinMAXModule.e( "Attempting to attach MaxAdView without Ad Unit ID" );
@@ -206,13 +241,29 @@ class AppLovinMAXAdView
206
241
 
207
242
  adView = new MaxAdView( adUnitId, adFormat, AppLovinMAXModule.getInstance().getSdk(), currentActivity );
208
243
  adView.setListener( this );
209
- adView.setRevenueListener( AppLovinMAXModule.getInstance() );
244
+ adView.setRevenueListener( this );
210
245
  adView.setPlacement( placement );
211
246
  adView.setCustomData( customData );
212
247
  adView.setExtraParameter( "adaptive_banner", Boolean.toString( adaptiveBannerEnabled ) );
213
248
  // Set this extra parameter to work around a SDK bug that ignores calls to stopAutoRefresh()
214
249
  adView.setExtraParameter( "allow_pause_auto_refresh_immediately", "true" );
215
250
 
251
+ if ( extraParameters != null )
252
+ {
253
+ for ( Map.Entry<String, Object> entry : extraParameters.entrySet() )
254
+ {
255
+ adView.setExtraParameter( entry.getKey(), (String) entry.getValue() );
256
+ }
257
+ }
258
+
259
+ if ( localExtraParameters != null )
260
+ {
261
+ for ( Map.Entry<String, Object> entry : localExtraParameters.entrySet() )
262
+ {
263
+ adView.setLocalExtraParameter( entry.getKey(), (String) entry.getValue() );
264
+ }
265
+ }
266
+
216
267
  if ( autoRefresh )
217
268
  {
218
269
  adView.startAutoRefresh();
@@ -247,46 +298,57 @@ class AppLovinMAXAdView
247
298
  @Override
248
299
  public void onAdLoaded(final MaxAd ad)
249
300
  {
250
- AppLovinMAXModule.getInstance().onAdLoaded( ad );
301
+ WritableMap adInfo = AppLovinMAXModule.getInstance().getAdInfo( ad );
302
+ reactContext.getJSModule( RCTEventEmitter.class ).receiveEvent( getId(), "onAdLoadedEvent", adInfo );
251
303
  }
252
304
 
253
305
  @Override
254
306
  public void onAdLoadFailed(final String adUnitId, final MaxError error)
255
307
  {
256
- String name = ( adFormat == MaxAdFormat.MREC ) ? "OnMRecAdLoadFailedEvent" : "OnBannerAdLoadFailedEvent";
257
-
258
- AppLovinMAXModule.getInstance().sendReactNativeEventForAdLoadFailed( name, adUnitId, error );
308
+ WritableMap adLoadFailedInfo = AppLovinMAXModule.getInstance().getAdLoadFailedInfo( adUnitId, error );
309
+ reactContext.getJSModule( RCTEventEmitter.class ).receiveEvent( getId(), "onAdLoadFailedEvent", adLoadFailedInfo );
259
310
  }
260
311
 
261
312
  @Override
262
313
  public void onAdDisplayFailed(final MaxAd ad, final MaxError error)
263
314
  {
264
- AppLovinMAXModule.getInstance().onAdDisplayFailed( ad, error );
315
+ WritableMap adDisplayFailedInfo = AppLovinMAXModule.getInstance().getAdDisplayFailedInfo( ad, error );
316
+ reactContext.getJSModule( RCTEventEmitter.class ).receiveEvent( getId(), "onAdDisplayFailedEvent", adDisplayFailedInfo );
265
317
  }
266
318
 
267
319
  @Override
268
320
  public void onAdClicked(final MaxAd ad)
269
321
  {
270
- AppLovinMAXModule.getInstance().onAdClicked( ad );
322
+ WritableMap adInfo = AppLovinMAXModule.getInstance().getAdInfo( ad );
323
+ reactContext.getJSModule( RCTEventEmitter.class ).receiveEvent( getId(), "onAdClickedEvent", adInfo );
271
324
  }
272
325
 
273
326
  @Override
274
327
  public void onAdExpanded(final MaxAd ad)
275
328
  {
276
- AppLovinMAXModule.getInstance().onAdExpanded( ad );
329
+ WritableMap adInfo = AppLovinMAXModule.getInstance().getAdInfo( ad );
330
+ reactContext.getJSModule( RCTEventEmitter.class ).receiveEvent( getId(), "onAdExpandedEvent", adInfo );
277
331
  }
278
332
 
279
333
  @Override
280
334
  public void onAdCollapsed(final MaxAd ad)
281
335
  {
282
- AppLovinMAXModule.getInstance().onAdCollapsed( ad );
336
+ WritableMap adInfo = AppLovinMAXModule.getInstance().getAdInfo( ad );
337
+ reactContext.getJSModule( RCTEventEmitter.class ).receiveEvent( getId(), "onAdCollapsedEvent", adInfo );
338
+ }
339
+
340
+ @Override
341
+ public void onAdRevenuePaid(final MaxAd ad)
342
+ {
343
+ WritableMap adRevenueInfo = AppLovinMAXModule.getInstance().getAdRevenueInfo( ad );
344
+ reactContext.getJSModule( RCTEventEmitter.class ).receiveEvent( getId(), "onAdRevenuePaidEvent", adRevenueInfo );
283
345
  }
284
346
 
285
347
  /// Deprecated Callbacks
286
348
 
287
349
  @Override
288
- public void onAdDisplayed(final MaxAd ad) {}
350
+ public void onAdDisplayed(final MaxAd ad) { }
289
351
 
290
352
  @Override
291
- public void onAdHidden(final MaxAd ad) {}
353
+ public void onAdHidden(final MaxAd ad) { }
292
354
  }
@@ -1,11 +1,13 @@
1
1
  package com.applovin.reactnative;
2
2
 
3
3
  import com.facebook.react.bridge.ReactApplicationContext;
4
+ import com.facebook.react.bridge.ReadableMap;
5
+ import com.facebook.react.common.MapBuilder;
4
6
  import com.facebook.react.uimanager.SimpleViewManager;
5
7
  import com.facebook.react.uimanager.ThemedReactContext;
6
8
  import com.facebook.react.uimanager.annotations.ReactProp;
7
9
 
8
- import org.jetbrains.annotations.NotNull;
10
+ import java.util.Map;
9
11
 
10
12
  import androidx.annotation.Nullable;
11
13
 
@@ -17,21 +19,47 @@ class AppLovinMAXAdViewManager
17
19
  {
18
20
  public AppLovinMAXAdViewManager(final ReactApplicationContext reactApplicationContext) { }
19
21
 
20
- @NotNull
21
22
  @Override
22
23
  public String getName()
23
24
  {
24
25
  return "AppLovinMAXAdView";
25
26
  }
26
27
 
27
- @NotNull
28
+ @Nullable
28
29
  @Override
29
- protected AppLovinMAXAdView createViewInstance(@NotNull final ThemedReactContext reactContext)
30
+ public Map<String, Object> getExportedCustomDirectEventTypeConstants()
31
+ {
32
+ // mapping Android events to JavaScript events
33
+ return MapBuilder.<String, Object>builder()
34
+ .put( "onAdLoadedEvent", MapBuilder.of( "registrationName", "onAdLoadedEvent" ) )
35
+ .put( "onAdLoadFailedEvent", MapBuilder.of( "registrationName", "onAdLoadFailedEvent" ) )
36
+ .put( "onAdDisplayFailedEvent", MapBuilder.of( "registrationName", "onAdDisplayFailedEvent" ) )
37
+ .put( "onAdClickedEvent", MapBuilder.of( "registrationName", "onAdClickedEvent" ) )
38
+ .put( "onAdExpandedEvent", MapBuilder.of( "registrationName", "onAdExpandedEvent" ) )
39
+ .put( "onAdCollapsedEvent", MapBuilder.of( "registrationName", "onAdCollapsedEvent" ) )
40
+ .put( "onAdRevenuePaidEvent", MapBuilder.of( "registrationName", "onAdRevenuePaidEvent" ) )
41
+ .build();
42
+ }
43
+
44
+ @Override
45
+ protected AppLovinMAXAdView createViewInstance(final ThemedReactContext reactContext)
30
46
  {
31
47
  // 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
32
48
  return new AppLovinMAXAdView( reactContext );
33
49
  }
34
50
 
51
+ @ReactProp(name = "adUnitId")
52
+ public void setAdUnitId(final AppLovinMAXAdView view, final String adUnitId)
53
+ {
54
+ view.setAdUnitId( adUnitId );
55
+ }
56
+
57
+ @ReactProp(name = "adFormat")
58
+ public void setAdFormat(final AppLovinMAXAdView view, final String adFormatStr)
59
+ {
60
+ view.setAdFormat( adFormatStr );
61
+ }
62
+
35
63
  @ReactProp(name = "placement")
36
64
  public void setPlacement(final AppLovinMAXAdView view, @Nullable final String placement)
37
65
  {
@@ -56,20 +84,20 @@ class AppLovinMAXAdViewManager
56
84
  view.setAutoRefresh( enabled );
57
85
  }
58
86
 
59
- @ReactProp(name = "adUnitId")
60
- public void setAdUnitId(final AppLovinMAXAdView view, final String adUnitId)
87
+ @ReactProp(name = "extraParameters")
88
+ public void setExtraParameters(final AppLovinMAXAdView view, @Nullable final ReadableMap value)
61
89
  {
62
- view.setAdUnitId( adUnitId );
90
+ view.setExtraParameters( value );
63
91
  }
64
92
 
65
- @ReactProp(name = "adFormat")
66
- public void setAdFormat(final AppLovinMAXAdView view, final String adFormatStr)
93
+ @ReactProp(name = "localExtraParameters")
94
+ public void setLocalExtraParameters(final AppLovinMAXAdView view, @Nullable final ReadableMap value)
67
95
  {
68
- view.setAdFormat( adFormatStr );
96
+ view.setLocalExtraParameters( value );
69
97
  }
70
98
 
71
99
  @Override
72
- public void onDropViewInstance(@NotNull AppLovinMAXAdView view)
100
+ public void onDropViewInstance(AppLovinMAXAdView view)
73
101
  {
74
102
  view.destroy();
75
103