react-native-applovin-max 8.1.1 → 9.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 (165) hide show
  1. package/android/build.gradle +14 -3
  2. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdView.java +33 -26
  3. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewManagerImpl.java +110 -0
  4. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewUiComponent.java +17 -15
  5. package/android/src/main/java/com/applovin/reactnative/{AppLovinMAXModule.java → AppLovinMAXModuleImpl.java} +115 -179
  6. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdView.java +84 -56
  7. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdViewManagerImpl.java +101 -0
  8. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXPackage.java +44 -11
  9. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXUtils.java +56 -0
  10. package/android/src/newarch/com/applovin/reactnative/AppLovinMAXAdViewManager.java +151 -0
  11. package/android/src/newarch/com/applovin/reactnative/AppLovinMAXModule.java +453 -0
  12. package/android/src/newarch/com/applovin/reactnative/AppLovinMAXNativeAdViewManager.java +130 -0
  13. package/android/src/oldarch/com/applovin/reactnative/AppLovinMAXAdViewManager.java +128 -0
  14. package/android/src/oldarch/com/applovin/reactnative/AppLovinMAXModule.java +453 -0
  15. package/android/src/oldarch/com/applovin/reactnative/AppLovinMAXNativeAdViewManager.java +93 -0
  16. package/ios/AppLovinMAX.h +8 -8
  17. package/ios/{AppLovinMAX.m → AppLovinMAX.mm} +73 -64
  18. package/ios/AppLovinMAXAdView.h +7 -2
  19. package/ios/AppLovinMAXAdView.mm +747 -0
  20. package/ios/{AppLovinMAXAdViewManager.m → AppLovinMAXAdViewManager.mm} +3 -2
  21. package/ios/{AppLovinMAXAdViewUIComponent.m → AppLovinMAXAdViewUIComponent.mm} +2 -1
  22. package/ios/AppLovinMAXNativeAdView.h +15 -4
  23. package/ios/AppLovinMAXNativeAdView.mm +745 -0
  24. package/ios/AppLovinMAXNativeAdViewManager.mm +116 -0
  25. package/lib/commonjs/AdView.js +67 -85
  26. package/lib/commonjs/AdView.js.map +1 -1
  27. package/lib/commonjs/AppLovinMAX.js +51 -10
  28. package/lib/commonjs/AppLovinMAX.js.map +1 -1
  29. package/lib/commonjs/AppOpenAd.js +8 -10
  30. package/lib/commonjs/AppOpenAd.js.map +1 -1
  31. package/lib/commonjs/BannerAd.js +19 -21
  32. package/lib/commonjs/BannerAd.js.map +1 -1
  33. package/lib/commonjs/ErrorCode.js +57 -5
  34. package/lib/commonjs/ErrorCode.js.map +1 -1
  35. package/lib/commonjs/EventEmitter.js +3 -5
  36. package/lib/commonjs/EventEmitter.js.map +1 -1
  37. package/lib/commonjs/InterstitialAd.js +8 -10
  38. package/lib/commonjs/InterstitialAd.js.map +1 -1
  39. package/lib/commonjs/MRecAd.js +14 -16
  40. package/lib/commonjs/MRecAd.js.map +1 -1
  41. package/lib/commonjs/Privacy.js +3 -5
  42. package/lib/commonjs/Privacy.js.map +1 -1
  43. package/lib/commonjs/RewardedAd.js +8 -10
  44. package/lib/commonjs/RewardedAd.js.map +1 -1
  45. package/lib/commonjs/Utils.js +25 -0
  46. package/lib/commonjs/Utils.js.map +1 -0
  47. package/lib/commonjs/nativeAd/NativeAdView.js +65 -42
  48. package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -1
  49. package/lib/commonjs/nativeAd/NativeAdViewComponents.js +51 -47
  50. package/lib/commonjs/nativeAd/NativeAdViewComponents.js.map +1 -1
  51. package/lib/commonjs/nativeAd/NativeAdViewProvider.js +38 -8
  52. package/lib/commonjs/nativeAd/NativeAdViewProvider.js.map +1 -1
  53. package/lib/commonjs/nativeAd/img/blank_icon.png +0 -0
  54. package/lib/commonjs/specs/AppLovinMAXAdViewNativeComponent.js +14 -0
  55. package/lib/commonjs/specs/AppLovinMAXAdViewNativeComponent.js.map +1 -0
  56. package/lib/commonjs/specs/AppLovinMAXNativeAdViewNativeComponent.js +14 -0
  57. package/lib/commonjs/specs/AppLovinMAXNativeAdViewNativeComponent.js.map +1 -0
  58. package/lib/commonjs/specs/NativeAppLovinMAXModule.js +9 -0
  59. package/lib/commonjs/specs/NativeAppLovinMAXModule.js.map +1 -0
  60. package/lib/commonjs/types/AdInfo.js +10 -3
  61. package/lib/commonjs/types/AdInfo.js.map +1 -1
  62. package/lib/module/AdView.js +62 -81
  63. package/lib/module/AdView.js.map +1 -1
  64. package/lib/module/AppLovinMAX.js +47 -7
  65. package/lib/module/AppLovinMAX.js.map +1 -1
  66. package/lib/module/AppOpenAd.js +1 -4
  67. package/lib/module/AppOpenAd.js.map +1 -1
  68. package/lib/module/BannerAd.js +1 -4
  69. package/lib/module/BannerAd.js.map +1 -1
  70. package/lib/module/ErrorCode.js +55 -4
  71. package/lib/module/ErrorCode.js.map +1 -1
  72. package/lib/module/EventEmitter.js +2 -4
  73. package/lib/module/EventEmitter.js.map +1 -1
  74. package/lib/module/InterstitialAd.js +2 -5
  75. package/lib/module/InterstitialAd.js.map +1 -1
  76. package/lib/module/MRecAd.js +1 -4
  77. package/lib/module/MRecAd.js.map +1 -1
  78. package/lib/module/Privacy.js +1 -4
  79. package/lib/module/Privacy.js.map +1 -1
  80. package/lib/module/RewardedAd.js +2 -5
  81. package/lib/module/RewardedAd.js.map +1 -1
  82. package/lib/module/Utils.js +17 -0
  83. package/lib/module/Utils.js.map +1 -0
  84. package/lib/module/nativeAd/NativeAdView.js +63 -40
  85. package/lib/module/nativeAd/NativeAdView.js.map +1 -1
  86. package/lib/module/nativeAd/NativeAdViewComponents.js +53 -49
  87. package/lib/module/nativeAd/NativeAdViewComponents.js.map +1 -1
  88. package/lib/module/nativeAd/NativeAdViewProvider.js +39 -9
  89. package/lib/module/nativeAd/NativeAdViewProvider.js.map +1 -1
  90. package/lib/module/nativeAd/img/blank_icon.png +0 -0
  91. package/lib/module/specs/AppLovinMAXAdViewNativeComponent.js +7 -0
  92. package/lib/module/specs/AppLovinMAXAdViewNativeComponent.js.map +1 -0
  93. package/lib/module/specs/AppLovinMAXNativeAdViewNativeComponent.js +7 -0
  94. package/lib/module/specs/AppLovinMAXNativeAdViewNativeComponent.js.map +1 -0
  95. package/lib/module/specs/NativeAppLovinMAXModule.js +3 -0
  96. package/lib/module/specs/NativeAppLovinMAXModule.js.map +1 -0
  97. package/lib/module/types/AdInfo.js +10 -4
  98. package/lib/module/types/AdInfo.js.map +1 -1
  99. package/lib/typescript/src/AdView.d.ts +16 -16
  100. package/lib/typescript/src/AdView.d.ts.map +1 -1
  101. package/lib/typescript/src/AppLovinMAX.d.ts.map +1 -1
  102. package/lib/typescript/src/AppOpenAd.d.ts.map +1 -1
  103. package/lib/typescript/src/BannerAd.d.ts.map +1 -1
  104. package/lib/typescript/src/ErrorCode.d.ts.map +1 -1
  105. package/lib/typescript/src/EventEmitter.d.ts.map +1 -1
  106. package/lib/typescript/src/InterstitialAd.d.ts.map +1 -1
  107. package/lib/typescript/src/MRecAd.d.ts.map +1 -1
  108. package/lib/typescript/src/Privacy.d.ts.map +1 -1
  109. package/lib/typescript/src/RewardedAd.d.ts.map +1 -1
  110. package/lib/typescript/src/Utils.d.ts +16 -0
  111. package/lib/typescript/src/Utils.d.ts.map +1 -0
  112. package/lib/typescript/src/nativeAd/NativeAdView.d.ts.map +1 -1
  113. package/lib/typescript/src/nativeAd/NativeAdViewComponents.d.ts +1 -1
  114. package/lib/typescript/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -1
  115. package/lib/typescript/src/nativeAd/NativeAdViewProvider.d.ts +14 -5
  116. package/lib/typescript/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -1
  117. package/lib/typescript/src/specs/AppLovinMAXAdViewNativeComponent.d.ts +86 -0
  118. package/lib/typescript/src/specs/AppLovinMAXAdViewNativeComponent.d.ts.map +1 -0
  119. package/lib/typescript/src/specs/AppLovinMAXNativeAdViewNativeComponent.d.ts +80 -0
  120. package/lib/typescript/src/specs/AppLovinMAXNativeAdViewNativeComponent.d.ts.map +1 -0
  121. package/lib/typescript/src/specs/NativeAppLovinMAXModule.d.ts +132 -0
  122. package/lib/typescript/src/specs/NativeAppLovinMAXModule.d.ts.map +1 -0
  123. package/lib/typescript/src/types/AdEvent.d.ts +2 -2
  124. package/lib/typescript/src/types/AdEvent.d.ts.map +1 -1
  125. package/lib/typescript/src/types/AdInfo.d.ts +24 -25
  126. package/lib/typescript/src/types/AdInfo.d.ts.map +1 -1
  127. package/lib/typescript/src/types/AdProps.d.ts +4 -4
  128. package/lib/typescript/src/types/AdProps.d.ts.map +1 -1
  129. package/lib/typescript/src/types/FullscreenAd.d.ts +4 -4
  130. package/lib/typescript/src/types/FullscreenAd.d.ts.map +1 -1
  131. package/lib/typescript/src/types/NativeAd.d.ts +4 -0
  132. package/lib/typescript/src/types/NativeAd.d.ts.map +1 -1
  133. package/lib/typescript/src/types/ViewAd.d.ts +4 -4
  134. package/lib/typescript/src/types/ViewAd.d.ts.map +1 -1
  135. package/package.json +9 -1
  136. package/react-native-applovin-max.podspec +3 -3
  137. package/src/AdView.tsx +56 -121
  138. package/src/AppLovinMAX.ts +7 -8
  139. package/src/AppOpenAd.ts +3 -5
  140. package/src/BannerAd.ts +3 -5
  141. package/src/ErrorCode.ts +1 -3
  142. package/src/EventEmitter.ts +2 -3
  143. package/src/InterstitialAd.ts +4 -6
  144. package/src/MRecAd.ts +3 -5
  145. package/src/Privacy.ts +1 -3
  146. package/src/RewardedAd.ts +4 -6
  147. package/src/Utils.ts +26 -0
  148. package/src/nativeAd/NativeAdView.tsx +65 -65
  149. package/src/nativeAd/NativeAdViewComponents.tsx +32 -60
  150. package/src/nativeAd/NativeAdViewProvider.tsx +37 -12
  151. package/src/nativeAd/img/blank_icon.png +0 -0
  152. package/src/specs/AppLovinMAXAdViewNativeComponent.ts +96 -0
  153. package/src/specs/AppLovinMAXNativeAdViewNativeComponent.ts +89 -0
  154. package/src/specs/NativeAppLovinMAXModule.ts +208 -0
  155. package/src/types/AdEvent.ts +2 -2
  156. package/src/types/AdInfo.ts +28 -28
  157. package/src/types/AdProps.ts +4 -4
  158. package/src/types/FullscreenAd.ts +4 -4
  159. package/src/types/NativeAd.ts +5 -0
  160. package/src/types/ViewAd.ts +4 -4
  161. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewManager.java +0 -149
  162. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdViewManager.java +0 -163
  163. package/ios/AppLovinMAXAdView.m +0 -323
  164. package/ios/AppLovinMAXNativeAdView.m +0 -432
  165. package/ios/AppLovinMAXNativeAdViewManager.m +0 -64
