react-native-applovin-max 8.0.5 → 8.1.1

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 (48) hide show
  1. package/android/build.gradle +3 -3
  2. package/android/gradle.properties +1 -3
  3. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdView.java +66 -42
  4. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewManager.java +7 -1
  5. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewUiComponent.java +28 -5
  6. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXModule.java +5 -5
  7. package/ios/AppLovinMAX.h +3 -0
  8. package/ios/AppLovinMAX.m +8 -8
  9. package/ios/AppLovinMAXAdView.h +4 -2
  10. package/ios/AppLovinMAXAdView.m +67 -37
  11. package/ios/AppLovinMAXAdViewManager.m +1 -0
  12. package/ios/AppLovinMAXAdViewUIComponent.h +2 -1
  13. package/ios/AppLovinMAXAdViewUIComponent.m +42 -14
  14. package/lib/commonjs/AdView.js +29 -27
  15. package/lib/commonjs/AdView.js.map +1 -1
  16. package/lib/commonjs/AppLovinMAX.js +11 -6
  17. package/lib/commonjs/AppLovinMAX.js.map +1 -1
  18. package/lib/commonjs/ErrorCode.js +0 -4
  19. package/lib/commonjs/ErrorCode.js.map +1 -1
  20. package/lib/commonjs/nativeAd/NativeAdView.js +6 -4
  21. package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -1
  22. package/lib/commonjs/types/AdInfo.js.map +1 -1
  23. package/lib/module/AdView.js +29 -27
  24. package/lib/module/AdView.js.map +1 -1
  25. package/lib/module/AppLovinMAX.js +11 -6
  26. package/lib/module/AppLovinMAX.js.map +1 -1
  27. package/lib/module/ErrorCode.js +0 -4
  28. package/lib/module/ErrorCode.js.map +1 -1
  29. package/lib/module/nativeAd/NativeAdView.js +6 -4
  30. package/lib/module/nativeAd/NativeAdView.js.map +1 -1
  31. package/lib/module/types/AdInfo.js.map +1 -1
  32. package/lib/typescript/src/AdView.d.ts +29 -28
  33. package/lib/typescript/src/AdView.d.ts.map +1 -1
  34. package/lib/typescript/src/AppLovinMAX.d.ts.map +1 -1
  35. package/lib/typescript/src/ErrorCode.d.ts +0 -10
  36. package/lib/typescript/src/ErrorCode.d.ts.map +1 -1
  37. package/lib/typescript/src/types/AdInfo.d.ts +9 -0
  38. package/lib/typescript/src/types/AdInfo.d.ts.map +1 -1
  39. package/lib/typescript/src/types/AdViewProps.d.ts +24 -8
  40. package/lib/typescript/src/types/AdViewProps.d.ts.map +1 -1
  41. package/package.json +5 -4
  42. package/react-native-applovin-max.podspec +4 -3
  43. package/src/AdView.tsx +31 -29
  44. package/src/AppLovinMAX.ts +11 -6
  45. package/src/ErrorCode.ts +0 -14
  46. package/src/nativeAd/NativeAdView.tsx +6 -7
  47. package/src/types/AdInfo.ts +11 -0
  48. package/src/types/AdViewProps.ts +26 -8
@@ -1,7 +1,6 @@
1
1
  require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
- folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
4
 
6
5
  Pod::Spec.new do |s|
7
6
  s.name = "react-native-applovin-max"
@@ -12,7 +11,7 @@ Pod::Spec.new do |s|
12
11
  s.authors = package["author"]
13
12
 
14
13
  s.platforms = { :ios => min_ios_version_supported }
15
- s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_8_0_5" }
14
+ s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_8_1_1" }
16
15
 
17
16
  s.source_files = "ios/AppLovinMAX*.{h,m}"
18
17
 
@@ -23,10 +22,12 @@ Pod::Spec.new do |s|
23
22
  if respond_to?(:install_modules_dependencies, true)
