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