@@ -49,12 +49,13 @@ import com.facebook.react.bridge.Arguments;
49
49
  import com.facebook.react.bridge.LifecycleEventListener;
50
50
  import com.facebook.react.bridge.Promise;
51
51
  import com.facebook.react.bridge.ReactApplicationContext;
52
- import com.facebook.react.bridge.ReactContextBaseJavaModule;
53
- import com.facebook.react.bridge.ReactMethod;
54
52
  import com.facebook.react.bridge.ReadableArray;
55
53
  import com.facebook.react.bridge.ReadableMap;
56
54
  import com.facebook.react.bridge.WritableArray;
57
55
  import com.facebook.react.bridge.WritableMap;
56
+ import com.facebook.react.uimanager.UIManagerHelper;
57
+ import com.facebook.react.uimanager.events.Event;
58
+ import com.facebook.react.uimanager.events.EventDispatcher;
58
59
 
59
60
  import java.util.ArrayList;
60
61
  import java.util.HashMap;
@@ -71,14 +72,13 @@ import static com.facebook.react.modules.core.DeviceEventManagerModule.RCTDevice
71
72
  /**
72
73
  * Created by Thomas So on July 11 2020
73
74
  */
74
- public class AppLovinMAXModule
75
- extends ReactContextBaseJavaModule
75
+ public class AppLovinMAXModuleImpl
76
76
  implements LifecycleEventListener,
77
77
  MaxAdListener, MaxAdViewAdListener, MaxRewardedAdListener, MaxAdRevenueListener
78
78
  {
79
79
  private static final String SDK_TAG = "AppLovinSdk";
80
80
  private static final String TAG = "AppLovinMAXModule";
81
- private static final String PLUGIN_VERSION = "8.1.1";
81
+ private static final String PLUGIN_VERSION = "9.0.0";
82
82
 
83
83
  private static final String USER_GEOGRAPHY_GDPR = "G";
84
84
  private static final String USER_GEOGRAPHY_OTHER = "O";
@@ -100,6 +100,8 @@ public class AppLovinMAXModule
100
100
 
101
101
  static
102
102
  {
103
+ ALCompatibleNativeSdkVersions.put( "9.0.0", "13.0.1" );
104
+ ALCompatibleNativeSdkVersions.put( "8.2.0", "13.0.1" );
103
105
  ALCompatibleNativeSdkVersions.put( "8.1.1", "13.0.1" );
104
106
  ALCompatibleNativeSdkVersions.put( "8.1.0", "13.0.1" );
105
107
  ALCompatibleNativeSdkVersions.put( "8.0.5", "13.0.1" );
@@ -110,12 +112,15 @@ public class AppLovinMAXModule
110
112
  ALCompatibleNativeSdkVersions.put( "8.0.0", "13.0.0" );
111
113
  }
112
114
 
113
- public static AppLovinMAXModule instance;
115
+ public static final String NAME = "AppLovinMAX";
116
+
117
+ public static AppLovinMAXModuleImpl instance;
114
118
  @Nullable
115
- private static Activity currentActivity;
119
+ private static Activity currentActivity;
116
120
 
117
121
  // Parent Fields
118
122
  private final AppLovinSdk sdk;
123
+ private final ReactApplicationContext reactContext;
119
124
  private boolean isPluginInitialized;
120
125
  private boolean isSdkInitialized;
121
126
  private AppLovinSdkConfiguration sdkConfiguration;
@@ -142,7 +147,7 @@ public class AppLovinMAXModule
142
147
  private final List<String> adUnitIdsToShowAfterCreate = new ArrayList<>( 2 );
143
148
  private final Set<String> disabledAdaptiveBannerAdUnitIds = new HashSet<>( 2 );
144
149
 
145
- public static AppLovinMAXModule getInstance()
150
+ public static AppLovinMAXModuleImpl getInstance()
146
151
  {
147
152
  return instance;
148
153
  }
@@ -152,9 +157,9 @@ public class AppLovinMAXModule
152
157
  return sdk;
153
158
  }
