react-native-applovin-max 5.7.2 → 6.0.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 (52) hide show
  1. package/README.md +1 -1
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/com/applovin/mediation/adapters/GoogleAdManagerMediationAdapter.java.saved +1616 -0
  4. package/android/src/main/java/com/applovin/mediation/adapters/{GoogleMediationAdapter.java.saved → GoogleMediationAdapter.java.old} +126 -49
  5. package/android/src/main/java/com/applovin/mediation/adapters/MintegralMediationAdapter.java.old +1481 -0
  6. package/ios/AppLovinMAX.m +1 -9
  7. package/ios/AppLovinMAX.xcodeproj/project.pbxproj +4 -4
  8. package/ios/AppLovinMAX.xcworkspace/xcuserdata/hiroshi.watanabe.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  9. package/ios/AppLovinMAXNativeAdView.m +8 -1
  10. package/ios/Podfile +2 -2
  11. package/ios/Podfile.lock +5 -5
  12. package/package.json +2 -1
  13. package/react-native-applovin-max.podspec +2 -2
  14. package/src/AdView.tsx +251 -0
  15. package/src/AppLovinMAX.ts +24 -0
  16. package/src/AppOpenAd.ts +128 -0
  17. package/src/BannerAd.ts +175 -0
  18. package/src/EventEmitter.ts +27 -0
  19. package/src/InterstitialAd.ts +128 -0
  20. package/src/MRecAd.ts +147 -0
  21. package/src/Privacy.ts +6 -0
  22. package/src/RewardedAd.ts +144 -0
  23. package/src/TargetingData.ts +214 -0
  24. package/src/index.ts +21 -0
  25. package/src/nativeAd/NativeAdView.tsx +162 -0
  26. package/src/nativeAd/NativeAdViewComponents.tsx +185 -0
  27. package/src/nativeAd/NativeAdViewProvider.tsx +35 -0
  28. package/src/types/AdEvent.ts +26 -0
  29. package/src/types/AdInfo.ts +348 -0
  30. package/src/types/AdProps.ts +60 -0
  31. package/src/types/AdViewProps.ts +36 -0
  32. package/src/types/AppLovinMAX.ts +87 -0
  33. package/src/types/AppOpenAd.ts +3 -0
  34. package/src/types/BannerAd.ts +47 -0
  35. package/src/types/Configuration.ts +11 -0
  36. package/src/types/FullscreenAd.ts +141 -0
  37. package/src/types/InterstitialAd.ts +3 -0
  38. package/src/types/MRecAd.ts +13 -0
  39. package/src/types/NativeAd.ts +50 -0
  40. package/src/types/NativeAdViewProps.ts +17 -0
  41. package/src/types/Privacy.ts +74 -0
  42. package/src/types/RewardedAd.ts +20 -0
  43. package/src/types/TargetingData.ts +51 -0
  44. package/src/types/ViewAd.ts +162 -0
  45. package/src/types/index.ts +4 -0
  46. package/src/AppLovinMAXAdView.js +0 -231
  47. package/src/AppLovinMAXEventListeners.js +0 -419
  48. package/src/NativeAdComponents.js +0 -208
  49. package/src/NativeAdView.js +0 -164
  50. package/src/NativeAdViewProvider.js +0 -19
  51. package/src/TargetingData.js +0 -104
  52. package/src/index.js +0 -291
package/ios/AppLovinMAX.m CHANGED
@@ -1777,15 +1777,7 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
1777
1777
  // All positions have constant height
1778
1778
  NSMutableArray<NSLayoutConstraint *> *constraints = [NSMutableArray arrayWithObject: [adView.heightAnchor constraintEqualToConstant: adViewSize.height]];
1779
1779
 
1780
- UILayoutGuide *layoutGuide;
1781
- if ( @available(iOS 11.0, *) )
1782
- {
1783
- layoutGuide = superview.safeAreaLayoutGuide;
1784
- }
1785
- else
1786
- {
1787
- layoutGuide = superview.layoutMarginsGuide;
1788
- }
1780
+ UILayoutGuide *layoutGuide = superview.safeAreaLayoutGuide;
1789
1781
 
1790
1782
  // If top of bottom center, stretch width of screen
1791
1783
  if ( [adViewPosition isEqual: TOP_CENTER] || [adViewPosition isEqual: BOTTOM_CENTER] )