24
23
  install_modules_dependencies(s)
25
24
  else
26
- s.dependency "React-Core"
25
+ s.dependency "React-Core"
27
26
 
28
27
  # Don't install the dependencies when we run `pod install` in the old architecture.
29
28
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
29
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
30
+
30
31
  s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
31
32
  s.pod_target_xcconfig = {
32
33
  "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
package/src/AdView.tsx CHANGED
@@ -4,7 +4,7 @@ import { NativeModules, requireNativeComponent, StyleSheet, UIManager, findNodeH
4
4
  import type { ViewProps, ViewStyle, StyleProp, NativeMethods, DimensionValue } from 'react-native';
5
5
  import type { AdDisplayFailedInfo, AdInfo, AdLoadFailedInfo, AdRevenueInfo } from './types/AdInfo';
6
6
  import type { AdNativeEvent } from './types/AdEvent';
7
- import type { AdViewProps, AdViewHandler, NativeUIComponentAdViewOptions } from './types/AdViewProps';
7
+ import type { AdViewProps, AdViewHandler, NativeUIComponentAdViewOptions, AdViewId } from './types/AdViewProps';
8
8
  import { addEventListener, removeEventListener } from './EventEmitter';
9
9
 
10
10
  const { AppLovinMAX } = NativeModules;
@@ -109,11 +109,16 @@ const sizeBannerDimensions = async (sizeProps: SizeRecord, adaptiveBannerEnabled
109
109
  };
110
110
 
111
111
  /**
112
- * The {@link AdView} component that you use for building a banner or an MREC. Phones
113
- * size banners to 320x50 and MRECs to 300x250. Tablets size banners to 728x90 and MRECs to
114
- * 300x250. You may use the utility method {@link AppLovinMAX.isTablet()} to help with view sizing
115
- * adjustments. For adaptive banners, call {@link BannerAd.getAdaptiveHeightForWidth()} to get
116
- * the banner height, and then adjust your content accordingly.
112
+ * The {@link AdView} component renders banner or MREC ads with responsive sizing.
113
+ * - **Banners**: 320x50 on phones, 728x90 on tablets.
114
+ * - **MRECs**: 300x250 on all devices.
115
+ *
116
+ * Use {@link AppLovinMAX.isTablet()} to determine device type for layout adjustments.
117
+ * For adaptive banners, use {@link BannerAd.getAdaptiveHeightForWidth()} for precise sizing.
118
+ *
119
+ * **Preloading**:
120
+ * When preloading an {@link AdView} using {@link preloadNativeUIComponentAdView},
121
+ * the returned {@link AdViewId} must be passed to identify the preloaded instance.
117
122
  *
118
123
  * ### Example:
119
124
  * ```js
@@ -135,6 +140,7 @@ export const AdView = forwardRef<AdViewHandler, AdViewProps & ViewProps>(functio
135
140
  {
136
141
  adUnitId,
137
142
  adFormat,
143
+ adViewId,
138
144
  placement,
139
145
  customData,
140
146
  adaptiveBannerEnabled = true,
@@ -282,6 +288,7 @@ export const AdView = forwardRef<AdViewHandler, AdViewProps & ViewProps>(functio
282
288
  ref={saveElement}
283
289
  adUnitId={adUnitId}
284
290
  adFormat={adFormat}
291
+ adViewId={adViewId || 0}
285
292
  placement={placement}
286
293
  customData={customData}
287
294
  adaptiveBannerEnabled={adaptiveBannerEnabled}
@@ -303,38 +310,33 @@ export const AdView = forwardRef<AdViewHandler, AdViewProps & ViewProps>(functio
303
310
  });
304
311
 
305
312
  /**
306
- * Preloads a native UI component for {@link AdView}. When you mount {@link AdView} with the Ad Unit
307
- * ID you preloaded, it will be constructed with the preloaded native UI component, allowing the ads
308
- * to be displayed quickly. When you unmount {@link AdView}, the preloaded native UI component won't
309
- * be destroyed. Instead, it will be reused for the next mount. You must manually destroy it when it
310
- * is no longer needed.
313
+ * Preloads a native UI component for {@link AdView}, enabling faster ad display on first mount.
311
314
  *
312
- * You can preload only one native UI component for a single Ad Unit ID. If you mount two of
313
- * {@link AdView} with the same Ad Unit ID, the first {@link AdView} will be constructed with the
314
- * preloaded native UI component, but the second {@link AdView} will create its own native UI
315
- * component and destroy it when unmounting.
315
+ * - When you mount {@link AdView} with the preloaded Ad Unit ID, it uses the preloaded native UI component.
316
+ * - Unmounting {@link AdView} does not destroy the preloaded component—it will be reused on the next mount.
317
+ * - You must manually destroy the preloaded component when it is no longer needed using {@link destroyNativeUIComponentAdView}.
316
318
  *
317
- * @param adUnitId The Ad Unit ID to load ads for.
318
- * @param adFormat An enum value representing the ad format to load ads for. Should be either
319
- * {@link AdFormat.BANNER} or {@link AdFormat.MREC}.
320
- * @param options Optional props used to construct a native UI component.
321
- * @returns A promise that resolves when preload starts. The resolved object contains void.
322
- * @throws Throws an error if the request fails.
319
+ * @param adUnitId - The Ad Unit ID for which the ads should be preloaded.
320
+ * @param adFormat - The ad format to preload. Must be either {@link AdFormat.BANNER} or {@link AdFormat.MREC}.
321
+ * @param options - Optional properties to configure the native UI component (e.g., placement, custom data).
322
+ * @returns A promise resolving to an {@link AdViewId}, which uniquely identifies the preloaded component.
323
+ * @throws An error if the preload request fails.
323
324
  */
324
- export const preloadNativeUIComponentAdView = async (adUnitId: string, adFormat: AdFormat, options?: NativeUIComponentAdViewOptions): Promise<void> => {
325
+ export const preloadNativeUIComponentAdView = async (adUnitId: string, adFormat: AdFormat, options?: NativeUIComponentAdViewOptions): Promise<AdViewId> => {
325
326
  return AppLovinMAX.preloadNativeUIComponentAdView(adUnitId, adFormat, options?.placement, options?.customData, options?.extraParameters, options?.localExtraParameters);
326
327
  };
327
328
 
328
329
  /**
329
- * Destroys the native UI component.
330
+ * Destroys a preloaded native UI component identified by its {@link AdViewId}.
331
+ *
332
+ * - This method should be called when the preloaded component is no longer needed to free resources.
330
333
  *
331
- * @param adUnitId The ad unit ID of the native UI component to destroy.
332
- * @returns A promise that resolves upon the destruction of the native UI component. The resolved
333
- * object contains void.
334
- * @throws Throws an error if the request fails.
334
+ * @param adViewId - The {@link AdViewId} of the native UI component to be destroyed.
335
+ * @returns A promise that resolves when the native UI component is successfully destroyed.
336
+ * @throws An error if the destruction process fails.
335
337
  */
336
- export const destroyNativeUIComponentAdView = async (adUnitId: string): Promise<void> => {
337
- return AppLovinMAX.destroyNativeUIComponentAdView(adUnitId);
338
+ export const destroyNativeUIComponentAdView = async (adViewId: AdViewId): Promise<void> => {
339
+ return AppLovinMAX.destroyNativeUIComponentAdView(adViewId);
338
340
  };
339
341
 
340
342
  /**
@@ -4,7 +4,7 @@ import type { Configuration } from './types/Configuration';
4
4
 
5
5
  const NativeAppLovinMAX = NativeModules.AppLovinMAX;
6
6
 
7
- const VERSION = '8.0.5';
7
+ const VERSION = '8.1.1';
8
8
 
9
9
  /**
10
10
  * This enum represents the user's geography used to determine the type of consent flow shown to the
@@ -115,10 +115,15 @@ type NativeAppLovinMAXType = Omit<AppLovinMAXType, 'initialize' | 'getSegments'>
115
115
 
116
116
  const nativeMethods: NativeAppLovinMAXType = NativeAppLovinMAX;
117
117
 
118
- export const AppLovinMAX: AppLovinMAXType = {
119
- ...nativeMethods,
120
- initialize,
121
- getSegments,
122
- };
118
+ export const AppLovinMAX: AppLovinMAXType = Object.create(nativeMethods, {
119
+ initialize: {
120
+ value: initialize,
121
+ enumerable: true,
122
+ },
123
+ getSegments: {
124
+ value: getSegments,
125
+ enumerable: true,
126
+ },
127
+ });
123
128
 
124
129
  export default AppLovinMAX;
package/src/ErrorCode.ts CHANGED
@@ -13,8 +13,6 @@ const {
13
13
  MAX_ERROR_CODE_FULLSCREEN_AD_ALREADY_SHOWING,
14
14
  MAX_ERROR_CODE_FULLSCREEN_AD_NOT_READY,
15
15
  MAX_ERROR_CODE_FULLSCREEN_AD_INVALID_VIEW_CONTROLLER,
16
- MAX_ERROR_CODE_FULLSCREEN_AD_ALREADY_LOADING,
17
- MAX_ERROR_CODE_FULLSCREEN_AD_LOAD_WHILE_SHOWING,
18
16
  MAX_ERROR_CODE_DONT_KEEP_ACTIVITIES_ENABLED,
19
17
  MAX_ERROR_CODE_INVALID_AD_UNIT_ID,
20
18
  } = AppLovinMAX.getConstants();
@@ -83,18 +81,6 @@ export enum ErrorCode {
83
81
  */
84
82
  FULLSCREEN_AD_INVALID_VIEW_CONTROLLER = MAX_ERROR_CODE_FULLSCREEN_AD_INVALID_VIEW_CONTROLLER,
85
83
 
86
- /**
87
- * This error code indicates you are attempting to load a fullscreen ad while another
88
- * fullscreen ad is already loading.
89
- */
90
- FULLSCREEN_AD_ALREADY_LOADING = MAX_ERROR_CODE_FULLSCREEN_AD_ALREADY_LOADING,
91
-
92
- /**
93
- * This error code indicates you are attempting to load a fullscreen ad while another fullscreen ad
94
- * is still showing.
95
- */
96
- FULLSCREEN_AD_LOAD_WHILE_SHOWING = MAX_ERROR_CODE_FULLSCREEN_AD_LOAD_WHILE_SHOWING,
97
-
98
84
  /**
99
85
  * This error code indicates that the SDK failed to display an ad because the user has the
100
86
  * "Don't Keep Activities" developer setting enabled.
@@ -95,13 +95,12 @@ const NativeAdViewImpl = forwardRef<NativeAdViewHandler, NativeAdViewProps & Vie
95
95
 
96
96
  // Load a new ad
97
97
  const loadAd = useCallback(() => {
98
- if (nativeAdViewRef.current) {
99
- UIManager.dispatchViewManagerCommand(
100
- findNodeHandle(nativeAdViewRef.current),
101
- // @ts-ignore: Issue in RN ts defs
102
- UIManager.getViewManagerConfig('AppLovinMAXNativeAdView').Commands.loadAd,
103
- undefined
104
- );
98
+ const nativeAdView = nativeAdViewRef.current;
99
+ if (nativeAdView) {
100
+ const viewManagerConfig = UIManager.getViewManagerConfig('AppLovinMAXNativeAdView');
101
+ if (viewManagerConfig?.Commands && typeof viewManagerConfig.Commands.loadAd === 'number') {
102
+ UIManager.dispatchViewManagerCommand(findNodeHandle(nativeAdView), viewManagerConfig.Commands.loadAd, []);
103
+ }
105
104
  }
106
105
  }, []);
107
106
 
@@ -1,4 +1,5 @@
1
1
  import type { ErrorCode } from '../ErrorCode';
2
+ import type { AdViewId } from './AdViewProps';
2
3
 
3
4
  /**
4
5
  * Represents an ad that has been served by AppLovin MAX.
@@ -9,6 +10,11 @@ export type AdInfo = {
9
10
  */
10
11
  adUnitId: string;
11
12
 
13
+ /**
14
+ * The unique ID of the native UI component AdView.
15
+ */
16
+ adViewId?: AdViewId;
17
+
12
18
  /**
13
19
  * The creative ID tied to the ad, if any. You can report creative issues to the corresponding
14
20
  * ad network using this ID.
@@ -69,6 +75,11 @@ export type AdLoadFailedInfo = {
69
75
  */
70
76
  adUnitId: string;
71
77
 
78
+ /**
79
+ * The unique ID of the native UI component AdView.
80
+ */
81
+ adViewId?: AdViewId;
82
+
72
83
  /**
73
84
  * The error code for the error.
74
85
  */
@@ -12,40 +12,58 @@ export type AdViewHandler = {
12
12
  loadAd(): void;
13
13
  };
14
14
 
15
+ /**
16
+ * A unique identifier for referencing a specific AdView instance.
17
+ *
18
+ * - If the value is a number, it represents the ID of a preloaded or assigned AdView.
19
+ * - A value of `undefined` indicates that the AdView has not been preloaded or assigned an ID yet.
20
+ */
21
+ export type AdViewId = number | undefined;
22
+
15
23
  /**
16
24
  * Represents an {@link AdView} - Banner / MREC.
17
25
  */
18
26
  export type AdViewProps = AdProps & {
19
27
  /**
20
- * An enum value representing the ad format to load ads for. Should be either
28
+ * An enum value representing the ad format to load ads for. Must be either
21
29
  * {@link AdFormat.BANNER} or {@link AdFormat.MREC}.
22
30
  */
23
31
  adFormat: AdFormat;
24
32
 
25
33
  /**
26
- * A boolean value representing whether or not to enable adaptive banners.
34
+ * A unique identifier representing the AdView instance.
35
+ * Used to manage and track the specific AdView.
36
+ */
37
+ adViewId?: AdViewId;
38
+
39
+ /**
40
+ * A boolean indicating whether adaptive banners are enabled.
27
41
  */
28
42
  adaptiveBannerEnabled?: boolean;
29
43
 
30
44
  /**
31
- * A boolean value representing whether or not to enable auto-refresh. Note that auto-refresh is
32
- * enabled by default.
45
+ * A boolean indicating whether auto-refresh is enabled.
46
+ * Auto-refresh is enabled by default.
33
47
  */
34
48
  autoRefresh?: boolean;
35
49
 
36
50
  /**
37
- * A boolean value representing whether or not to load an ad as soon as {@link AdView} is
38
- * mounted. Note that the default value is true.
51
+ * A boolean indicating whether an ad should load automatically
52
+ * when the {@link AdView} is mounted. Defaults to `true`.
39
53
  */
40
54
  loadOnMount?: boolean;
41
55
 
42
56
  /**
43
- * A callback fuction that {@link AdView} fires when it expands the ad.
57
+ * A callback function triggered when the {@link AdView} expands the ad.
58
+ *
59
+ * @param adInfo - Information about the ad that was expanded.
44
60
  */
45
61
  onAdExpanded?: (adInfo: AdInfo) => void;
46
62
 
47
63
  /**
48
- * A callback fuction that {@link AdView} fires when it collapses the ad.
64
+ * A callback function triggered when the {@link AdView} collapses the ad.
65
+ *
66
+ * @param adInfo - Information about the ad that was collapsed.
49
67
  */
50
68
  onAdCollapsed?: (adInfo: AdInfo) => void;
51
69
  };