154
159
 
155
- public AppLovinMAXModule(final ReactApplicationContext reactContext)
160
+ public AppLovinMAXModuleImpl(final ReactApplicationContext reactApplicationContext)
156
161
  {
157
- super( reactContext );
162
+ reactContext = reactApplicationContext;
158
163
 
159
164
  // Check that plugin version is compatible with native SDK version
160
165
  String minCompatibleNativeSdkVersion = ALCompatibleNativeSdkVersions.get( PLUGIN_VERSION );
@@ -173,33 +178,24 @@ public class AppLovinMAXModule
173
178
  reactContext.addLifecycleEventListener( this );
174
179
  }
175
180
 
176
- @NonNull
177
- @Override
178
- public String getName()
179
- {
180
- return "AppLovinMAX";
181
- }
182
-
183
181
  @Nullable
184
182
  private Activity maybeGetCurrentActivity()
185
183
  {
186
184
  // React Native has a bug where `getCurrentActivity()` returns null: https://github.com/facebook/react-native/issues/18345
187
185
  // To alleviate the issue - we will store as a static reference (WeakReference unfortunately did not suffice)
188
- if ( getReactApplicationContext().hasCurrentActivity() )
186
+ if ( reactContext.hasCurrentActivity() )
189
187
  {
190
- currentActivity = getReactApplicationContext().getCurrentActivity();
188
+ currentActivity = reactContext.getCurrentActivity();
191
189
  }
192
190
 
193
191
  return currentActivity;
194
192
  }
195
193
 
196
- @ReactMethod
197
194
  public void isInitialized(final Promise promise)
198
195
  {
199
196
  promise.resolve( isPluginInitialized && isSdkInitialized );
200
197
  }
201
198
 
202
- @ReactMethod
203
199
  public void initialize(final String pluginVersion, final String sdkKey, final Promise promise)
204
200
  {
205
201
  // Guard against running init logic multiple times
@@ -219,7 +215,7 @@ public class AppLovinMAXModule
219
215
  return;
220
216
  }
221
217
 
222
- AppLovinSdkInitializationConfiguration.Builder initConfigBuidler = AppLovinSdkInitializationConfiguration.builder( sdkKey, getReactApplicationContext() );
218
+ AppLovinSdkInitializationConfiguration.Builder initConfigBuidler = AppLovinSdkInitializationConfiguration.builder( sdkKey, reactContext );
223
219
  initConfigBuidler.setPluginVersion( "React-Native-" + pluginVersion );
224
220
  initConfigBuidler.setMediationProvider( AppLovinMediationProvider.MAX );
225
221
  initConfigBuidler.setSegmentCollection( segmentCollectionBuilder.build() );
@@ -241,12 +237,12 @@ public class AppLovinMAXModule
241
237
  sdkConfiguration = appLovinSdkConfiguration;
242
238
  isSdkInitialized = true;
243
239
 
244
- windowManager = (WindowManager) getReactApplicationContext().getSystemService( Context.WINDOW_SERVICE );
240
+ windowManager = (WindowManager) reactContext.getSystemService( Context.WINDOW_SERVICE );
245
241
 
246
242
  lastRotation = windowManager.getDefaultDisplay().getRotation();
247
243
 
248
244
  // Enable orientation change listener, so that the ad view positions can be updated when the device is rotated.
249
- new OrientationEventListener( getReactApplicationContext() )
245
+ new OrientationEventListener( reactContext )
250
246
  {
251
247
  @Override
252
248
  public void onOrientationChanged(final int orientation)
@@ -283,15 +279,13 @@ public class AppLovinMAXModule
283
279
 
284
280
  // General Public API
285
281
 
286
- @ReactMethod
287
282
  public void isTablet(final Promise promise)
288
283
  {
289
284
  Activity currentActivity = maybeGetCurrentActivity();
290
- Context contextToUse = ( currentActivity != null ) ? currentActivity : getReactApplicationContext();
285
+ Context contextToUse = ( currentActivity != null ) ? currentActivity : reactContext;
291
286
  promise.resolve( AppLovinSdkUtils.isTablet( contextToUse ) );
292
287
  }
293
288
 
294
- @ReactMethod
295
289
  public void showMediationDebugger()
296
290
  {
297
291
  if ( !isSdkInitialized )
@@ -303,61 +297,51 @@ public class AppLovinMAXModule
303
297
  sdk.showMediationDebugger();
304
298
  }
305
299
 
306
- @ReactMethod
307
300
  public void setHasUserConsent(final boolean hasUserConsent)
308
301
  {
309
- AppLovinPrivacySettings.setHasUserConsent( hasUserConsent, getReactApplicationContext() );
302
+ AppLovinPrivacySettings.setHasUserConsent( hasUserConsent, reactContext );
310
303
  }
311
304
 
312
- @ReactMethod
313
305
  public void hasUserConsent(final Promise promise)
314
306
  {
315
- promise.resolve( AppLovinPrivacySettings.hasUserConsent( getReactApplicationContext() ) );
307
+ promise.resolve( AppLovinPrivacySettings.hasUserConsent( reactContext ) );
316
308
  }
317
309
 
318
- @ReactMethod
319
310
  public void setDoNotSell(final boolean doNotSell)
320
311
  {
321
- AppLovinPrivacySettings.setDoNotSell( doNotSell, getReactApplicationContext() );
312
+ AppLovinPrivacySettings.setDoNotSell( doNotSell, reactContext );
322
313
  }
323
314
 
324
- @ReactMethod
325
315
  public void isDoNotSell(final Promise promise)
326
316
  {
327
- promise.resolve( AppLovinPrivacySettings.isDoNotSell( getReactApplicationContext() ) );
317
+ promise.resolve( AppLovinPrivacySettings.isDoNotSell( reactContext ) );
328
318
  }
329
319
 
330
- @ReactMethod
331
320
  public void setUserId(final String userId)
332
321
  {
333
322
  sdk.getSettings().setUserIdentifier( userId );
334
323
  }
335
324
 
336
- @ReactMethod
337
325
  public void setMuted(final boolean muted)
338
326
  {
339
327
  sdk.getSettings().setMuted( muted );
340
328
  }
341
329
 
342
- @ReactMethod
343
330
  public void isMuted(final Promise promise)
344
331
  {
345
332
  promise.resolve( sdk.getSettings().isMuted() );
346
333
  }
347
334
 
348
- @ReactMethod
349
335
  public void setVerboseLogging(final boolean enabled)
350
336
  {
351
337
  sdk.getSettings().setVerboseLogging( enabled );
352
338
  }
353
339
 
354
- @ReactMethod
355
340
  public void setCreativeDebuggerEnabled(final boolean enabled)
356
341
  {
357
342
  sdk.getSettings().setCreativeDebuggerEnabled( enabled );
358
343
  }
359
344
 
360
- @ReactMethod
361
345
  public void setTestDeviceAdvertisingIds(final ReadableArray rawAdvertisingIds)
362
346
  {
363
347
  List<String> advertisingIds = new ArrayList<>( rawAdvertisingIds.size() );
@@ -371,7 +355,6 @@ public class AppLovinMAXModule
371
355
  testDeviceAdvertisingIdsToSet = advertisingIds;
372
356
  }
373
357
 
374
- @ReactMethod
375
358
  public void setExtraParameter(final String key, @Nullable final String value)
376
359
  {
377
360
  if ( TextUtils.isEmpty( key ) )
@@ -383,7 +366,6 @@ public class AppLovinMAXModule
383
366
  sdk.getSettings().setExtraParameter( key, value );
384
367
  }
385
368
 
386
- @ReactMethod
387
369
  public void setInitializationAdUnitIds(final ReadableArray rawAdUnitIds)
388
370
  {
389
371
  initializationAdUnitIdsToSet = new ArrayList<>( rawAdUnitIds.size() );
@@ -397,31 +379,26 @@ public class AppLovinMAXModule
397
379
 
398
380
  // MAX Terms and Privacy Policy Flow
399
381
 
400
- @ReactMethod
401
382
  public void setTermsAndPrivacyPolicyFlowEnabled(final boolean enabled)
402
383
  {
403
384
  sdk.getSettings().getTermsAndPrivacyPolicyFlowSettings().setEnabled( enabled );
404
385
  }
405
386
 
406
- @ReactMethod
407
387
  public void setPrivacyPolicyUrl(final String urlString)
408
388
  {
409
389
  sdk.getSettings().getTermsAndPrivacyPolicyFlowSettings().setPrivacyPolicyUri( Uri.parse( urlString ) );
410
390
  }
411
391
 
412
- @ReactMethod
413
392
  public void setTermsOfServiceUrl(final String urlString)
414
393
  {
415
394
  sdk.getSettings().getTermsAndPrivacyPolicyFlowSettings().setTermsOfServiceUri( Uri.parse( urlString ) );
416
395
  }
417
396
 
418
- @ReactMethod
419
397
  public void setConsentFlowDebugUserGeography(final String userGeography)
420
398
  {
421
399
  sdk.getSettings().getTermsAndPrivacyPolicyFlowSettings().setDebugUserGeography( getAppLovinConsentFlowUserGeography( userGeography ) );
422
400
  }
423
401
 
424
- @ReactMethod
425
402
  public void showCmpForExistingUser(final Promise promise)
426
403
  {
427
404
  if ( !isPluginInitialized )
@@ -454,7 +431,6 @@ public class AppLovinMAXModule
454
431
  } );
455
432
  }