@@ -240,7 +240,7 @@
240
240
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
241
241
  GCC_WARN_UNUSED_FUNCTION = YES;
242
242
  GCC_WARN_UNUSED_VARIABLE = YES;
243
- IPHONEOS_DEPLOYMENT_TARGET = 10.0;
243
+ IPHONEOS_DEPLOYMENT_TARGET = 11.0;
244
244
  MTL_ENABLE_DEBUG_INFO = YES;
245
245
  ONLY_ACTIVE_ARCH = YES;
246
246
  SDKROOT = iphoneos;
@@ -286,7 +286,7 @@
286
286
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
287
287
  GCC_WARN_UNUSED_FUNCTION = YES;
288
288
  GCC_WARN_UNUSED_VARIABLE = YES;
289
- IPHONEOS_DEPLOYMENT_TARGET = 10.0;
289
+ IPHONEOS_DEPLOYMENT_TARGET = 11.0;
290
290
  MTL_ENABLE_DEBUG_INFO = NO;
291
291
  SDKROOT = iphoneos;
292
292
  VALIDATE_PRODUCT = YES;
@@ -307,7 +307,7 @@
307
307
  "$(SRCROOT)/../../../React/**",
308
308
  "$(SRCROOT)/../../react-native/React/**",
309
309
  );
310
- IPHONEOS_DEPLOYMENT_TARGET = 10.0;
310
+ IPHONEOS_DEPLOYMENT_TARGET = 11.0;
311
311
  LIBRARY_SEARCH_PATHS = "$(inherited)";
312
312
  OTHER_LDFLAGS = "-ObjC";
313
313
  PRODUCT_NAME = AppLovinMAX;
@@ -331,7 +331,7 @@
331
331
  "$(SRCROOT)/../../../React/**",
332
332
  "$(SRCROOT)/../../react-native/React/**",
333
333
  );
334
- IPHONEOS_DEPLOYMENT_TARGET = 10.0;
334
+ IPHONEOS_DEPLOYMENT_TARGET = 11.0;
335
335
  LIBRARY_SEARCH_PATHS = "$(inherited)";
336
336
  OTHER_LDFLAGS = "-ObjC";
337
337
  PRODUCT_NAME = AppLovinMAX;
@@ -221,7 +221,14 @@
221
221
  if ( !icon.URL && icon.image )
222
222
  {
223
223
  RCTImageView *iconImageView = (RCTImageView *) view;
224
- iconImageView.defaultImage = icon.image;
224
+ if ( [iconImageView respondsToSelector: @selector(setImage:)] )
225
+ {
226
+ [iconImageView performSelector: @selector(setImage:) withObject: icon.image];
227
+ }
228
+ else
229
+ {
230
+ [[AppLovinMAX shared] log: @"Unable to set native ad IconView image"];
231
+ }
225
232
  }
226
233
  }
227
234
  }
package/ios/Podfile CHANGED
@@ -1,5 +1,5 @@
1
1
  # Uncomment the next line to define a global platform for your project
2
- platform :ios, '10.0'
2
+ platform :ios, '11.0'
3
3
  require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
4
4
 
5
5
  target 'AppLovinMAX' do
@@ -35,6 +35,6 @@ target 'AppLovinMAX' do
35
35
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
36
36
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
37
37
 
38
- pod 'AppLovinSDK', '11.11.3'
38
+ pod 'AppLovinSDK', '11.11.4'
39
39
 
40
40
  end
package/ios/Podfile.lock CHANGED
@@ -1,5 +1,5 @@
1
1
  PODS:
2
- - AppLovinSDK (11.11.3)
2
+ - AppLovinSDK (11.11.4)
3
3
  - boost-for-react-native (1.63.0)
4
4
  - DoubleConversion (1.1.6)
5
5
  - FBLazyVector (0.63.5)
@@ -249,7 +249,7 @@ PODS:
249
249
  - Yoga (1.14.0)
250
250
 
251
251
  DEPENDENCIES:
252
- - AppLovinSDK (= 11.11.3)
252
+ - AppLovinSDK (= 11.11.4)
253
253
  - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
254
254
  - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
255
255
  - FBReactNativeSpec (from `../node_modules/react-native/Libraries/FBReactNativeSpec`)
