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.
- package/android/build.gradle +14 -3
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdView.java +34 -27
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewManagerImpl.java +110 -0
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewUiComponent.java +15 -13
- package/android/src/main/java/com/applovin/reactnative/{AppLovinMAXModule.java → AppLovinMAXModuleImpl.java} +108 -168
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdView.java +84 -56
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdViewManagerImpl.java +101 -0
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXPackage.java +44 -11
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXUtils.java +56 -0
- package/android/src/newarch/com/applovin/reactnative/AppLovinMAXAdViewManager.java +151 -0
- package/android/src/newarch/com/applovin/reactnative/AppLovinMAXModule.java +453 -0
- package/android/src/newarch/com/applovin/reactnative/AppLovinMAXNativeAdViewManager.java +130 -0
- package/android/src/oldarch/com/applovin/reactnative/AppLovinMAXAdViewManager.java +128 -0
- package/android/src/oldarch/com/applovin/reactnative/AppLovinMAXModule.java +453 -0
- package/android/src/oldarch/com/applovin/reactnative/AppLovinMAXNativeAdViewManager.java +93 -0
- package/ios/AppLovinMAX.h +8 -3
- package/ios/{AppLovinMAX.m → AppLovinMAX.mm} +67 -53
- package/ios/AppLovinMAXAdView.h +7 -2
- package/ios/AppLovinMAXAdView.mm +747 -0
- package/ios/{AppLovinMAXAdViewManager.m → AppLovinMAXAdViewManager.mm} +3 -2
- package/ios/{AppLovinMAXAdViewUIComponent.m → AppLovinMAXAdViewUIComponent.mm} +2 -1
- package/ios/AppLovinMAXNativeAdView.h +15 -4
- package/ios/AppLovinMAXNativeAdView.mm +745 -0
- package/ios/AppLovinMAXNativeAdViewManager.mm +116 -0
- package/lib/commonjs/AdView.js +102 -142
- package/lib/commonjs/AdView.js.map +1 -1
- package/lib/commonjs/AppLovinMAX.js +49 -34
- package/lib/commonjs/AppLovinMAX.js.map +1 -1
- package/lib/commonjs/AppOpenAd.js +8 -10
- package/lib/commonjs/AppOpenAd.js.map +1 -1
- package/lib/commonjs/BannerAd.js +19 -21
- package/lib/commonjs/BannerAd.js.map +1 -1
- package/lib/commonjs/ErrorCode.js +27 -36
- package/lib/commonjs/ErrorCode.js.map +1 -1
- package/lib/commonjs/EventEmitter.js +24 -5
- package/lib/commonjs/EventEmitter.js.map +1 -1
- package/lib/commonjs/InterstitialAd.js +8 -10
- package/lib/commonjs/InterstitialAd.js.map +1 -1
- package/lib/commonjs/MRecAd.js +14 -16
- package/lib/commonjs/MRecAd.js.map +1 -1
- package/lib/commonjs/Privacy.js +3 -5
- package/lib/commonjs/Privacy.js.map +1 -1
- package/lib/commonjs/RewardedAd.js +8 -10
- package/lib/commonjs/RewardedAd.js.map +1 -1
- package/lib/commonjs/Utils.js +43 -0
- package/lib/commonjs/Utils.js.map +1 -0
- package/lib/commonjs/nativeAd/NativeAdView.js +84 -50
- package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdViewComponents.js +129 -82
- package/lib/commonjs/nativeAd/NativeAdViewComponents.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdViewProvider.js +67 -8
- package/lib/commonjs/nativeAd/NativeAdViewProvider.js.map +1 -1
- package/lib/commonjs/nativeAd/img/blank_icon.png +0 -0
- package/lib/commonjs/specs/AppLovinMAXAdViewNativeComponent.js +41 -0
- package/lib/commonjs/specs/AppLovinMAXAdViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/AppLovinMAXNativeAdViewNativeComponent.js +37 -0
- package/lib/commonjs/specs/AppLovinMAXNativeAdViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/NativeAppLovinMAXModule.js +16 -0
- package/lib/commonjs/specs/NativeAppLovinMAXModule.js.map +1 -0
- package/lib/commonjs/types/AdInfo.js +13 -16
- package/lib/commonjs/types/AdInfo.js.map +1 -1
- package/lib/module/AdView.js +98 -139
- package/lib/module/AdView.js.map +1 -1
- package/lib/module/AppLovinMAX.js +47 -32
- package/lib/module/AppLovinMAX.js.map +1 -1
- package/lib/module/AppOpenAd.js +1 -4
- package/lib/module/AppOpenAd.js.map +1 -1
- package/lib/module/BannerAd.js +1 -4
- package/lib/module/BannerAd.js.map +1 -1
- package/lib/module/ErrorCode.js +25 -35
- package/lib/module/ErrorCode.js.map +1 -1
- package/lib/module/EventEmitter.js +24 -5
- package/lib/module/EventEmitter.js.map +1 -1
- package/lib/module/InterstitialAd.js +2 -5
- package/lib/module/InterstitialAd.js.map +1 -1
- package/lib/module/MRecAd.js +1 -4
- package/lib/module/MRecAd.js.map +1 -1
- package/lib/module/Privacy.js +1 -4
- package/lib/module/Privacy.js.map +1 -1
- package/lib/module/RewardedAd.js +2 -5
- package/lib/module/RewardedAd.js.map +1 -1
- package/lib/module/Utils.js +35 -0
- package/lib/module/Utils.js.map +1 -0
- package/lib/module/nativeAd/NativeAdView.js +83 -47
- package/lib/module/nativeAd/NativeAdView.js.map +1 -1
- package/lib/module/nativeAd/NativeAdViewComponents.js +134 -83
- package/lib/module/nativeAd/NativeAdViewComponents.js.map +1 -1
- package/lib/module/nativeAd/NativeAdViewProvider.js +69 -9
- package/lib/module/nativeAd/NativeAdViewProvider.js.map +1 -1
- package/lib/module/nativeAd/img/blank_icon.png +0 -0
- package/lib/module/specs/AppLovinMAXAdViewNativeComponent.js +35 -0
- package/lib/module/specs/AppLovinMAXAdViewNativeComponent.js.map +1 -0
- package/lib/module/specs/AppLovinMAXNativeAdViewNativeComponent.js +31 -0
- package/lib/module/specs/AppLovinMAXNativeAdViewNativeComponent.js.map +1 -0
- package/lib/module/specs/NativeAppLovinMAXModule.js +12 -0
- package/lib/module/specs/NativeAppLovinMAXModule.js.map +1 -0
- package/lib/module/types/AdInfo.js +13 -16
- package/lib/module/types/AdInfo.js.map +1 -1
- package/lib/typescript/src/AdView.d.ts +38 -32
- package/lib/typescript/src/AdView.d.ts.map +1 -1
- package/lib/typescript/src/AppLovinMAX.d.ts +22 -21
- package/lib/typescript/src/AppLovinMAX.d.ts.map +1 -1
- package/lib/typescript/src/AppOpenAd.d.ts.map +1 -1
- package/lib/typescript/src/BannerAd.d.ts.map +1 -1
- package/lib/typescript/src/ErrorCode.d.ts +24 -31
- package/lib/typescript/src/ErrorCode.d.ts.map +1 -1
- package/lib/typescript/src/EventEmitter.d.ts +16 -0
- package/lib/typescript/src/EventEmitter.d.ts.map +1 -1
- package/lib/typescript/src/InterstitialAd.d.ts.map +1 -1
- package/lib/typescript/src/MRecAd.d.ts.map +1 -1
- package/lib/typescript/src/Privacy.d.ts.map +1 -1
- package/lib/typescript/src/RewardedAd.d.ts.map +1 -1
- package/lib/typescript/src/Utils.d.ts +31 -0
- package/lib/typescript/src/Utils.d.ts.map +1 -0
- package/lib/typescript/src/nativeAd/NativeAdView.d.ts +15 -7
- package/lib/typescript/src/nativeAd/NativeAdView.d.ts.map +1 -1
- package/lib/typescript/src/nativeAd/NativeAdViewComponents.d.ts +65 -1
- package/lib/typescript/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -1
- package/lib/typescript/src/nativeAd/NativeAdViewProvider.d.ts +31 -5
- package/lib/typescript/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -1
- package/lib/typescript/src/specs/AppLovinMAXAdViewNativeComponent.d.ts +130 -0
- package/lib/typescript/src/specs/AppLovinMAXAdViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/specs/AppLovinMAXNativeAdViewNativeComponent.d.ts +131 -0
- package/lib/typescript/src/specs/AppLovinMAXNativeAdViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeAppLovinMAXModule.d.ts +142 -0
- package/lib/typescript/src/specs/NativeAppLovinMAXModule.d.ts.map +1 -0
- package/lib/typescript/src/types/AdEvent.d.ts +10 -4
- package/lib/typescript/src/types/AdEvent.d.ts.map +1 -1
- package/lib/typescript/src/types/AdInfo.d.ts +79 -86
- package/lib/typescript/src/types/AdInfo.d.ts.map +1 -1
- package/lib/typescript/src/types/AdProps.d.ts +16 -17
- package/lib/typescript/src/types/AdProps.d.ts.map +1 -1
- package/lib/typescript/src/types/AdViewProps.d.ts +28 -29
- package/lib/typescript/src/types/AdViewProps.d.ts.map +1 -1
- package/lib/typescript/src/types/AppLovinMAX.d.ts +50 -53
- package/lib/typescript/src/types/AppLovinMAX.d.ts.map +1 -1
- package/lib/typescript/src/types/BannerAd.d.ts +22 -17
- package/lib/typescript/src/types/BannerAd.d.ts.map +1 -1
- package/lib/typescript/src/types/CMPError.d.ts +7 -4
- package/lib/typescript/src/types/CMPError.d.ts.map +1 -1
- package/lib/typescript/src/types/Configuration.d.ts +12 -14
- package/lib/typescript/src/types/Configuration.d.ts.map +1 -1
- package/lib/typescript/src/types/FullscreenAd.d.ts +39 -46
- package/lib/typescript/src/types/FullscreenAd.d.ts.map +1 -1
- package/lib/typescript/src/types/MRecAd.d.ts +7 -3
- package/lib/typescript/src/types/MRecAd.d.ts.map +1 -1
- package/lib/typescript/src/types/NativeAd.d.ts +15 -10
- package/lib/typescript/src/types/NativeAd.d.ts.map +1 -1
- package/lib/typescript/src/types/NativeAdViewProps.d.ts +4 -3
- package/lib/typescript/src/types/NativeAdViewProps.d.ts.map +1 -1
- package/lib/typescript/src/types/Privacy.d.ts +13 -6
- package/lib/typescript/src/types/Privacy.d.ts.map +1 -1
- package/lib/typescript/src/types/RewardedAd.d.ts +7 -5
- package/lib/typescript/src/types/RewardedAd.d.ts.map +1 -1
- package/lib/typescript/src/types/ViewAd.d.ts +46 -50
- package/lib/typescript/src/types/ViewAd.d.ts.map +1 -1
- package/package.json +9 -1
- package/react-native-applovin-max.podspec +3 -3
- package/src/AdView.tsx +100 -183
- package/src/AppLovinMAX.ts +42 -33
- package/src/AppOpenAd.ts +1 -3
- package/src/BannerAd.ts +1 -3
- package/src/ErrorCode.ts +25 -34
- package/src/EventEmitter.ts +22 -5
- package/src/InterstitialAd.ts +2 -4
- package/src/MRecAd.ts +1 -3
- package/src/Privacy.ts +1 -3
- package/src/RewardedAd.ts +2 -4
- package/src/Utils.ts +45 -0
- package/src/nativeAd/NativeAdView.tsx +83 -73
- package/src/nativeAd/NativeAdViewComponents.tsx +120 -89
- package/src/nativeAd/NativeAdViewProvider.tsx +60 -12
- package/src/nativeAd/img/blank_icon.png +0 -0
- package/src/specs/AppLovinMAXAdViewNativeComponent.ts +157 -0
- package/src/specs/AppLovinMAXNativeAdViewNativeComponent.ts +153 -0
- package/src/specs/NativeAppLovinMAXModule.ts +228 -0
- package/src/types/AdEvent.ts +10 -4
- package/src/types/AdInfo.ts +79 -86
- package/src/types/AdProps.ts +16 -17
- package/src/types/AdViewProps.ts +28 -29
- package/src/types/AppLovinMAX.ts +50 -53
- package/src/types/BannerAd.ts +22 -17
- package/src/types/CMPError.ts +7 -4
- package/src/types/Configuration.ts +12 -14
- package/src/types/FullscreenAd.ts +39 -46
- package/src/types/MRecAd.ts +7 -3
- package/src/types/NativeAd.ts +16 -10
- package/src/types/NativeAdViewProps.ts +4 -3
- package/src/types/Privacy.ts +13 -6
- package/src/types/RewardedAd.ts +7 -5
- package/src/types/ViewAd.ts +46 -50
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewManager.java +0 -149
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdViewManager.java +0 -163
- package/ios/AppLovinMAXAdView.m +0 -325
- package/ios/AppLovinMAXNativeAdView.m +0 -432
- package/ios/AppLovinMAXNativeAdViewManager.m +0 -64
package/src/AdView.tsx
CHANGED
|
@@ -1,76 +1,47 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useEffect, useState, useRef, useCallback, useImperativeHandle, useReducer, forwardRef } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import type { ViewProps, ViewStyle, StyleProp,
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import type {
|
|
3
|
+
import { StyleSheet, useWindowDimensions, View } from 'react-native';
|
|
4
|
+
import type { NativeSyntheticEvent, ViewProps, ViewStyle, StyleProp, DimensionValue } from 'react-native';
|
|
5
|
+
import AppLovinMAX from './specs/NativeAppLovinMAXModule';
|
|
6
|
+
import AdViewComponent, { Commands } from './specs/AppLovinMAXAdViewNativeComponent';
|
|
7
|
+
import type { AdInfoEvent, AdLoadFailedEvent, AdDisplayFailedEvent } from './specs/AppLovinMAXAdViewNativeComponent';
|
|
8
8
|
import { addEventListener, removeEventListener } from './EventEmitter';
|
|
9
|
+
import type { AdInfo, AdLoadFailedInfo } from './types/AdInfo';
|
|
10
|
+
import type { AdViewProps, AdViewHandler, NativeUIComponentAdViewOptions, AdViewId } from './types/AdViewProps';
|
|
11
|
+
import { makeExtraParametersArray, makeLocalExtraParametersArray } from './Utils';
|
|
9
12
|
|
|
10
|
-
const {
|
|
11
|
-
|
|
12
|
-
const {
|
|
13
|
-
BANNER_AD_FORMAT_LABEL,
|
|
14
|
-
MREC_AD_FORMAT_LABEL,
|
|
15
|
-
|
|
16
|
-
TOP_CENTER_POSITION,
|
|
17
|
-
TOP_LEFT_POSITION,
|
|
18
|
-
TOP_RIGHT_POSITION,
|
|
19
|
-
CENTERED_POSITION,
|
|
20
|
-
CENTER_LEFT_POSITION,
|
|
21
|
-
CENTER_RIGHT_POSITION,
|
|
22
|
-
BOTTOM_LEFT_POSITION,
|
|
23
|
-
BOTTOM_CENTER_POSITION,
|
|
24
|
-
BOTTOM_RIGHT_POSITION,
|
|
25
|
-
|
|
26
|
-
ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOADED_EVENT,
|
|
27
|
-
ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOAD_FAILED_EVENT,
|
|
28
|
-
} = AppLovinMAX.getConstants();
|
|
13
|
+
const { ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOADED_EVENT, ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOAD_FAILED_EVENT } = AppLovinMAX.getConstants();
|
|
29
14
|
|
|
30
15
|
/**
|
|
31
|
-
* Defines
|
|
16
|
+
* Defines the format of an ad.
|
|
32
17
|
*/
|
|
33
18
|
export enum AdFormat {
|
|
34
19
|
/**
|
|
35
20
|
* Banner ad.
|
|
36
21
|
*/
|
|
37
|
-
BANNER =
|
|
22
|
+
BANNER = 'BANNER',
|
|
38
23
|
|
|
39
24
|
/**
|
|
40
25
|
* MREC ad.
|
|
41
26
|
*/
|
|
42
|
-
MREC =
|
|
27
|
+
MREC = 'MREC',
|
|
43
28
|
}
|
|
44
29
|
|
|
45
30
|
/**
|
|
46
|
-
* Defines
|
|
31
|
+
* Defines the position for rendering a banner or MREC ad within its container.
|
|
47
32
|
*/
|
|
48
33
|
export enum AdViewPosition {
|
|
49
|
-
TOP_CENTER =
|
|
50
|
-
TOP_LEFT =
|
|
51
|
-
TOP_RIGHT =
|
|
52
|
-
CENTERED =
|
|
53
|
-
CENTER_LEFT =
|
|
54
|
-
CENTER_RIGHT =
|
|
55
|
-
BOTTOM_LEFT =
|
|
56
|
-
BOTTOM_CENTER =
|
|
57
|
-
BOTTOM_RIGHT =
|
|
34
|
+
TOP_CENTER = 'top_center',
|
|
35
|
+
TOP_LEFT = 'top_left',
|
|
36
|
+
TOP_RIGHT = 'top_right',
|
|
37
|
+
CENTERED = 'centered',
|
|
38
|
+
CENTER_LEFT = 'center_left',
|
|
39
|
+
CENTER_RIGHT = 'center_right',
|
|
40
|
+
BOTTOM_LEFT = 'bottom_left',
|
|
41
|
+
BOTTOM_CENTER = 'bottom_center',
|
|
42
|
+
BOTTOM_RIGHT = 'bottom_right',
|
|
58
43
|
}
|
|
59
44
|
|
|
60
|
-
type AdViewNativeEvents = {
|
|
61
|
-
onAdLoadedEvent(event: AdNativeEvent<AdInfo>): void;
|
|
62
|
-
onAdLoadFailedEvent(event: AdNativeEvent<AdLoadFailedInfo>): void;
|
|
63
|
-
onAdDisplayFailedEvent(event: AdNativeEvent<AdDisplayFailedInfo>): void;
|
|
64
|
-
onAdClickedEvent(event: AdNativeEvent<AdInfo>): void;
|
|
65
|
-
onAdExpandedEvent(event: AdNativeEvent<AdInfo>): void;
|
|
66
|
-
onAdCollapsedEvent(event: AdNativeEvent<AdInfo>): void;
|
|
67
|
-
onAdRevenuePaidEvent(event: AdNativeEvent<AdInfo>): void;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const AdViewComponent = requireNativeComponent<AdViewProps & ViewProps & AdViewNativeEvents>('AppLovinMAXAdView');
|
|
71
|
-
|
|
72
|
-
type AdViewType = React.Component<AdViewProps> & NativeMethods;
|
|
73
|
-
|
|
74
45
|
type SizeKey = 'width' | 'height';
|
|
75
46
|
type SizeRecord = Partial<Record<SizeKey, DimensionValue>>;
|
|
76
47
|
|
|
@@ -80,61 +51,53 @@ const ADVIEW_SIZE = {
|
|
|
80
51
|
mrec: { width: 300, height: 250 },
|
|
81
52
|
};
|
|
82
53
|
|
|
83
|
-
//
|
|
54
|
+
// Extracts width and height from the style prop, defaulting to 'auto' when unspecified.
|
|
84
55
|
const getOutlineViewSize = (style: StyleProp<ViewStyle>): [DimensionValue, DimensionValue] => {
|
|
85
56
|
const viewStyle = StyleSheet.flatten(style) || {};
|
|
86
57
|
return [viewStyle.width ?? 'auto', viewStyle.height ?? 'auto'];
|
|
87
58
|
};
|
|
88
59
|
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
let height;
|
|
93
|
-
if (sizeProps.height === 'auto') {
|
|
94
|
-
if (adaptiveBannerEnabled) {
|
|
95
|
-
try {
|
|
96
|
-
height = await AppLovinMAX.getAdaptiveBannerHeightForWidth(screenWidth);
|
|
97
|
-
} catch (error) {
|
|
98
|
-
console.error('Error getting adaptive banner height:', error);
|
|
99
|
-
height = bannerFormatSize.height;
|
|
100
|
-
}
|
|
101
|
-
} else {
|
|
102
|
-
height = bannerFormatSize.height;
|
|
103
|
-
}
|
|
104
|
-
} else {
|
|
105
|
-
height = sizeProps.height;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return { width, height };
|
|
60
|
+
const handleAdViewEvent = <T extends AdInfoEvent | AdLoadFailedEvent | AdDisplayFailedEvent>(event: NativeSyntheticEvent<T>, callback?: (adInfo: T) => void) => {
|
|
61
|
+
if (!callback) return;
|
|
62
|
+
callback(event.nativeEvent);
|
|
109
63
|
};
|
|
110
64
|
|
|
111
65
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* - **
|
|
66
|
+
* Renders a banner or MREC ad using a native view, with adaptive or responsive sizing.
|
|
67
|
+
*
|
|
68
|
+
* - **Banners**: 320×50 on phones, 728×90 on tablets.
|
|
69
|
+
* - **MRECs**: Fixed size of 300×250 on all devices.
|
|
70
|
+
*
|
|
71
|
+
* Internally uses {@link AppLovinMAX.isTablet()} to determine banner size on tablets.
|
|
72
|
+
* You can also use this method externally to assist with layout decisions.
|
|
115
73
|
*
|
|
116
|
-
*
|
|
117
|
-
* For adaptive banners, use {@link BannerAd.getAdaptiveHeightForWidth()} for precise sizing.
|
|
74
|
+
* For adaptive banners, use {@link BannerAd.getAdaptiveHeightForWidth()} to determine the appropriate height.
|
|
118
75
|
*
|
|
119
76
|
* **Preloading**:
|
|
120
|
-
*
|
|
121
|
-
* the returned {@link AdViewId}
|
|
77
|
+
* If you preload an ad for AdView using {@link preloadNativeUIComponentAdView},
|
|
78
|
+
* pass the returned {@link AdViewId} to this component to display the preloaded instance.
|
|
79
|
+
*
|
|
80
|
+
* **Note:** The AppLovin SDK must be initialized before using this component.
|
|
122
81
|
*
|
|
123
82
|
* ### Example:
|
|
124
|
-
* ```
|
|
83
|
+
* ```tsx
|
|
125
84
|
* <AdView
|
|
126
85
|
* adUnitId={adUnitId}
|
|
127
86
|
* adFormat={AdFormat.BANNER}
|
|
128
87
|
* placement="my_placement"
|
|
129
88
|
* customData="my_customData"
|
|
130
|
-
* extraParameters={{
|
|
131
|
-
* localExtraParameters={{
|
|
89
|
+
* extraParameters={{ key1: "value1", key2: "value2" }}
|
|
90
|
+
* localExtraParameters={{ key1: "value1", key2: true }}
|
|
132
91
|
* adaptiveBannerEnabled={false}
|
|
133
92
|
* autoRefresh={false}
|
|
134
93
|
* style={styles.banner}
|
|
135
94
|
* onAdLoaded={(adInfo: AdInfo) => { ... }}
|
|
136
95
|
* />
|
|
137
96
|
* ```
|
|
97
|
+
*
|
|
98
|
+
* For complete implementation examples, see:
|
|
99
|
+
* - https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/example/src/NativeBannerExample.tsx
|
|
100
|
+
* - https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/example/src/NativeMRecExample.tsx
|
|
138
101
|
*/
|
|
139
102
|
export const AdView = forwardRef<AdViewHandler, AdViewProps & ViewProps>(function AdView(
|
|
140
103
|
{
|
|
@@ -163,43 +126,25 @@ export const AdView = forwardRef<AdViewHandler, AdViewProps & ViewProps>(functio
|
|
|
163
126
|
const { width: screenWidth } = useWindowDimensions();
|
|
164
127
|
const adFormatSize = useRef<SizeRecord>({});
|
|
165
128
|
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
166
|
-
const adViewRef = useRef<
|
|
129
|
+
const adViewRef = useRef<React.ElementRef<typeof AdViewComponent> | undefined>();
|
|
167
130
|
const [isInitialized, setIsInitialized] = useState<boolean>(false);
|
|
168
|
-
const sizeProps = useRef<SizeRecord>({});
|
|
169
131
|
const dimensions = useRef<SizeRecord>({});
|
|
170
132
|
|
|
171
133
|
const loadAd = useCallback(() => {
|
|
172
|
-
|
|
173
|
-
UIManager.dispatchViewManagerCommand(
|
|
174
|
-
findNodeHandle(adViewRef.current),
|
|
175
|
-
// @ts-ignore: Issue in RN ts defs
|
|
176
|
-
UIManager.getViewManagerConfig('AppLovinMAXAdView').Commands.loadAd,
|
|
177
|
-
undefined
|
|
178
|
-
);
|
|
179
|
-
}
|
|
134
|
+
adViewRef.current && Commands.loadAd(adViewRef.current);
|
|
180
135
|
}, []);
|
|
181
136
|
|
|
182
137
|
useImperativeHandle(ref, () => ({ loadAd }), [loadAd]);
|
|
183
138
|
|
|
184
|
-
const saveElement = useCallback((element: AdViewType | null) => {
|
|
185
|
-
adViewRef.current = element;
|
|
186
|
-
}, []);
|
|
187
|
-
|
|
188
139
|
useEffect(() => {
|
|
189
140
|
(async () => {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
adFormatSize.current = isTablet
|
|
193
|
-
? { width: ADVIEW_SIZE.leader.width, height: ADVIEW_SIZE.leader.height }
|
|
194
|
-
: { width: ADVIEW_SIZE.banner.width, height: ADVIEW_SIZE.banner.height };
|
|
195
|
-
} else {
|
|
196
|
-
adFormatSize.current = { width: ADVIEW_SIZE.mrec.width, height: ADVIEW_SIZE.mrec.height };
|
|
197
|
-
}
|
|
141
|
+
const isTablet = adFormat === AdFormat.BANNER ? await AppLovinMAX.isTablet() : false;
|
|
142
|
+
adFormatSize.current = adFormat === AdFormat.BANNER ? (isTablet ? ADVIEW_SIZE.leader : ADVIEW_SIZE.banner) : ADVIEW_SIZE.mrec;
|
|
198
143
|
|
|
199
144
|
const initialized = await AppLovinMAX.isInitialized();
|
|
200
145
|
setIsInitialized(initialized);
|
|
201
146
|
if (!initialized) {
|
|
202
|
-
console.warn('AdView
|
|
147
|
+
console.warn('AdView was mounted before the AppLovin MAX React Native module was initialized.');
|
|
203
148
|
}
|
|
204
149
|
})();
|
|
205
150
|
}, [adFormat]);
|
|
@@ -207,85 +152,55 @@ export const AdView = forwardRef<AdViewHandler, AdViewProps & ViewProps>(functio
|
|
|
207
152
|
useEffect(() => {
|
|
208
153
|
const [width, height] = getOutlineViewSize(style);
|
|
209
154
|
|
|
210
|
-
if (
|
|
211
|
-
|
|
212
|
-
sizeProps.current = { width, height };
|
|
155
|
+
if (dimensions.current.width === width && dimensions.current.height === height) return;
|
|
213
156
|
|
|
214
157
|
(async () => {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
158
|
+
const isBanner = adFormat === AdFormat.BANNER;
|
|
159
|
+
const isWidthAuto = width === 'auto';
|
|
160
|
+
const isHeightAuto = height === 'auto';
|
|
161
|
+
|
|
162
|
+
const resolvedWidth = isWidthAuto ? (isBanner ? screenWidth : adFormatSize.current.width) : width;
|
|
163
|
+
|
|
164
|
+
let resolvedHeight: DimensionValue | undefined = height;
|
|
165
|
+
|
|
166
|
+
if (isHeightAuto) {
|
|
167
|
+
if (isBanner && adaptiveBannerEnabled) {
|
|
168
|
+
try {
|
|
169
|
+
resolvedHeight = await AppLovinMAX.getAdaptiveBannerHeightForWidth(screenWidth);
|
|
170
|
+
} catch (error) {
|
|
171
|
+
console.error('Error getting adaptive banner height:', error);
|
|
172
|
+
resolvedHeight = adFormatSize.current.height;
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
resolvedHeight = adFormatSize.current.height;
|
|
221
176
|
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const newSize = { width: resolvedWidth, height: resolvedHeight };
|
|
180
|
+
|
|
181
|
+
if (dimensions.current.width !== newSize.width || dimensions.current.height !== newSize.height) {
|
|
182
|
+
dimensions.current = newSize;
|
|
227
183
|
forceUpdate();
|
|
228
184
|
}
|
|
229
185
|
})();
|
|
230
186
|
}, [adFormat, adaptiveBannerEnabled, isInitialized, screenWidth, style]);
|
|
231
187
|
|
|
232
|
-
const onAdLoadedEvent = useCallback(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
);
|
|
238
|
-
|
|
239
|
-
const onAdLoadFailedEvent = useCallback(
|
|
240
|
-
(event: AdNativeEvent<AdLoadFailedInfo>) => {
|
|
241
|
-
onAdLoadFailed?.(event.nativeEvent);
|
|
242
|
-
},
|
|
243
|
-
[onAdLoadFailed]
|
|
244
|
-
);
|
|
245
|
-
|
|
246
|
-
const onAdDisplayFailedEvent = useCallback(
|
|
247
|
-
(event: AdNativeEvent<AdDisplayFailedInfo>) => {
|
|
248
|
-
onAdDisplayFailed?.(event.nativeEvent);
|
|
249
|
-
},
|
|
250
|
-
[onAdDisplayFailed]
|
|
251
|
-
);
|
|
252
|
-
|
|
253
|
-
const onAdClickedEvent = useCallback(
|
|
254
|
-
(event: AdNativeEvent<AdInfo>) => {
|
|
255
|
-
onAdClicked?.(event.nativeEvent);
|
|
256
|
-
},
|
|
257
|
-
[onAdClicked]
|
|
258
|
-
);
|
|
259
|
-
|
|
260
|
-
const onAdExpandedEvent = useCallback(
|
|
261
|
-
(event: AdNativeEvent<AdInfo>) => {
|
|
262
|
-
onAdExpanded?.(event.nativeEvent);
|
|
263
|
-
},
|
|
264
|
-
[onAdExpanded]
|
|
265
|
-
);
|
|
266
|
-
|
|
267
|
-
const onAdCollapsedEvent = useCallback(
|
|
268
|
-
(event: AdNativeEvent<AdInfo>) => {
|
|
269
|
-
onAdCollapsed?.(event.nativeEvent);
|
|
270
|
-
},
|
|
271
|
-
[onAdCollapsed]
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
const onAdRevenuePaidEvent = useCallback(
|
|
275
|
-
(event: AdNativeEvent<AdInfo>) => {
|
|
276
|
-
onAdRevenuePaid?.(event.nativeEvent);
|
|
277
|
-
},
|
|
278
|
-
[onAdRevenuePaid]
|
|
279
|
-
);
|
|
188
|
+
const onAdLoadedEvent = useCallback((event: NativeSyntheticEvent<AdInfoEvent>) => handleAdViewEvent(event, onAdLoaded), [onAdLoaded]);
|
|
189
|
+
const onAdLoadFailedEvent = useCallback((event: NativeSyntheticEvent<AdLoadFailedEvent>) => handleAdViewEvent(event, onAdLoadFailed), [onAdLoadFailed]);
|
|
190
|
+
const onAdDisplayFailedEvent = useCallback((event: NativeSyntheticEvent<AdDisplayFailedEvent>) => handleAdViewEvent(event, onAdDisplayFailed), [onAdDisplayFailed]);
|
|
191
|
+
const onAdClickedEvent = useCallback((event: NativeSyntheticEvent<AdInfoEvent>) => handleAdViewEvent(event, onAdClicked), [onAdClicked]);
|
|
192
|
+
const onAdExpandedEvent = useCallback((event: NativeSyntheticEvent<AdInfoEvent>) => handleAdViewEvent(event, onAdExpanded), [onAdExpanded]);
|
|
193
|
+
const onAdCollapsedEvent = useCallback((event: NativeSyntheticEvent<AdInfoEvent>) => handleAdViewEvent(event, onAdCollapsed), [onAdCollapsed]);
|
|
194
|
+
const onAdRevenuePaidEvent = useCallback((event: NativeSyntheticEvent<AdInfoEvent>) => handleAdViewEvent(event, onAdRevenuePaid), [onAdRevenuePaid]);
|
|
280
195
|
|
|
281
196
|
if (!isInitialized || Object.keys(dimensions.current).length === 0) {
|
|
282
197
|
// Early return if not initialized or dimensions are not set
|
|
283
|
-
return <View style={
|
|
198
|
+
return <View style={style} {...otherProps} />;
|
|
284
199
|
}
|
|
285
200
|
|
|
286
201
|
return (
|
|
287
202
|
<AdViewComponent
|
|
288
|
-
ref={
|
|
203
|
+
ref={(element) => (adViewRef.current = element ?? undefined)}
|
|
289
204
|
adUnitId={adUnitId}
|
|
290
205
|
adFormat={adFormat}
|
|
291
206
|
adViewId={adViewId || 0}
|
|
@@ -294,8 +209,9 @@ export const AdView = forwardRef<AdViewHandler, AdViewProps & ViewProps>(functio
|
|
|
294
209
|
adaptiveBannerEnabled={adaptiveBannerEnabled}
|
|
295
210
|
autoRefresh={autoRefresh}
|
|
296
211
|
loadOnMount={loadOnMount}
|
|
297
|
-
extraParameters={extraParameters}
|
|
298
|
-
|
|
212
|
+
extraParameters={makeExtraParametersArray(extraParameters)}
|
|
213
|
+
strLocalExtraParameters={makeLocalExtraParametersArray(localExtraParameters, 'str')}
|
|
214
|
+
boolLocalExtraParameters={makeLocalExtraParametersArray(localExtraParameters, 'bool')}
|
|
299
215
|
onAdLoadedEvent={onAdLoadedEvent}
|
|
300
216
|
onAdLoadFailedEvent={onAdLoadFailedEvent}
|
|
301
217
|
onAdDisplayFailedEvent={onAdDisplayFailedEvent}
|
|
@@ -303,7 +219,7 @@ export const AdView = forwardRef<AdViewHandler, AdViewProps & ViewProps>(functio
|
|
|
303
219
|
onAdExpandedEvent={onAdExpandedEvent}
|
|
304
220
|
onAdCollapsedEvent={onAdCollapsedEvent}
|
|
305
221
|
onAdRevenuePaidEvent={onAdRevenuePaidEvent}
|
|
306
|
-
style={
|
|
222
|
+
style={[style, dimensions.current]}
|
|
307
223
|
{...otherProps}
|
|
308
224
|
/>
|
|
309
225
|
);
|
|
@@ -316,14 +232,15 @@ export const AdView = forwardRef<AdViewHandler, AdViewProps & ViewProps>(functio
|
|
|
316
232
|
* - Unmounting {@link AdView} does not destroy the preloaded component—it will be reused on the next mount.
|
|
317
233
|
* - You must manually destroy the preloaded component when it is no longer needed using {@link destroyNativeUIComponentAdView}.
|
|
318
234
|
*
|
|
319
|
-
* @param adUnitId - The Ad Unit ID for which
|
|
235
|
+
* @param adUnitId - The Ad Unit ID for which ads should be preloaded.
|
|
320
236
|
* @param adFormat - The ad format to preload. Must be either {@link AdFormat.BANNER} or {@link AdFormat.MREC}.
|
|
321
237
|
* @param options - Optional properties to configure the native UI component (e.g., placement, custom data).
|
|
322
|
-
* @returns A promise
|
|
238
|
+
* @returns A promise that resolves to an {@link AdViewId}, uniquely identifying the preloaded component instance.
|
|
323
239
|
* @throws An error if the preload request fails.
|
|
324
240
|
*/
|
|
325
|
-
export const preloadNativeUIComponentAdView = async (adUnitId: string, adFormat: AdFormat, options
|
|
326
|
-
|
|
241
|
+
export const preloadNativeUIComponentAdView = async (adUnitId: string, adFormat: AdFormat, options: NativeUIComponentAdViewOptions = {}): Promise<AdViewId> => {
|
|
242
|
+
const { placement = null, customData = null, extraParameters = {}, localExtraParameters = {} } = options;
|
|
243
|
+
return AppLovinMAX.preloadNativeUIComponentAdView(adUnitId, adFormat, placement, customData, extraParameters, localExtraParameters);
|
|
327
244
|
};
|
|
328
245
|
|
|
329
246
|
/**
|
|
@@ -336,12 +253,14 @@ export const preloadNativeUIComponentAdView = async (adUnitId: string, adFormat:
|
|
|
336
253
|
* @throws An error if the destruction process fails.
|
|
337
254
|
*/
|
|
338
255
|
export const destroyNativeUIComponentAdView = async (adViewId: AdViewId): Promise<void> => {
|
|
256
|
+
if (adViewId === undefined) {
|
|
257
|
+
return Promise.reject(new Error('adViewId is not provided'));
|
|
258
|
+
}
|
|
339
259
|
return AppLovinMAX.destroyNativeUIComponentAdView(adViewId);
|
|
340
260
|
};
|
|
341
261
|
|
|
342
262
|
/**
|
|
343
|
-
* Adds the specified event listener to receive {@link AdInfo} when a native UI component loads a
|
|
344
|
-
* new ad.
|
|
263
|
+
* Adds the specified event listener to receive {@link AdInfo} when a native UI component loads a new ad.
|
|
345
264
|
*
|
|
346
265
|
* @param listener Listener to be notified.
|
|
347
266
|
*/
|
|
@@ -350,15 +269,14 @@ export const addNativeUIComponentAdViewAdLoadedEventListener = (listener: (adInf
|
|
|
350
269
|
};
|
|
351
270
|
|
|
352
271
|
/**
|
|
353
|
-
* Removes the event listener to receive {@link AdInfo} when a native UI component loads a new ad.
|
|
272
|
+
* Removes the event listener registered to receive {@link AdInfo} when a native UI component loads a new ad.
|
|
354
273
|
*/
|
|
355
274
|
export const removeNativeUIComponentAdViewAdLoadedEventListener = (): void => {
|
|
356
275
|
removeEventListener(ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOADED_EVENT);
|
|
357
276
|
};
|
|
358
277
|
|
|
359
278
|
/**
|
|
360
|
-
* Adds the specified event listener to receive {@link AdLoadFailedInfo} when a native UI component
|
|
361
|
-
* could not load a new ad.
|
|
279
|
+
* Adds the specified event listener to receive {@link AdLoadFailedInfo} when a native UI component could not load a new ad.
|
|
362
280
|
*
|
|
363
281
|
* @param listener Listener to be notified.
|
|
364
282
|
*/
|
|
@@ -367,8 +285,7 @@ export const addNativeUIComponentAdViewAdLoadFailedEventListener = (listener: (e
|
|
|
367
285
|
};
|
|
368
286
|
|
|
369
287
|
/**
|
|
370
|
-
* Removes the event listener to receive {@link AdLoadFailedInfo} when a native UI component could
|
|
371
|
-
* not load a new ad.
|
|
288
|
+
* Removes the event listener registered to receive {@link AdLoadFailedInfo} when a native UI component could not load a new ad.
|
|
372
289
|
*/
|
|
373
290
|
export const removeNativeUIComponentAdViewAdLoadFailedEventListener = (): void => {
|
|
374
291
|
removeEventListener(ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOAD_FAILED_EVENT);
|
package/src/AppLovinMAX.ts
CHANGED
|
@@ -1,96 +1,101 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
2
1
|
import type { AppLovinMAXType } from './types/AppLovinMAX';
|
|
3
2
|
import type { Configuration } from './types/Configuration';
|
|
3
|
+
import NativeAppLovinMAX from './specs/NativeAppLovinMAXModule';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const VERSION = '8.2.0';
|
|
5
|
+
const VERSION = '9.1.0';
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
|
-
*
|
|
11
|
-
* user.
|
|
8
|
+
* Represents the user's geography, used to determine which type of consent flow to display.
|
|
12
9
|
*/
|
|
13
10
|
export enum ConsentFlowUserGeography {
|
|
14
11
|
/**
|
|
15
|
-
*
|
|
12
|
+
* The user's geography could not be determined.
|
|
16
13
|
*/
|
|
17
14
|
UNKNOWN = 'U',
|
|
18
15
|
|
|
19
16
|
/**
|
|
20
|
-
* The user is in GDPR region.
|
|
17
|
+
* The user is located in a GDPR region.
|
|
21
18
|
*/
|
|
22
19
|
GDPR = 'G',
|
|
23
20
|
|
|
24
21
|
/**
|
|
25
|
-
* The user is in a
|
|
22
|
+
* The user is not in a GDPR region.
|
|
26
23
|
*/
|
|
27
24
|
OTHER = 'O',
|
|
28
25
|
}
|
|
29
26
|
|
|
30
27
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
28
|
+
* App tracking transparency status values as defined by the AppLovin SDK.
|
|
29
|
+
*
|
|
30
|
+
* These values are based on Apple's AppTrackingTransparency framework (iOS 14+).
|
|
33
31
|
*/
|
|
34
32
|
export enum AppTrackingStatus {
|
|
35
33
|
/**
|
|
36
|
-
* Device is
|
|
34
|
+
* Device is running an iOS version prior to iOS 14.
|
|
35
|
+
* AppTrackingTransparency is not available.
|
|
37
36
|
*/
|
|
38
37
|
UNAVAILABLE = 'U',
|
|
39
38
|
|
|
40
39
|
/**
|
|
41
|
-
* The user has not yet
|
|
42
|
-
* data that can be used for tracking the user or the device.
|
|
40
|
+
* The user has not yet responded to the tracking authorization prompt.
|
|
43
41
|
*/
|
|
44
42
|
NOT_DETERMINED = 'N',
|
|
45
43
|
|
|
46
44
|
/**
|
|
47
|
-
*
|
|
48
|
-
* is restricted.
|
|
45
|
+
* Tracking is restricted (e.g. due to parental controls).
|
|
49
46
|
*/
|
|
50
47
|
RESTRICTED = 'R',
|
|
51
48
|
|
|
52
49
|
/**
|
|
53
|
-
* The user
|
|
54
|
-
* user or the device.
|
|
50
|
+
* The user denied authorization for tracking.
|
|
55
51
|
*/
|
|
56
52
|
DENIED = 'D',
|
|
57
53
|
|
|
58
54
|
/**
|
|
59
|
-
* The user
|
|
60
|
-
* device.
|
|
55
|
+
* The user authorized tracking access.
|
|
61
56
|
*/
|
|
62
57
|
AUTHORIZED = 'A',
|
|
63
58
|
}
|
|
64
59
|
|
|
65
60
|
/**
|
|
66
|
-
*
|
|
61
|
+
* Error codes returned from the Consent Management Platform (CMP) flow.
|
|
67
62
|
*/
|
|
68
63
|
export enum CMPErrorCode {
|
|
69
64
|
/**
|
|
70
|
-
*
|
|
65
|
+
* An unspecified error occurred.
|
|
71
66
|
*/
|
|
72
67
|
UNSPECIFIED = -1,
|
|
73
68
|
|
|
74
69
|
/**
|
|
75
|
-
*
|
|
70
|
+
* The CMP was not integrated correctly.
|
|
76
71
|
*/
|
|
77
72
|
INTEGRATION_ERROR = 1,
|
|
78
73
|
|
|
79
74
|
/**
|
|
80
|
-
*
|
|
75
|
+
* The CMP form is unavailable.
|
|
81
76
|
*/
|
|
82
77
|
FORM_UNAVAILABLE = 2,
|
|
83
78
|
|
|
84
79
|
/**
|
|
85
|
-
*
|
|
80
|
+
* The CMP form is not required for this user.
|
|
86
81
|
*/
|
|
87
82
|
FORM_NOT_REQUIRED = 3,
|
|
88
83
|
}
|
|
89
84
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Initializes the AppLovin MAX SDK with the provided SDK key.
|
|
87
|
+
*
|
|
88
|
+
* @param sdkKey - Your AppLovin SDK key.
|
|
89
|
+
* @returns A promise that resolves with the SDK configuration.
|
|
90
|
+
*/
|
|
91
|
+
const initialize = (sdkKey: string): Promise<Configuration> => NativeAppLovinMAX.initialize(VERSION, sdkKey);
|
|
93
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Retrieves the user segments.
|
|
95
|
+
*
|
|
96
|
+
* @returns A promise resolving to a Map of segment IDs to arrays of group IDs,
|
|
97
|
+
* or `null` if no segments are available.
|
|
98
|
+
*/
|
|
94
99
|
const getSegments = async (): Promise<Map<number, number[]> | null> => {
|
|
95
100
|
const segments = await NativeAppLovinMAX.getSegments();
|
|
96
101
|
|
|
@@ -100,21 +105,25 @@ const getSegments = async (): Promise<Map<number, number[]> | null> => {
|
|
|
100
105
|
|
|
101
106
|
const map = new Map<number, number[]>();
|
|
102
107
|
|
|
103
|
-
for (const key
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
map.set(Number(key), segments[key]);
|
|
108
|
+
for (const [key, value] of Object.entries(segments)) {
|
|
109
|
+
// In JavaScript, object keys are always strings, so we convert them to numbers for the Map.
|
|
110
|
+
if (value) {
|
|
111
|
+
map.set(Number(key), value);
|
|
108
112
|
}
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
return map;
|
|
112
116
|
};
|
|
113
117
|
|
|
118
|
+
// All native methods except those overridden here
|
|
114
119
|
type NativeAppLovinMAXType = Omit<AppLovinMAXType, 'initialize' | 'getSegments'>;
|
|
115
120
|
|
|
116
121
|
const nativeMethods: NativeAppLovinMAXType = NativeAppLovinMAX;
|
|
117
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Main AppLovin MAX module interface exposed to JavaScript.
|
|
125
|
+
* Wraps the native module and overrides `initialize()` and `getSegments()` for custom handling.
|
|
126
|
+
*/
|
|
118
127
|
export const AppLovinMAX: AppLovinMAXType = Object.create(nativeMethods, {
|
|
119
128
|
initialize: {
|
|
120
129
|
value: initialize,
|
package/src/AppOpenAd.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
2
1
|
import { addEventListener, removeEventListener } from './EventEmitter';
|
|
3
2
|
import type { AdDisplayFailedInfo, AdInfo, AdLoadFailedInfo } from './types/AdInfo';
|
|
4
3
|
import type { LocalExtraParameterValue } from './types/AdProps';
|
|
5
4
|
import type { AppOpenAdType } from './types/AppOpenAd';
|
|
6
|
-
|
|
7
|
-
const { AppLovinMAX } = NativeModules;
|
|
5
|
+
import AppLovinMAX from './specs/NativeAppLovinMAXModule';
|
|
8
6
|
|
|
9
7
|
const {
|
|
10
8
|
ON_APPOPEN_AD_LOADED_EVENT,
|
package/src/BannerAd.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
2
1
|
import { addEventListener, removeEventListener } from './EventEmitter';
|
|
3
2
|
import type { AdInfo, AdLoadFailedInfo } from './types/AdInfo';
|
|
4
3
|
import type { LocalExtraParameterValue } from './types/AdProps';
|
|
5
4
|
import type { BannerAdType } from './types/BannerAd';
|
|
6
5
|
import type { AdViewPosition } from './AdView';
|
|
7
|
-
|
|
8
|
-
const { AppLovinMAX } = NativeModules;
|
|
6
|
+
import AppLovinMAX from './specs/NativeAppLovinMAXModule';
|
|
9
7
|
|
|
10
8
|
const {
|
|
11
9
|
ON_BANNER_AD_LOADED_EVENT,
|