456
433
 
457
- @ReactMethod
458
434
  public void hasSupportedCmp(final Promise promise)
459
435
  {
460
436
  if ( !isPluginInitialized )
@@ -468,7 +444,6 @@ public class AppLovinMAXModule
468
444
 
469
445
  // Segment Targeting
470
446
 
471
- @ReactMethod
472
447
  public void addSegment(final int key, final ReadableArray values, final Promise promise)
473
448
  {
474
449
  if ( isPluginInitialized )
@@ -502,7 +477,6 @@ public class AppLovinMAXModule
502
477
  promise.resolve( null );
503
478
  }
504
479
 
505
- @ReactMethod
506
480
  public void getSegments(final Promise promise)
507
481
  {
508
482
  if ( !isSdkInitialized )
@@ -532,7 +506,6 @@ public class AppLovinMAXModule
532
506
 
533
507
  // EVENT TRACKING
534
508
 
535
- @ReactMethod
536
509
  public void trackEvent(final String event, final ReadableMap parameters)
537
510
  {
538
511
  // Convert Map<String, Object> type of `parameters.toHashMap()` to Map<String, String>
@@ -551,7 +524,6 @@ public class AppLovinMAXModule
551
524
 
552
525
  // BANNERS
553
526
 
554
- @ReactMethod
555
527
  public void createBanner(final String adUnitId, final String bannerPosition)
556
528
  {
557
529
  if ( sdk == null )
@@ -563,7 +535,7 @@ public class AppLovinMAXModule
563
535
  createAdView( adUnitId, getDeviceSpecificBannerAdViewAdFormat(), bannerPosition, DEFAULT_AD_VIEW_OFFSET );
564
536
  }
565
537
 
566
- @ReactMethod // NOTE: No function overloading in JS so we need new method signature
538
+ // NOTE: No function overloading in JS so we need new method signature
567
539
  public void createBannerWithOffsets(final String adUnitId, final String bannerPosition, final float x, final float y)
568
540
  {
569
541
  if ( sdk == null )
@@ -572,10 +544,9 @@ public class AppLovinMAXModule
572
544
  return;
573
545
  }
574
546
 
575
- createAdView( adUnitId, getDeviceSpecificBannerAdViewAdFormat(), bannerPosition, getOffsetPixels( x, y, getReactApplicationContext() ) );
547
+ createAdView( adUnitId, getDeviceSpecificBannerAdViewAdFormat(), bannerPosition, getOffsetPixels( x, y, reactContext ) );
576
548
  }
577
549
 
578
- @ReactMethod
579
550
  public void setBannerBackgroundColor(final String adUnitId, final String hexColorCode)
580
551
  {
581
552
  if ( sdk == null )
@@ -587,7 +558,6 @@ public class AppLovinMAXModule
587
558
  setAdViewBackgroundColor( adUnitId, getDeviceSpecificBannerAdViewAdFormat(), hexColorCode );
588
559
  }
589
560
 
590
- @ReactMethod
591
561
  public void setBannerPlacement(final String adUnitId, final String placement)
592
562
  {
593
563
  if ( sdk == null )
@@ -599,7 +569,6 @@ public class AppLovinMAXModule
599
569
  setAdViewPlacement( adUnitId, getDeviceSpecificBannerAdViewAdFormat(), placement );
600
570
  }
601
571
 
602
- @ReactMethod
603
572
  public void setBannerCustomData(final String adUnitId, final String customData)
604
573
  {
605
574
  if ( sdk == null )
@@ -611,7 +580,6 @@ public class AppLovinMAXModule
611
580
  setAdViewCustomData( adUnitId, getDeviceSpecificBannerAdViewAdFormat(), customData );
612
581
  }
613
582
 
614
- @ReactMethod
615
583
  public void setBannerWidth(final String adUnitId, final int widthDp)
616
584
  {
617
585
  if ( sdk == null )
@@ -623,7 +591,6 @@ public class AppLovinMAXModule
623
591
  setAdViewWidth( adUnitId, widthDp, getDeviceSpecificBannerAdViewAdFormat() );
624
592
  }
625
593
 
626
- @ReactMethod
627
594
  public void updateBannerPosition(final String adUnitId, final String bannerPosition)
628
595
  {
629
596
  if ( sdk == null )
@@ -635,7 +602,6 @@ public class AppLovinMAXModule
635
602
  updateAdViewPosition( adUnitId, bannerPosition, DEFAULT_AD_VIEW_OFFSET, getDeviceSpecificBannerAdViewAdFormat() );
636
603
  }
637
604
 
638
- @ReactMethod
639
605
  public void updateBannerOffsets(final String adUnitId, final float x, final float y)
640
606
  {
641
607
  if ( sdk == null )
@@ -644,11 +610,10 @@ public class AppLovinMAXModule
644
610
  return;
645
611
  }
646
612
 
647
- updateAdViewPosition( adUnitId, adViewPositions.get( adUnitId ), getOffsetPixels( x, y, getReactApplicationContext() ), getDeviceSpecificBannerAdViewAdFormat() );
613
+ updateAdViewPosition( adUnitId, adViewPositions.get( adUnitId ), getOffsetPixels( x, y, reactContext ), getDeviceSpecificBannerAdViewAdFormat() );
648
614
  }
649
615
 
650
- @ReactMethod
651
- public void setBannerExtraParameter(final String adUnitId, final String key, final String value)
616
+ public void setBannerExtraParameter(final String adUnitId, final String key, @Nullable final String value)
652
617
  {
653
618
  if ( sdk == null )
654
619
  {
@@ -659,14 +624,12 @@ public class AppLovinMAXModule
659
624
  setAdViewExtraParameters( adUnitId, getDeviceSpecificBannerAdViewAdFormat(), key, value );
660
625
  }
661
626
 
662
- @ReactMethod
663
627
  public void setBannerLocalExtraParameter(final String adUnitId, final ReadableMap parameterMap)
664
628
  {
665
629
  Map.Entry<String, Object> entry = parameterMap.getEntryIterator().next();
666
630
  setAdViewLocalExtraParameters( adUnitId, getDeviceSpecificBannerAdViewAdFormat(), entry.getKey(), entry.getValue() );
667
631
  }
668
632
 
669
- @ReactMethod
670
633
  public void startBannerAutoRefresh(final String adUnitId)
671
634
  {
672
635
  if ( sdk == null )
@@ -678,7 +641,6 @@ public class AppLovinMAXModule
678
641
  startAutoRefresh( adUnitId, getDeviceSpecificBannerAdViewAdFormat() );
679
642
  }
680
643
 
681
- @ReactMethod
682
644
  public void stopBannerAutoRefresh(final String adUnitId)
683
645
  {
684
646
  if ( sdk == null )
@@ -690,7 +652,6 @@ public class AppLovinMAXModule
690
652
  stopAutoRefresh( adUnitId, getDeviceSpecificBannerAdViewAdFormat() );
691
653
  }
692
654
 
693
- @ReactMethod
694
655
  public void showBanner(final String adUnitId)
695
656
  {
696
657
  if ( sdk == null )
@@ -702,7 +663,6 @@ public class AppLovinMAXModule
702
663
  showAdView( adUnitId, getDeviceSpecificBannerAdViewAdFormat() );
703
664
  }
704
665
 
705
- @ReactMethod
706
666
  public void hideBanner(final String adUnitId)
707
667
  {
708
668
  if ( sdk == null )
@@ -714,7 +674,6 @@ public class AppLovinMAXModule
714
674
  hideAdView( adUnitId, getDeviceSpecificBannerAdViewAdFormat() );
715
675
  }
716
676
 
717
- @ReactMethod
718
677
  public void destroyBanner(final String adUnitId)
719
678
  {
720
679
  if ( sdk == null )
@@ -726,15 +685,13 @@ public class AppLovinMAXModule
726
685
  destroyAdView( adUnitId, getDeviceSpecificBannerAdViewAdFormat() );
727
686
  }
728
687
 
729
- @ReactMethod
730
688
  public void getAdaptiveBannerHeightForWidth(final float width, final Promise promise)
731
689
  {
732
- promise.resolve( getDeviceSpecificBannerAdViewAdFormat().getAdaptiveSize( (int) width, getReactApplicationContext() ).getHeight() );
690
+ promise.resolve( getDeviceSpecificBannerAdViewAdFormat().getAdaptiveSize( (int) width, reactContext ).getHeight() );
733
691
  }
734
692
 
735
693
  // MRECS
736
694
 
737
- @ReactMethod
738
695
  public void createMRec(final String adUnitId, final String mrecPosition)
739
696
  {
740
697
  if ( sdk == null )
@@ -746,8 +703,7 @@ public class AppLovinMAXModule
746
703
  createAdView( adUnitId, MaxAdFormat.MREC, mrecPosition, DEFAULT_AD_VIEW_OFFSET );
747
704
  }
748
705
 
749
- @ReactMethod
750
- public void setMRecPlacement(final String adUnitId, final String placement)
706
+ public void setMRecPlacement(final String adUnitId, @Nullable final String placement)
751
707
  {
752
708
  if ( sdk == null )
753
709
  {
@@ -758,8 +714,7 @@ public class AppLovinMAXModule
758
714
  setAdViewPlacement( adUnitId, MaxAdFormat.MREC, placement );
759
715
  }
760
716
 
761
- @ReactMethod
762
- public void setMRecCustomData(final String adUnitId, final String customData)
717
+ public void setMRecCustomData(final String adUnitId, @Nullable final String customData)
763
718
  {
764
719
  if ( sdk == null )
765
720
  {
@@ -770,7 +725,6 @@ public class AppLovinMAXModule
770
725
  setAdViewCustomData( adUnitId, MaxAdFormat.MREC, customData );
771
726
  }
772
727
 
773
- @ReactMethod
774
728
  public void updateMRecPosition(final String adUnitId, final String mrecPosition)
775
729
  {
776
730
  if ( sdk == null )
@@ -782,20 +736,17 @@ public class AppLovinMAXModule
782
736
  updateAdViewPosition( adUnitId, mrecPosition, DEFAULT_AD_VIEW_OFFSET, MaxAdFormat.MREC );
783
737
  }
784
738
 
785
- @ReactMethod
786
- public void setMRecExtraParameter(final String adUnitId, final String key, final String value)
739
+ public void setMRecExtraParameter(final String adUnitId, final String key, @Nullable final String value)
787
740
  {
788
741
  setAdViewExtraParameters( adUnitId, MaxAdFormat.MREC, key, value );
789
742
  }
790
743
 
791
- @ReactMethod
792
744
  public void setMRecLocalExtraParameter(final String adUnitId, final ReadableMap parameterMap)
793
745
  {
794
746
  Map.Entry<String, Object> entry = parameterMap.getEntryIterator().next();
795
747
  setAdViewLocalExtraParameters( adUnitId, MaxAdFormat.MREC, entry.getKey(), entry.getValue() );
796
748
  }
797
749
 
798
- @ReactMethod
799
750
  public void startMRecAutoRefresh(final String adUnitId)
800
751
  {
801
752
  if ( sdk == null )
@@ -807,7 +758,6 @@ public class AppLovinMAXModule
807
758
  startAutoRefresh( adUnitId, MaxAdFormat.MREC );
808
759
  }
809
760
 
810
- @ReactMethod
811
761
  public void stopMRecAutoRefresh(final String adUnitId)
812
762
  {
813
763
  if ( sdk == null )
@@ -819,7 +769,6 @@ public class AppLovinMAXModule
819
769
  stopAutoRefresh( adUnitId, MaxAdFormat.MREC );
820
770
  }
821
771
 
822
- @ReactMethod
823
772
  public void showMRec(final String adUnitId)
824
773
  {
825
774
  if ( sdk == null )
@@ -831,7 +780,6 @@ public class AppLovinMAXModule
831
780
  showAdView( adUnitId, MaxAdFormat.MREC );
832
781
  }
833
782
 
834
- @ReactMethod
835
783
  public void hideMRec(final String adUnitId)
836
784
  {
837
785
  if ( sdk == null )
@@ -843,7 +791,6 @@ public class AppLovinMAXModule
843
791
  hideAdView( adUnitId, MaxAdFormat.MREC );
844
792
  }
845
793
 
846
- @ReactMethod
847
794
  public void destroyMRec(final String adUnitId)
848
795
  {
849
796
  if ( sdk == null )
@@ -857,7 +804,6 @@ public class AppLovinMAXModule
857
804
 
858
805
  // INTERSTITIALS
859
806
 
860
- @ReactMethod
861
807
  public void loadInterstitial(final String adUnitId)
862
808
  {
863
809
  if ( sdk == null )
@@ -876,7 +822,6 @@ public class AppLovinMAXModule
876
822
  interstitial.loadAd();
877
823
  }
878
824
 
879
- @ReactMethod
880
825
  public void isInterstitialReady(final String adUnitId, final Promise promise)
881
826
  {
882
827
  if ( sdk == null )
@@ -896,8 +841,7 @@ public class AppLovinMAXModule
896
841
  promise.resolve( interstitial.isReady() );
897
842
  }
898
843
 
899
- @ReactMethod
900
- public void showInterstitial(final String adUnitId, final String placement, final String customData)
844
+ public void showInterstitial(final String adUnitId, @Nullable final String placement, @Nullable final String customData)
901
845
  {
902
846
  if ( sdk == null )
903
847
  {
@@ -915,8 +859,7 @@ public class AppLovinMAXModule
915
859
  interstitial.showAd( placement, customData );
916
860
  }
917
861
 
918
- @ReactMethod
919
- public void setInterstitialExtraParameter(final String adUnitId, final String key, final String value)
862
+ public void setInterstitialExtraParameter(final String adUnitId, final String key, @Nullable final String value)
920
863
  {
921
864
  if ( sdk == null )
922
865
  {
@@ -930,7 +873,6 @@ public class AppLovinMAXModule
930
873
  interstitial.setExtraParameter( key, value );
931
874
  }
932
875
 
933
- @ReactMethod
934
876
  public void setInterstitialLocalExtraParameter(final String adUnitId, final ReadableMap parameterMap)
935
877
  {
936
878
  if ( sdk == null )
@@ -948,7 +890,6 @@ public class AppLovinMAXModule
948
890
 
949
891
  // REWARDED
950
892
 
951
- @ReactMethod
952
893
  public void loadRewardedAd(final String adUnitId)
953
894
  {
954
895
  if ( sdk == null )
@@ -967,7 +908,6 @@ public class AppLovinMAXModule
967
908
  rewardedAd.loadAd();
968
909
  }
969
910
 
970
- @ReactMethod
971
911
  public void isRewardedAdReady(final String adUnitId, final Promise promise)
972
912
  {
973
913
  if ( sdk == null )
@@ -987,8 +927,7 @@ public class AppLovinMAXModule
987
927
  promise.resolve( rewardedAd.isReady() );
988
928
  }
989
929
 
990
- @ReactMethod
991
- public void showRewardedAd(final String adUnitId, final String placement, final String customData)
930
+ public void showRewardedAd(final String adUnitId, @Nullable final String placement, @Nullable final String customData)
992
931
  {
993
932
  if ( sdk == null )
994
933
  {
@@ -1006,8 +945,7 @@ public class AppLovinMAXModule
1006
945
  rewardedAd.showAd( placement, customData );
1007
946
  }
1008
947
 
1009
- @ReactMethod
1010
- public void setRewardedAdExtraParameter(final String adUnitId, final String key, final String value)
948
+ public void setRewardedAdExtraParameter(final String adUnitId, final String key, @Nullable final String value)
1011
949
  {
1012
950
  if ( sdk == null )
1013
951
  {
@@ -1021,7 +959,6 @@ public class AppLovinMAXModule
1021
959
  rewardedAd.setExtraParameter( key, value );
1022
960
  }
1023
961
 
1024
- @ReactMethod
1025
962
  public void setRewardedAdLocalExtraParameter(final String adUnitId, final ReadableMap parameterMap)
1026
963
  {
1027
964
  if ( sdk == null )
@@ -1039,7 +976,6 @@ public class AppLovinMAXModule
1039
976
 
1040
977
  // APP OPEN AD
1041
978
 
1042
- @ReactMethod
1043
979
  public void loadAppOpenAd(final String adUnitId)
1044
980
  {
1045
981
  if ( sdk == null )
@@ -1052,7 +988,6 @@ public class AppLovinMAXModule
1052
988
  appOpenAd.loadAd();
1053
989
  }
1054
990
 
1055
- @ReactMethod
1056
991
  public void isAppOpenAdReady(final String adUnitId, final Promise promise)
1057
992
  {
1058
993
  if ( sdk == null )
@@ -1066,7 +1001,6 @@ public class AppLovinMAXModule
1066
1001
  promise.resolve( appOpenAd.isReady() );
1067
1002
  }
1068
1003
 
1069
- @ReactMethod
1070
1004
  public void showAppOpenAd(final String adUnitId, @Nullable final String placement, @Nullable final String customData)
1071
1005
  {
1072
1006
  if ( sdk == null )
@@ -1079,8 +1013,7 @@ public class AppLovinMAXModule
1079
1013
  appOpenAd.showAd( placement, customData );
1080
1014
  }
1081
1015
 
1082
- @ReactMethod
1083
- public void setAppOpenAdExtraParameter(final String adUnitId, final String key, final String value)
1016
+ public void setAppOpenAdExtraParameter(final String adUnitId, final String key, @Nullable final String value)
1084
1017
  {
1085
1018
  if ( sdk == null )
1086
1019
  {
@@ -1092,7 +1025,6 @@ public class AppLovinMAXModule
1092
1025
  appOpenAd.setExtraParameter( key, value );
1093
1026
  }
1094
1027
 
1095
- @ReactMethod
1096
1028
  public void setAppOpenAdLocalExtraParameter(final String adUnitId, final ReadableMap parameterMap)
1097
1029
  {
1098
1030
  MaxAppOpenAd appOpenAd = retrieveAppOpenAd( adUnitId );
@@ -1102,16 +1034,15 @@ public class AppLovinMAXModule
1102
1034
 
1103
1035
  // ADVIEW PRELOADING
1104
1036
 
1105
- @ReactMethod
1106
- public void preloadNativeUIComponentAdView(final String adUnitId, final String adFormatStr, final String placement, final String customData, final ReadableMap extraParameterMap, final ReadableMap localExtraParameterMap, final Promise promise)
1037
+ public void preloadNativeUIComponentAdView(final String adUnitId, final String adFormatStr, @Nullable final String placement, @Nullable final String customData, @Nullable final ReadableMap extraParameterMap, @Nullable final ReadableMap localExtraParameterMap, final Promise promise)
1107
1038
  {
1108
1039
  MaxAdFormat adFormat;
1109
1040
 
1110
- if ( MaxAdFormat.BANNER.getLabel().equals( adFormatStr ) )
1041
+ if ( "BANNER".equalsIgnoreCase( adFormatStr ) )
1111
1042
  {
1112
1043
  adFormat = getDeviceSpecificBannerAdViewAdFormat();
1113
1044
  }
1114
- else if ( MaxAdFormat.MREC.getLabel().equals( adFormatStr ) )
1045
+ else if ( "MREC".equalsIgnoreCase( adFormatStr ) )
1115
1046
  {
1116
1047
  adFormat = MaxAdFormat.MREC;
1117
1048
  }
@@ -1125,20 +1056,20 @@ public class AppLovinMAXModule
1125
1056
  final Map<String, Object> extraParameters = ( extraParameterMap != null ) ? extraParameterMap.toHashMap() : null;
1126
1057
  final Map<String, Object> localExtraParameters = ( localExtraParameterMap != null ) ? localExtraParameterMap.toHashMap() : null;
1127
1058
 
1128
- getReactApplicationContext().runOnUiQueueThread( () -> AppLovinMAXAdView.preloadNativeUIComponentAdView( adUnitId,
1129
- finalAdFormat,
1130
- placement,
1131
- customData,
1132
- extraParameters,
1133
- localExtraParameters,
1134
- promise,
1135
- getReactApplicationContext() ) );
1059
+ reactContext.runOnUiQueueThread( () -> AppLovinMAXAdView.preloadNativeUIComponentAdView( adUnitId,
1060
+ finalAdFormat,
1061
+ placement,
1062
+ customData,
1063
+ extraParameters,
1064
+ localExtraParameters,
1065
+ promise,
1066
+ reactContext ) );
1136
1067
  }
1137
1068
 
1138
- @ReactMethod
1069
+
1139
1070
  public void destroyNativeUIComponentAdView(final int adViewId, final Promise promise)
1140
1071
  {
1141
- getReactApplicationContext().runOnUiQueueThread( () -> AppLovinMAXAdView.destroyNativeUIComponentAdView( adViewId, promise ) );
1072
+ reactContext.runOnUiQueueThread( () -> AppLovinMAXAdView.destroyNativeUIComponentAdView( adViewId, promise ) );
1142
1073
  }
1143
1074
 
1144
1075
  // AD CALLBACKS
@@ -1391,7 +1322,7 @@ public class AppLovinMAXModule
1391
1322
  return;
1392
1323
  }
1393
1324
 
1394
- sendReactNativeEvent( name, getAdRevenueInfo( ad ) );
1325
+ sendReactNativeEvent( name, getAdInfo( ad ) );
1395
1326
  }
1396
1327
 
1397
1328
  @Override
@@ -1418,7 +1349,7 @@ public class AppLovinMAXModule
1418
1349
  private void createAdView(final String adUnitId, final MaxAdFormat adFormat, final String adViewPosition, final Point adViewOffsetPixels)
1419
1350
  {
1420
1351
  // Run on main thread to ensure there are no concurrency issues with other ad view methods
1421
- getReactApplicationContext().runOnUiQueueThread( () -> {
1352
+ reactContext.runOnUiQueueThread( () -> {
1422
1353
 
1423
1354
  d( "Creating " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\", position: \"" + adViewPosition + "\", and offset: " + adViewOffsetPixels );
1424
1355
 
@@ -1454,7 +1385,7 @@ public class AppLovinMAXModule
1454
1385
 
1455
1386
  private void setAdViewPlacement(final String adUnitId, final MaxAdFormat adFormat, final String placement)
1456
1387
  {
1457
- getReactApplicationContext().runOnUiQueueThread( () -> {
1388
+ reactContext.runOnUiQueueThread( () -> {
1458
1389
 
1459
1390
  d( "Setting placement \"" + placement + "\" for " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1460
1391
 
@@ -1471,7 +1402,7 @@ public class AppLovinMAXModule
1471
1402
 
1472
1403
  private void setAdViewCustomData(final String adUnitId, final MaxAdFormat adFormat, final String customData)
1473
1404
  {
1474
- getReactApplicationContext().runOnUiQueueThread( () -> {
1405
+ reactContext.runOnUiQueueThread( () -> {
1475
1406
 
1476
1407
  d( "Setting custom data \"" + customData + "\" for " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1477
1408
 
@@ -1488,7 +1419,7 @@ public class AppLovinMAXModule
1488
1419
 
1489
1420
  private void setAdViewWidth(final String adUnitId, final int widthDp, final MaxAdFormat adFormat)
1490
1421
  {
1491
- getReactApplicationContext().runOnUiQueueThread( () -> {
1422
+ reactContext.runOnUiQueueThread( () -> {
1492
1423
 
1493
1424
  d( "Setting width " + widthDp + " for \"" + adFormat + "\" with ad unit identifier \"" + adUnitId + "\"" );
1494
1425
 
@@ -1505,7 +1436,7 @@ public class AppLovinMAXModule
1505
1436
 
1506
1437
  private void updateAdViewPosition(final String adUnitId, final String adViewPosition, final Point offsetPixels, final MaxAdFormat adFormat)
1507
1438
  {
1508
- getReactApplicationContext().runOnUiQueueThread( () -> {
1439
+ reactContext.runOnUiQueueThread( () -> {
1509
1440
 
1510
1441
  d( "Updating " + adFormat.getLabel() + " position to \"" + adViewPosition + "\" for ad unit id \"" + adUnitId + "\"" );
1511
1442
 
@@ -1525,7 +1456,7 @@ public class AppLovinMAXModule
1525
1456
 
1526
1457
  private void showAdView(final String adUnitId, final MaxAdFormat adFormat)
1527
1458
  {
1528
- getReactApplicationContext().runOnUiQueueThread( () -> {
1459
+ reactContext.runOnUiQueueThread( () -> {
1529
1460
 
1530
1461
  d( "Showing " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1531
1462
 
@@ -1548,7 +1479,7 @@ public class AppLovinMAXModule
1548
1479
 
1549
1480
  private void hideAdView(final String adUnitId, final MaxAdFormat adFormat)
1550
1481
  {
1551
- getReactApplicationContext().runOnUiQueueThread( () -> {
1482
+ reactContext.runOnUiQueueThread( () -> {
1552
1483
 
1553
1484
  d( "Hiding " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1554
1485
  adUnitIdsToShowAfterCreate.remove( adUnitId );
@@ -1567,7 +1498,7 @@ public class AppLovinMAXModule
1567
1498
 
1568
1499
  private void destroyAdView(final String adUnitId, final MaxAdFormat adFormat)
1569
1500
  {
1570
- getReactApplicationContext().runOnUiQueueThread( () -> {
1501
+ reactContext.runOnUiQueueThread( () -> {
1571
1502
 
1572
1503
  d( "Destroying " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1573
1504
 
@@ -1598,7 +1529,7 @@ public class AppLovinMAXModule
1598
1529
 
1599
1530
  private void setAdViewBackgroundColor(final String adUnitId, final MaxAdFormat adFormat, final String hexColorCode)
1600
1531
  {
1601
- getReactApplicationContext().runOnUiQueueThread( () -> {
1532
+ reactContext.runOnUiQueueThread( () -> {
1602
1533
 
1603
1534
  d( "Setting " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\" to color: " + hexColorCode );
1604
1535
 
@@ -1615,7 +1546,7 @@ public class AppLovinMAXModule
1615
1546
 
1616
1547
  private void setAdViewExtraParameters(final String adUnitId, final MaxAdFormat adFormat, final String key, final String value)
1617
1548
  {
1618
- getReactApplicationContext().runOnUiQueueThread( () -> {
1549
+ reactContext.runOnUiQueueThread( () -> {
1619
1550
 
1620
1551
  d( "Setting " + adFormat.getLabel() + " extra with key: \"" + key + "\" value: " + value );
1621
1552
 
@@ -1666,7 +1597,7 @@ public class AppLovinMAXModule
1666
1597
 
1667
1598
  private void setAdViewLocalExtraParameters(final String adUnitId, final MaxAdFormat adFormat, final String key, final Object value)
1668
1599
  {
1669
- getReactApplicationContext().runOnUiQueueThread( () -> {
1600
+ reactContext.runOnUiQueueThread( () -> {
1670
1601
 
1671
1602
  d( "Setting " + adFormat.getLabel() + " local extra with key: \"" + key + "\" value: " + value );
1672
1603
 
@@ -1684,7 +1615,7 @@ public class AppLovinMAXModule
1684
1615
 
1685
1616
  private void startAutoRefresh(final String adUnitId, final MaxAdFormat adFormat)
1686
1617
  {
1687
- getReactApplicationContext().runOnUiQueueThread( () -> {
1618
+ reactContext.runOnUiQueueThread( () -> {
1688
1619
 
1689
1620
  d( "Starting auto refresh " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1690
1621
 
@@ -1701,7 +1632,7 @@ public class AppLovinMAXModule
1701
1632
 
1702
1633
  private void stopAutoRefresh(final String adUnitId, final MaxAdFormat adFormat)
1703
1634
  {
1704
- getReactApplicationContext().runOnUiQueueThread( () -> {
1635
+ reactContext.runOnUiQueueThread( () -> {
1705
1636
 
1706
1637
  d( "Stopping auto refresh " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1707
1638
 
@@ -1723,7 +1654,7 @@ public class AppLovinMAXModule
1723
1654
  final Activity currentActivity = maybeGetCurrentActivity();
1724
1655
  if ( currentActivity != null )
1725
1656
  {
1726
- final RelativeLayout relativeLayout = new RelativeLayout( getReactApplicationContext() );
1657
+ final RelativeLayout relativeLayout = new RelativeLayout( reactContext );
1727
1658
  relativeLayout.addView( adView );
1728
1659
 
1729
1660
  currentActivity.addContentView( relativeLayout, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT,
@@ -1803,7 +1734,7 @@ public class AppLovinMAXModule
1803
1734
  MaxAdView result = adViews.get( adUnitId );
1804
1735
  if ( result == null && adViewPosition != null && adViewOffsetPixels != null )
1805
1736
  {
1806
- result = new MaxAdView( adUnitId, adFormat, sdk, getReactApplicationContext() );
1737
+ result = new MaxAdView( adUnitId, adFormat, sdk, reactContext );
1807
1738
  result.setListener( this );
1808
1739
  result.setRevenueListener( this );
1809
1740
 
@@ -1861,7 +1792,7 @@ public class AppLovinMAXModule
1861
1792
  else if ( TOP_CENTER.equalsIgnoreCase( adViewPosition ) || BOTTOM_CENTER.equalsIgnoreCase( adViewPosition ) )
1862
1793
  {
1863
1794
  int adViewWidthPx = windowRect.width();
1864
- adViewWidthDp = AppLovinSdkUtils.pxToDp( getReactApplicationContext(), adViewWidthPx );
1795
+ adViewWidthDp = AppLovinSdkUtils.pxToDp( reactContext, adViewWidthPx );
1865
1796
  }
1866
1797
  // Else use standard widths of 320, 728, or 300
1867
1798
  else
@@ -1876,15 +1807,15 @@ public class AppLovinMAXModule
1876
1807
 
1877
1808
  if ( ( adFormat == MaxAdFormat.BANNER || adFormat == MaxAdFormat.LEADER ) && !isAdaptiveBannerDisabled )
1878
1809
  {
1879
- adViewHeightDp = adFormat.getAdaptiveSize( adViewWidthDp, getReactApplicationContext() ).getHeight();
1810
+ adViewHeightDp = adFormat.getAdaptiveSize( adViewWidthDp, reactContext ).getHeight();
1880
1811
  }
1881
1812
  else
1882
1813
  {
1883
1814
  adViewHeightDp = adFormat.getSize().getHeight();
1884
1815
  }
1885
1816
 
1886
- final int widthPx = AppLovinSdkUtils.dpToPx( getReactApplicationContext(), adViewWidthDp );
1887
- final int heightPx = AppLovinSdkUtils.dpToPx( getReactApplicationContext(), adViewHeightDp );
1817
+ final int widthPx = AppLovinSdkUtils.dpToPx( reactContext, adViewWidthDp );
1818
+ final int heightPx = AppLovinSdkUtils.dpToPx( reactContext, adViewHeightDp );
1888
1819
 
1889
1820
  final RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) adView.getLayoutParams();
1890
1821
  params.height = heightPx;
@@ -2006,7 +1937,7 @@ public class AppLovinMAXModule
2006
1937
 
2007
1938
  private MaxAdFormat getDeviceSpecificBannerAdViewAdFormat()
2008
1939
  {
2009
- return getDeviceSpecificBannerAdViewAdFormat( getReactApplicationContext() );
1940
+ return getDeviceSpecificBannerAdViewAdFormat( reactContext );
2010
1941
  }
2011
1942
 
2012
1943
  public static MaxAdFormat getDeviceSpecificBannerAdViewAdFormat(final Context context)
@@ -2053,11 +1984,16 @@ public class AppLovinMAXModule
2053
1984
  {
2054
1985
  WritableMap adInfo = Arguments.createMap();
2055
1986
  adInfo.putString( "adUnitId", ad.getAdUnitId() );
2056
- adInfo.putString( "creativeId", AppLovinSdkUtils.isValidString( ad.getCreativeId() ) ? ad.getCreativeId() : "" );
1987
+ adInfo.putString( "adFormat", ad.getFormat().getLabel() );
2057
1988
  adInfo.putString( "networkName", ad.getNetworkName() );
1989
+ adInfo.putString( "networkPlacement", ad.getNetworkPlacement() );
1990
+
1991
+ adInfo.putString( "creativeId", AppLovinSdkUtils.isValidString( ad.getCreativeId() ) ? ad.getCreativeId() : "" );
2058
1992
  adInfo.putString( "placement", AppLovinSdkUtils.isValidString( ad.getPlacement() ) ? ad.getPlacement() : "" );
2059
1993
  adInfo.putDouble( "revenue", ad.getRevenue() );
1994
+ adInfo.putString( "revenuePrecision", ad.getRevenuePrecision() );
2060
1995
  adInfo.putMap( "waterfall", createAdWaterfallInfo( ad.getWaterfall() ) );
1996
+ adInfo.putDouble( "latencyMillis", ad.getRequestLatencyMillis() );
2061
1997
  adInfo.putString( "dspName", AppLovinSdkUtils.isValidString( ad.getDspName() ) ? ad.getDspName() : "" );
2062
1998
 
2063
1999
  WritableMap sizeObject = Arguments.createMap();
@@ -2100,15 +2036,6 @@ public class AppLovinMAXModule
2100
2036
  return info;
2101
2037
  }
2102
2038
 
2103
- public WritableMap getAdRevenueInfo(final MaxAd ad)
2104
- {
2105
- WritableMap adInfo = getAdInfo( ad );
2106
- adInfo.putString( "networkPlacement", ad.getNetworkPlacement() );
2107
- adInfo.putString( "revenuePrecision", ad.getRevenuePrecision() );
2108
- adInfo.putString( "countryCode", sdkConfiguration.getCountryCode() );
2109
- return adInfo;
2110
- }
2111
-
2112
2039
  private WritableMap getAdUnitInfo(final String adUnitId)
2113
2040
  {
2114
2041
  WritableMap info = Arguments.createMap();
@@ -2304,28 +2231,51 @@ public class AppLovinMAXModule
2304
2231
  rewardedAds.clear();
2305
2232
  }
2306
2233
 
2307
- // Required methods introduced React Native 0.65
2308
- //
2309
- // Without these methods, the following warnings are generated.
2310
- //
2311
- // WARN new NativeEventEmitter() was called with a non-null argument without the required addListener method.
2312
- // WARN new NativeEventEmitter() was called with a non-null argument without the required removeListeners method.
2313
- @ReactMethod
2314
- public void addListener(String eventName) { }
2315
-
2316
- @ReactMethod
2317
- public void removeListeners(Integer count) { }
2318
-
2319
2234
  // React Native Bridge
2320
2235
 
2321
2236
  public void sendReactNativeEvent(final String name, @Nullable final WritableMap params)
2322
2237
  {
2323
- getReactApplicationContext()
2238
+ reactContext
2324
2239
  .getJSModule( RCTDeviceEventEmitter.class )
2325
2240
  .emit( name, params );
2326
2241
  }
2327
2242
 
2328
- @Override
2243
+ public void sendReactNativeViewEvent(final int surfaceId, final int viewId, final String eventName, final WritableMap payload)
2244
+ {
2245
+ EventDispatcher eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag( reactContext, viewId );
2246
+ if ( eventDispatcher != null )
2247
+ {
2248
+ eventDispatcher.dispatchEvent( new OnViewEvent( surfaceId, viewId, eventName, payload ) );
2249
+ }
2250
+ }
2251
+
2252
+ private class OnViewEvent
2253
+ extends Event<OnViewEvent>
2254
+ {
2255
+ private final WritableMap payload;
2256
+ private final String eventName;
2257
+
2258
+ OnViewEvent(final int surfaceId, final int viewId, final String eventName, @Nullable final WritableMap payload)
2259
+ {
2260
+ super( surfaceId, viewId );
2261
+ this.eventName = eventName;
2262
+ this.payload = payload;
2263
+ }
2264
+
2265
+ @Override
2266
+ public String getEventName()
2267
+ {
2268
+ return eventName;
2269
+ }
2270
+
2271
+ @Nullable
2272
+ @Override
2273
+ protected WritableMap getEventData()
2274
+ {
2275
+ return payload;
2276
+ }
2277
+ }
2278
+
2329
2279
  @Nullable
2330
2280
  public Map<String, Object> getConstants()
2331
2281
  {
@@ -2373,19 +2323,6 @@ public class AppLovinMAXModule
2373
2323
  constants.put( "ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOADED_EVENT", AppLovinMAXAdEvents.ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOADED_EVENT );
2374
2324
  constants.put( "ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOAD_FAILED_EVENT", AppLovinMAXAdEvents.ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOAD_FAILED_EVENT );
2375
2325
 
2376
- constants.put( "TOP_CENTER_POSITION", TOP_CENTER );
2377
- constants.put( "TOP_LEFT_POSITION", TOP_LEFT );
2378
- constants.put( "TOP_RIGHT_POSITION", TOP_RIGHT );
2379
- constants.put( "CENTERED_POSITION", CENTERED );
2380
- constants.put( "CENTER_LEFT_POSITION", CENTER_LEFT );
2381
- constants.put( "CENTER_RIGHT_POSITION", CENTER_RIGHT );
2382
- constants.put( "BOTTOM_LEFT_POSITION", BOTTOM_LEFT );
2383
- constants.put( "BOTTOM_CENTER_POSITION", BOTTOM_CENTER );
2384
- constants.put( "BOTTOM_RIGHT_POSITION", BOTTOM_RIGHT );
2385
-
2386
- constants.put( "BANNER_AD_FORMAT_LABEL", MaxAdFormat.BANNER.getLabel() );
2387
- constants.put( "MREC_AD_FORMAT_LABEL", MaxAdFormat.MREC.getLabel() );
2388
-
2389
2326
  constants.put( "MAX_ERROR_CODE_UNSPECIFIED", MaxErrorCode.UNSPECIFIED );
2390
2327
  constants.put( "MAX_ERROR_CODE_NO_FILL", MaxErrorCode.NO_FILL );
2391
2328
  constants.put( "MAX_ERROR_CODE_AD_LOAD_FAILED", MaxErrorCode.AD_LOAD_FAILED );
@@ -2452,5 +2389,4 @@ public class AppLovinMAXModule
2452
2389
 
2453
2390
  return versionCode;
2454
2391
  }
2455
-
2456
2392
  }