@@ -339,7 +339,7 @@ EXTERNAL SOURCES:
339
339
  :path: "../node_modules/react-native/ReactCommon/yoga"
340
340
 
341
341
  SPEC CHECKSUMS:
342
- AppLovinSDK: 623ef78363c0dd2c3ff5446cde37e4920a96b7e0
342
+ AppLovinSDK: 5c667a790725d9529c01c3f3acf12ab195865fbb
343
343
  boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
344
344
  DoubleConversion: cde416483dac037923206447da6e1454df403714
345
345
  FBLazyVector: 352a8ca9bbc8e2f097d680747a8c97ecef12d469
@@ -368,6 +368,6 @@ SPEC CHECKSUMS:
368
368
  ReactCommon: b9ff54b6dd22ba4a776eda22d7f83ec27544ca35
369
369
  Yoga: 0276e9f20976c8568e107cfc1163a8629051adc0
370
370
 
371
- PODFILE CHECKSUM: 0e638fe64c425ebeff3ccbfd5c809f3b35246730
371
+ PODFILE CHECKSUM: 76a08f1862fba288a559d37757b6d80d45c19d6e
372
372
 
373
- COCOAPODS: 1.12.1
373
+ COCOAPODS: 1.11.3
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-applovin-max",
3
3
  "author": "AppLovin Corporation",
4
- "version": "5.7.2",
4
+ "version": "6.0.1",
5
5
  "description": "AppLovin MAX React Native Plugin for Android and iOS",
6
6
  "homepage": "https://github.com/AppLovin/AppLovin-MAX-React-Native",
7
7
  "license": "MIT",
@@ -24,6 +24,7 @@
24
24
  ],
25
25
  "repository": "https://github.com/AppLovin/AppLovin-MAX-React-Native",
26
26
  "devDependencies": {
27
+ "@types/react-native": "^0.63.1",
27
28
  "react": "^16.13.1",
28
29
  "react-native": "^0.63.1"
29
30
  },
@@ -11,10 +11,10 @@ Pod::Spec.new do |s|
11
11
  s.authors = package["author"]
12
12
 
13
13
  s.platforms = { :ios => "10.0" }
14
- s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_5_7_2" }
14
+ s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_6_0_1" }
15
15
 
16
16
  s.source_files = "ios/AppLovinMAX*.{h,m}"
17
17
 
18
18
  s.dependency "React"
19
- s.dependency "AppLovinSDK", "11.11.3"
19
+ s.dependency "AppLovinSDK", "11.11.4"
20
20
  end
package/src/AdView.tsx ADDED
@@ -0,0 +1,251 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import { NativeModules, requireNativeComponent, StyleSheet } from "react-native";
3
+ import type { ViewProps, ViewStyle, StyleProp } from "react-native";
4
+ import type { AdDisplayFailedInfo, AdInfo, AdLoadFailedInfo, AdRevenueInfo } from "./types/AdInfo";
5
+ import type { AdNativeEvent } from "./types/AdEvent";
6
+ import type { AdViewProps } from "./types/AdViewProps";
7
+
8
+ const { AppLovinMAX } = NativeModules;
9
+
10
+ const {
11
+ BANNER_AD_FORMAT_LABEL,
12
+ MREC_AD_FORMAT_LABEL,
13
+
14
+ TOP_CENTER_POSITION,
15
+ TOP_LEFT_POSITION,
16
+ TOP_RIGHT_POSITION,
17
+ CENTERED_POSITION,
18
+ CENTER_LEFT_POSITION,
19
+ CENTER_RIGHT_POSITION,
20
+ BOTTOM_LEFT_POSITION,
21
+ BOTTOM_CENTER_POSITION,
22
+ BOTTOM_RIGHT_POSITION,
23
+ } = AppLovinMAX.getConstants();
24
+
25
+ /**
26
+ * Defines a format of an ad.
27
+ */
28
+ export enum AdFormat {
29
+
30
+ /**
31
+ * Banner ad.
32
+ */
33
+ BANNER = BANNER_AD_FORMAT_LABEL,
34
+
35
+ /**
36
+ * MREC ad.
37
+ */
38
+ MREC = MREC_AD_FORMAT_LABEL,
39
+ }
40
+
41
+ /**
42
+ * Defines a position of a banner or MREC ad.
43
+ */
44
+ export enum AdViewPosition {
45
+ TOP_CENTER = TOP_CENTER_POSITION,
46
+ TOP_LEFT = TOP_LEFT_POSITION,
47
+ TOP_RIGHT = TOP_RIGHT_POSITION,
48
+ CENTERED = CENTERED_POSITION,
49
+ CENTER_LEFT = CENTER_LEFT_POSITION,
50
+ CENTER_RIGHT = CENTER_RIGHT_POSITION,
51
+ BOTTOM_LEFT = BOTTOM_LEFT_POSITION,
52
+ BOTTOM_CENTER = BOTTOM_CENTER_POSITION,
53
+ BOTTOM_RIGHT = BOTTOM_RIGHT_POSITION,
54
+ }
55
+
56
+ type AdViewNativeEvents = {
57
+ onAdLoadedEvent(event: AdNativeEvent<AdInfo>): void
58
+ onAdLoadFailedEvent(event: AdNativeEvent<AdLoadFailedInfo>): void
59
+ onAdDisplayFailedEvent(event: AdNativeEvent<AdDisplayFailedInfo>): void
60
+ onAdClickedEvent(event: AdNativeEvent<AdInfo>): void
61
+ onAdExpandedEvent(event: AdNativeEvent<AdInfo>): void
62
+ onAdCollapsedEvent(event: AdNativeEvent<AdInfo>): void
63
+ onAdRevenuePaidEvent(event: AdNativeEvent<AdRevenueInfo>): void
64
+ }
65
+
66
+ const AdViewComponent = requireNativeComponent<AdViewProps & ViewProps & AdViewNativeEvents>("AppLovinMAXAdView");
67
+
68
+ const ADVIEW_SIZE = {
69
+ banner: { width: 320, height: 50 },
70
+ leader: { width: 728, height: 90 },
71
+ mrec: { width: 300, height: 250 },
72
+ };
73
+
74
+ const getOutlineViewSize = (style: StyleProp<ViewStyle>) => {
75
+ const viewStyle = StyleSheet.flatten(style || {});
76
+ return [viewStyle?.width, viewStyle?.height];
77
+ };
78
+
79
+ const sizeAdViewDimensions = (adFormat: AdFormat, adaptiveBannerEnabled?: boolean, width?: number | string, height?: number | string): Promise<{}> => {
80
+ const sizeForBannerFormat = async () => {
81
+ const isTablet = await AppLovinMAX.isTablet();
82
+
83
+ const minWidth = isTablet ? ADVIEW_SIZE.leader.width : ADVIEW_SIZE.banner.width;
84
+
85
+ let minHeight;
86
+ if (adaptiveBannerEnabled) {
87
+ if (typeof width === "number" && width > minWidth) {
88
+ minHeight = await AppLovinMAX.getAdaptiveBannerHeightForWidth(width);
89
+ } else {
90
+ minHeight = await AppLovinMAX.getAdaptiveBannerHeightForWidth(minWidth);
91
+ }
92
+ } else {
93
+ minHeight = isTablet ? ADVIEW_SIZE.leader.height : ADVIEW_SIZE.banner.height;
94
+ }
95
+
96
+ return Promise.resolve({
97
+ ...width === "auto" ? {
98
+ width: minWidth,
99
+ } : {
100
+ minWidth: minWidth,
101
+ },
102
+ ...height === "auto" ? {
103
+ height: minHeight,
104
+ } : {
105
+ minHeight: minHeight,
106
+ }
107
+ });
108
+ }
109
+
110
+ if (adFormat === AdFormat.BANNER) {
111
+ return sizeForBannerFormat();
112
+ } else {
113
+ return Promise.resolve({
114
+ ...width === "auto" ? {
115
+ width: ADVIEW_SIZE.mrec.width,
116
+ } : {
117
+ minWidth: ADVIEW_SIZE.mrec.width,
118
+ },
119
+ ...height === "auto" ? {
120
+ height: ADVIEW_SIZE.mrec.height,
121
+ } : {
122
+ minHeight: ADVIEW_SIZE.mrec.height,
123
+ }
124
+ });
125
+ }
126
+ }
127
+
128
+ /**
129
+ * The {@link AdView} component that you use building a banner or an MREC. Phones
130
+ * sizes banners to 320x50 and MRECs to 300x250. Tablets sizes banners to 728x90 and MRECs to
131
+ * 300x250. You may use the utility method {@link AppLovinMAX.isTablet()} to help with view sizing
132
+ * adjustments. For adaptive banners, call {@link BannerAd.getAdaptiveHeightForWidth()} to get
133
+ * the banner height, and then adjust your content accordingly.
134
+ *
135
+ * ### Example:
136
+ * ```js
137
+ * <AdView
138
+ * adUnitId={adUnitId}
139
+ * adFormat={AdFormat.BANNER}
140
+ * placement="my_placement"
141
+ * customData="my_customData"
142
+ * extraParameters={{"key1":"value1", "key2":"value2"}}
143
+ * localExtraParameters={{"key1":123", "key2":object}}
144
+ * adaptiveBannerEnabled={false}
145
+ * autoRefresh={false}
146
+ * style={styles.banner}
147
+ * onAdLoaded={(adInfo: AdInfo) => { ... }}
148
+ * />
149
+ * ```
150
+ */
151
+ export const AdView = ({
152
+ adUnitId,
153
+ adFormat,
154
+ placement,
155
+ customData,
156
+ adaptiveBannerEnabled = true,
157
+ autoRefresh = true,
158
+ extraParameters,
159
+ localExtraParameters,
160
+ onAdLoaded,
161
+ onAdLoadFailed,
162
+ onAdDisplayFailed,
163
+ onAdClicked,
164
+ onAdExpanded,
165
+ onAdCollapsed,
166
+ onAdRevenuePaid,
167
+ style,
168
+ ...otherProps
169
+ }: AdViewProps & ViewProps) => {
170
+ const [isInitialized, setIsInitialized] = useState<boolean>(false);
171
+ const [dimensions, setDimensions] = useState({});
172
+
173
+ useEffect(() => {
174
+ AppLovinMAX.isInitialized().then((result: boolean) => {
175
+ setIsInitialized(result);
176
+ if (!result) {
177
+ console.warn("ERROR: AdView is mounted before the initialization of the AppLovin MAX React Native module");
178
+ }
179
+ });
180
+ }, []);
181
+
182
+ useEffect(() => {
183
+ if (!isInitialized) return;
184
+ const [width, height] = getOutlineViewSize(style);
185
+ sizeAdViewDimensions(adFormat, adaptiveBannerEnabled, width, height).then((value: {}) => {
186
+ setDimensions(value);
187
+ });
188
+ }, [isInitialized]);
189
+
190
+ const onAdLoadedEvent = (event: AdNativeEvent<AdInfo>) => {
191
+ if (onAdLoaded) onAdLoaded(event.nativeEvent);
192
+ };
193
+
194
+ const onAdLoadFailedEvent = (event: AdNativeEvent<AdLoadFailedInfo>) => {
195
+ if (onAdLoadFailed) onAdLoadFailed(event.nativeEvent);
196
+ };
197
+
198
+ const onAdDisplayFailedEvent = (event: AdNativeEvent<AdDisplayFailedInfo>) => {
199
+ if (onAdDisplayFailed) onAdDisplayFailed(event.nativeEvent);
200
+ };
201
+
202
+ const onAdClickedEvent = (event: AdNativeEvent<AdInfo>) => {
203
+ if (onAdClicked) onAdClicked(event.nativeEvent);
204
+ };
205
+
206
+ const onAdExpandedEvent = (event: AdNativeEvent<AdInfo>) => {
207
+ if (onAdExpanded) onAdExpanded(event.nativeEvent);
208
+ };
209
+
210
+ const onAdCollapsedEvent = (event: AdNativeEvent<AdInfo>) => {
211
+ if (onAdCollapsed) onAdCollapsed(event.nativeEvent);
212
+ };
213
+
214
+ const onAdRevenuePaidEvent = (event: AdNativeEvent<AdRevenueInfo>) => {
215
+ if (onAdRevenuePaid) onAdRevenuePaid(event.nativeEvent);
216
+ };
217
+
218
+ // Not initialized
219
+ if (!isInitialized) {
220
+ return null;
221
+ } else {
222
+ const isDimensionsSet = (Object.keys(dimensions).length > 0);
223
+
224
+ // Not sized yet
225
+ if (!isDimensionsSet) {
226
+ return null;
227
+ }
228
+ }
229
+
230
+ return (
231
+ <AdViewComponent
232
+ adUnitId={adUnitId}
233
+ adFormat={adFormat}
234
+ placement={placement}
235
+ customData={customData}
236
+ adaptiveBannerEnabled={adaptiveBannerEnabled}
237
+ autoRefresh={autoRefresh}
238
+ extraParameters={extraParameters}
239
+ localExtraParameters={localExtraParameters}
240
+ onAdLoadedEvent={onAdLoadedEvent}
241
+ onAdLoadFailedEvent={onAdLoadFailedEvent}
242
+ onAdDisplayFailedEvent={onAdDisplayFailedEvent}
243
+ onAdClickedEvent={onAdClickedEvent}
244
+ onAdExpandedEvent={onAdExpandedEvent}
245
+ onAdCollapsedEvent={onAdCollapsedEvent}
246
+ onAdRevenuePaidEvent={onAdRevenuePaidEvent}
247
+ style={Object.assign({}, style, dimensions)}
248
+ {...otherProps}
249
+ />
250
+ );
251
+ };
@@ -0,0 +1,24 @@
1
+ import { NativeModules } from "react-native";
2
+ import type { AppLovinMAXType } from "./types/AppLovinMAX";
3
+ import type { Configuration } from "./types/Configuration";
4
+
5
+ const NativeAppLovinMAX = NativeModules.AppLovinMAX;
6
+
7
+ const VERSION = "6.0.1";
8
+
9
+ const initialize = async (
10
+ sdkKey: string
11
+ ): Promise<Configuration> => {
12
+ return NativeAppLovinMAX.initialize(VERSION, sdkKey);
13
+ }
14
+
15
+ type NativeAppLovinMAXType = Omit<AppLovinMAXType, | 'initialize'>;
16
+
17
+ const nativeMethods: NativeAppLovinMAXType = NativeAppLovinMAX;
18
+
19
+ export const AppLovinMAX: AppLovinMAXType = {
20
+ ...nativeMethods,
21
+ initialize,
22
+ }
23
+
24
+ export default AppLovinMAX;
@@ -0,0 +1,128 @@
1
+ import { NativeModules } from "react-native";
2
+ import { addEventListener, removeEventListener } from "./EventEmitter"
3
+ import type { AdDisplayFailedInfo, AdInfo, AdLoadFailedInfo, AdRevenueInfo } from "./types/AdInfo";
4
+ import type { AppOpenAdType } from "./types/AppOpenAd";
5
+
6
+ const { AppLovinMAX } = NativeModules;
7
+
8
+ const {
9
+ ON_APPOPEN_AD_LOADED_EVENT,
10
+ ON_APPOPEN_AD_LOAD_FAILED_EVENT,
11
+ ON_APPOPEN_AD_CLICKED_EVENT,
12
+ ON_APPOPEN_AD_DISPLAYED_EVENT,
13
+ ON_APPOPEN_AD_FAILED_TO_DISPLAY_EVENT,
14
+ ON_APPOPEN_AD_HIDDEN_EVENT,
15
+ ON_APPOPEN_AD_REVENUE_PAID,
16
+ } = AppLovinMAX.getConstants();
17
+
18
+ const isAdReady = (adUnitId: string): Promise<boolean> => {
19
+ return AppLovinMAX.isAppOpenAdReady(adUnitId);
20
+ }
21
+
22
+ const loadAd = (adUnitId: string): void => {
23
+ AppLovinMAX.loadAppOpenAd(adUnitId);
24
+ }
25
+
26
+ const showAd = (
27
+ adUnitId: string,
28
+ placement?: string | null,
29
+ customData?: string | null
30
+ ): void => {
31
+ AppLovinMAX.showAppOpenAd(adUnitId, placement ?? undefined, customData ?? undefined);
32
+ }
33
+
34
+ const setExtraParameter = (adUnitId: string, key: string, value: any): void => {
35
+ AppLovinMAX.setAppOpenAdExtraParameter(adUnitId, key, value);
36
+ }
37
+
38
+ const setLocalExtraParameter = (adUnitId: string, key: string, value: any): void => {
39
+ AppLovinMAX.setAppOpenAdLocalExtraParameter(adUnitId, { [key]: value });
40
+ }
41
+
42
+ const addAdLoadedEventListener = (listener: (adInfo: AdInfo) => void) => {
43
+ addEventListener(ON_APPOPEN_AD_LOADED_EVENT, (adInfo: AdInfo) => listener(adInfo));
44
+ }
45
+
46
+ const removeAdLoadedEventListener = () => {
47
+ removeEventListener(ON_APPOPEN_AD_LOADED_EVENT);
48
+ }
49
+
50
+ const addAdLoadFailedEventListener = (listener: (errorInfo: AdLoadFailedInfo) => void) => {
51
+ addEventListener(ON_APPOPEN_AD_LOAD_FAILED_EVENT, (errorInfo: AdLoadFailedInfo) => listener(errorInfo));
52
+ }
53
+
54
+ const removeAdLoadFailedEventListener = () => {
55
+ removeEventListener(ON_APPOPEN_AD_LOAD_FAILED_EVENT);
56
+ }
57
+
58
+ const addAdClickedEventListener = (listener: (adInfo: AdInfo) => void) => {
59
+ addEventListener(ON_APPOPEN_AD_CLICKED_EVENT, (adInfo: AdInfo) => listener(adInfo));
60
+ }
61
+
62
+ const removeAdClickedEventListener = () => {
63
+ removeEventListener(ON_APPOPEN_AD_CLICKED_EVENT);
64
+ }
65
+
66
+ const addAdDisplayedEventListener = (listener: (adInfo: AdInfo) => void) => {
67
+ addEventListener(ON_APPOPEN_AD_DISPLAYED_EVENT, (adInfo: AdInfo) => listener(adInfo));
68
+ }
69
+
70
+ const removeAdDisplayedEventListener = () => {
71
+ removeEventListener(ON_APPOPEN_AD_DISPLAYED_EVENT);
72
+ }
73
+
74
+ const addAdFailedToDisplayEventListener = (listener: (errorInfo: AdDisplayFailedInfo) => void) => {
75
+ addEventListener(ON_APPOPEN_AD_FAILED_TO_DISPLAY_EVENT, (errorInfo: AdDisplayFailedInfo) => listener(errorInfo));
76
+ }
77
+
78
+ const removeAdFailedToDisplayEventListener = () => {
79
+ removeEventListener(ON_APPOPEN_AD_FAILED_TO_DISPLAY_EVENT);
80
+ }
81
+
82
+ const addAdHiddenEventListener = (listener: (adInfo: AdInfo) => void) => {
83
+ addEventListener(ON_APPOPEN_AD_HIDDEN_EVENT, (adInfo: AdInfo) => listener(adInfo));
84
+ }
85
+
86
+ const removeAdHiddenEventListener = () => {
87
+ removeEventListener(ON_APPOPEN_AD_HIDDEN_EVENT);
88
+ }
89
+
90
+ const addAdRevenuePaidListener = (listener: (adInfo: AdRevenueInfo) => void) => {
91
+ addEventListener(ON_APPOPEN_AD_REVENUE_PAID, (adInfo: AdRevenueInfo) => listener(adInfo));
92
+ }
93
+
94
+ const removeAdRevenuePaidListener = () => {
95
+ removeEventListener(ON_APPOPEN_AD_REVENUE_PAID);
96
+ }
97
+
98
+ export const AppOpenAd: AppOpenAdType = {
99
+ isAdReady,
100
+ loadAd,
101
+ showAd,
102
+
103
+ setExtraParameter,
104
+ setLocalExtraParameter,
105
+
106
+ addAdLoadedEventListener,
107
+ removeAdLoadedEventListener,
108
+
109
+ addAdLoadFailedEventListener,
110
+ removeAdLoadFailedEventListener,
111
+
112
+ addAdClickedEventListener,
113
+ removeAdClickedEventListener,
114
+
115
+ addAdDisplayedEventListener,
116
+ removeAdDisplayedEventListener,
117
+
118
+ addAdFailedToDisplayEventListener,
119
+ removeAdFailedToDisplayEventListener,
120
+
121
+ addAdHiddenEventListener,
122
+ removeAdHiddenEventListener,
123
+
124
+ addAdRevenuePaidListener,
125
+ removeAdRevenuePaidListener,
126
+ }
127
+
128
+ export default AppOpenAd;