react-native-applovin-max 6.0.1 → 6.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 (44) hide show
  1. package/android/build.gradle +3 -3
  2. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXModule.java +127 -20
  3. package/ios/AppLovinMAX.m +154 -25
  4. package/ios/Podfile +1 -1
  5. package/ios/Podfile.lock +4 -4
  6. package/package.json +5 -1
  7. package/react-native-applovin-max.podspec +2 -2
  8. package/src/AdView.tsx +58 -43
  9. package/src/AppLovinMAX.ts +8 -10
  10. package/src/AppOpenAd.ts +28 -31
  11. package/src/BannerAd.ts +36 -35
  12. package/src/EventEmitter.ts +9 -9
  13. package/src/InterstitialAd.ts +31 -32
  14. package/src/MRecAd.ts +32 -31
  15. package/src/Privacy.ts +58 -2
  16. package/src/RewardedAd.ts +31 -34
  17. package/src/TargetingData.ts +46 -35
  18. package/src/index.ts +12 -12
  19. package/src/nativeAd/NativeAdView.tsx +64 -55
  20. package/src/nativeAd/NativeAdViewComponents.tsx +38 -29
  21. package/src/nativeAd/NativeAdViewProvider.tsx +16 -13
  22. package/src/types/AdEvent.ts +2 -13
  23. package/src/types/AdInfo.ts +6 -18
  24. package/src/types/AdProps.ts +7 -3
  25. package/src/types/AdViewProps.ts +4 -5
  26. package/src/types/AppLovinMAX.ts +14 -8
  27. package/src/types/AppOpenAd.ts +1 -1
  28. package/src/types/BannerAd.ts +8 -9
  29. package/src/types/Configuration.ts +28 -3
  30. package/src/types/FullscreenAd.ts +19 -19
  31. package/src/types/InterstitialAd.ts +1 -1
  32. package/src/types/MRecAd.ts +3 -4
  33. package/src/types/NativeAd.ts +1 -2
  34. package/src/types/NativeAdViewProps.ts +1 -2
  35. package/src/types/Privacy.ts +28 -16
  36. package/src/types/RewardedAd.ts +4 -5
  37. package/src/types/TargetingData.ts +1 -2
  38. package/src/types/ViewAd.ts +20 -20
  39. package/src/types/index.ts +4 -4
  40. package/android/src/main/java/com/applovin/mediation/adapters/GoogleAdManagerMediationAdapter.java.saved +0 -1616
  41. package/android/src/main/java/com/applovin/mediation/adapters/GoogleMediationAdapter.java.old +0 -1788
  42. package/android/src/main/java/com/applovin/mediation/adapters/MintegralMediationAdapter.java.old +0 -1481
  43. package/android/src/main/java/com/applovin/mediation/adapters/MintegralMediationAdapter.java.saved +0 -1448
  44. package/ios/AppLovinMAX.xcworkspace/xcuserdata/hiroshi.watanabe.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
package/src/AdView.tsx CHANGED
@@ -1,9 +1,10 @@
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";
1
+ import * as React from 'react';
2
+ import { useEffect, useState } from 'react';
3
+ import { NativeModules, requireNativeComponent, StyleSheet } from 'react-native';
4
+ import type { ViewProps, ViewStyle, StyleProp } from 'react-native';
5
+ import type { AdDisplayFailedInfo, AdInfo, AdLoadFailedInfo, AdRevenueInfo } from './types/AdInfo';
6
+ import type { AdNativeEvent } from './types/AdEvent';
7
+ import type { AdViewProps } from './types/AdViewProps';
7
8
 
8
9
  const { AppLovinMAX } = NativeModules;
9
10
 
@@ -26,7 +27,6 @@ const {
26
27
  * Defines a format of an ad.
27
28
  */
28
29
  export enum AdFormat {
29
-
30
30
  /**
31
31
  * Banner ad.
32
32
  */
@@ -54,16 +54,16 @@ export enum AdViewPosition {
54
54
  }
55
55
 
56
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
- }
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
65
 
66
- const AdViewComponent = requireNativeComponent<AdViewProps & ViewProps & AdViewNativeEvents>("AppLovinMAXAdView");
66
+ const AdViewComponent = requireNativeComponent<AdViewProps & ViewProps & AdViewNativeEvents>('AppLovinMAXAdView');
67
67
 
68
68
  const ADVIEW_SIZE = {
69
69
  banner: { width: 320, height: 50 },
@@ -76,7 +76,12 @@ const getOutlineViewSize = (style: StyleProp<ViewStyle>) => {
76
76
  return [viewStyle?.width, viewStyle?.height];
77
77
  };
78
78
 
79
- const sizeAdViewDimensions = (adFormat: AdFormat, adaptiveBannerEnabled?: boolean, width?: number | string, height?: number | string): Promise<{}> => {
79
+ const sizeAdViewDimensions = (
80
+ adFormat: AdFormat,
81
+ adaptiveBannerEnabled?: boolean,
82
+ width?: number | string | null,
83
+ height?: number | string | null
84
+ ): Promise<Record<string, number>> => {
80
85
  const sizeForBannerFormat = async () => {
81
86
  const isTablet = await AppLovinMAX.isTablet();
82
87
 
@@ -84,7 +89,7 @@ const sizeAdViewDimensions = (adFormat: AdFormat, adaptiveBannerEnabled?: boolea
84
89
 
85
90
  let minHeight;
86
91
  if (adaptiveBannerEnabled) {
87
- if (typeof width === "number" && width > minWidth) {
92
+ if (typeof width === 'number' && width > minWidth) {
88
93
  minHeight = await AppLovinMAX.getAdaptiveBannerHeightForWidth(width);
89
94
  } else {
90
95
  minHeight = await AppLovinMAX.getAdaptiveBannerHeightForWidth(minWidth);
@@ -94,36 +99,44 @@ const sizeAdViewDimensions = (adFormat: AdFormat, adaptiveBannerEnabled?: boolea
94
99
  }
95
100
 
96
101
  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
- }
102
+ ...(width === 'auto'
103
+ ? {
104
+ width: minWidth,
105
+ }
106
+ : {
107
+ minWidth: minWidth,
108
+ }),
109
+ ...(height === 'auto'
110
+ ? {
111
+ height: minHeight,
112
+ }
113
+ : {
114
+ minHeight: minHeight,
115
+ }),
107
116
  });
108
- }
117
+ };
109
118
 
110
119
  if (adFormat === AdFormat.BANNER) {
111
120
  return sizeForBannerFormat();
112
121
  } else {
113
122
  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
- }
123
+ ...(width === 'auto'
124
+ ? {
125
+ width: ADVIEW_SIZE.mrec.width,
126
+ }
127
+ : {
128
+ minWidth: ADVIEW_SIZE.mrec.width,
129
+ }),
130
+ ...(height === 'auto'
131
+ ? {
132
+ height: ADVIEW_SIZE.mrec.height,
133
+ }
134
+ : {
135
+ minHeight: ADVIEW_SIZE.mrec.height,
136
+ }),
124
137
  });
125
138
  }
126
- }
139
+ };
127
140
 
128
141
  /**
129
142
  * The {@link AdView} component that you use building a banner or an MREC. Phones
@@ -174,7 +187,7 @@ export const AdView = ({
174
187
  AppLovinMAX.isInitialized().then((result: boolean) => {
175
188
  setIsInitialized(result);
176
189
  if (!result) {
177
- console.warn("ERROR: AdView is mounted before the initialization of the AppLovin MAX React Native module");
190
+ console.warn('AdView is mounted before the initialization of the AppLovin MAX React Native module');
178
191
  }
179
192
  });
180
193
  }, []);
@@ -182,7 +195,9 @@ export const AdView = ({
182
195
  useEffect(() => {
183
196
  if (!isInitialized) return;
184
197
  const [width, height] = getOutlineViewSize(style);
185
- sizeAdViewDimensions(adFormat, adaptiveBannerEnabled, width, height).then((value: {}) => {
198
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
199
+ // @ts-ignore: width and height should be of type DimensionValue in react-native 0.72.0 and above
200
+ sizeAdViewDimensions(adFormat, adaptiveBannerEnabled, width, height).then((value: Record<string, number>) => {
186
201
  setDimensions(value);
187
202
  });
188
203
  }, [isInitialized]);
@@ -219,7 +234,7 @@ export const AdView = ({
219
234
  if (!isInitialized) {
220
235
  return null;
221
236
  } else {
222
- const isDimensionsSet = (Object.keys(dimensions).length > 0);
237
+ const isDimensionsSet = Object.keys(dimensions).length > 0;
223
238
 
224
239
  // Not sized yet
225
240
  if (!isDimensionsSet) {
@@ -1,24 +1,22 @@
1
- import { NativeModules } from "react-native";
2
- import type { AppLovinMAXType } from "./types/AppLovinMAX";
3
- import type { Configuration } from "./types/Configuration";
1
+ import { NativeModules } from 'react-native';
2
+ import type { AppLovinMAXType } from './types/AppLovinMAX';
3
+ import type { Configuration } from './types/Configuration';
4
4
 
5
5
  const NativeAppLovinMAX = NativeModules.AppLovinMAX;
6
6
 
7
- const VERSION = "6.0.1";
7
+ const VERSION = '6.1.0';
8
8
 
9
- const initialize = async (
10
- sdkKey: string
11
- ): Promise<Configuration> => {
9
+ const initialize = async (sdkKey: string): Promise<Configuration> => {
12
10
  return NativeAppLovinMAX.initialize(VERSION, sdkKey);
13
- }
11
+ };
14
12
 
15
- type NativeAppLovinMAXType = Omit<AppLovinMAXType, | 'initialize'>;
13
+ type NativeAppLovinMAXType = Omit<AppLovinMAXType, 'initialize'>;
16
14
 
17
15
  const nativeMethods: NativeAppLovinMAXType = NativeAppLovinMAX;
18
16
 
19
17
  export const AppLovinMAX: AppLovinMAXType = {
20
18
  ...nativeMethods,
21
19
  initialize,
22
- }
20
+ };
23
21
 
24
22
  export default AppLovinMAX;
package/src/AppOpenAd.ts CHANGED
@@ -1,7 +1,8 @@
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";
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 { LocalExtraParameterValue } from './types/AdProps';
5
+ import type { AppOpenAdType } from './types/AppOpenAd';
5
6
 
6
7
  const { AppLovinMAX } = NativeModules;
7
8
 
@@ -17,83 +18,79 @@ const {
17
18
 
18
19
  const isAdReady = (adUnitId: string): Promise<boolean> => {
19
20
  return AppLovinMAX.isAppOpenAdReady(adUnitId);
20
- }
21
+ };
21
22
 
22
23
  const loadAd = (adUnitId: string): void => {
23
24
  AppLovinMAX.loadAppOpenAd(adUnitId);
24
- }
25
+ };
25
26
 
26
- const showAd = (
27
- adUnitId: string,
28
- placement?: string | null,
29
- customData?: string | null
30
- ): void => {
27
+ const showAd = (adUnitId: string, placement?: string | null, customData?: string | null): void => {
31
28
  AppLovinMAX.showAppOpenAd(adUnitId, placement ?? undefined, customData ?? undefined);
32
- }
29
+ };
33
30
 
34
- const setExtraParameter = (adUnitId: string, key: string, value: any): void => {
31
+ const setExtraParameter = (adUnitId: string, key: string, value: string | null): void => {
35
32
  AppLovinMAX.setAppOpenAdExtraParameter(adUnitId, key, value);
36
- }
33
+ };
37
34
 
38
- const setLocalExtraParameter = (adUnitId: string, key: string, value: any): void => {
35
+ const setLocalExtraParameter = (adUnitId: string, key: string, value: LocalExtraParameterValue): void => {
39
36
  AppLovinMAX.setAppOpenAdLocalExtraParameter(adUnitId, { [key]: value });
40
- }
37
+ };
41
38
 
42
39
  const addAdLoadedEventListener = (listener: (adInfo: AdInfo) => void) => {
43
40
  addEventListener(ON_APPOPEN_AD_LOADED_EVENT, (adInfo: AdInfo) => listener(adInfo));
44
- }
41
+ };
45
42
 
46
43
  const removeAdLoadedEventListener = () => {
47
44
  removeEventListener(ON_APPOPEN_AD_LOADED_EVENT);
48
- }
45
+ };
49
46
 
50
47
  const addAdLoadFailedEventListener = (listener: (errorInfo: AdLoadFailedInfo) => void) => {
51
48
  addEventListener(ON_APPOPEN_AD_LOAD_FAILED_EVENT, (errorInfo: AdLoadFailedInfo) => listener(errorInfo));
52
- }
49
+ };
53
50
 
54
51
  const removeAdLoadFailedEventListener = () => {
55
52
  removeEventListener(ON_APPOPEN_AD_LOAD_FAILED_EVENT);
56
- }
53
+ };
57
54
 
58
55
  const addAdClickedEventListener = (listener: (adInfo: AdInfo) => void) => {
59
56
  addEventListener(ON_APPOPEN_AD_CLICKED_EVENT, (adInfo: AdInfo) => listener(adInfo));
60
- }
57
+ };
61
58
 
62
59
  const removeAdClickedEventListener = () => {
63
60
  removeEventListener(ON_APPOPEN_AD_CLICKED_EVENT);
64
- }
61
+ };
65
62
 
66
63
  const addAdDisplayedEventListener = (listener: (adInfo: AdInfo) => void) => {
67
64
  addEventListener(ON_APPOPEN_AD_DISPLAYED_EVENT, (adInfo: AdInfo) => listener(adInfo));
68
- }
65
+ };
69
66
 
70
67
  const removeAdDisplayedEventListener = () => {
71
68
  removeEventListener(ON_APPOPEN_AD_DISPLAYED_EVENT);
72
- }
69
+ };
73
70
 
74
71
  const addAdFailedToDisplayEventListener = (listener: (errorInfo: AdDisplayFailedInfo) => void) => {
75
72
  addEventListener(ON_APPOPEN_AD_FAILED_TO_DISPLAY_EVENT, (errorInfo: AdDisplayFailedInfo) => listener(errorInfo));
76
- }
73
+ };
77
74
 
78
75
  const removeAdFailedToDisplayEventListener = () => {
79
76
  removeEventListener(ON_APPOPEN_AD_FAILED_TO_DISPLAY_EVENT);
80
- }
77
+ };
81
78
 
82
79
  const addAdHiddenEventListener = (listener: (adInfo: AdInfo) => void) => {
83
80
  addEventListener(ON_APPOPEN_AD_HIDDEN_EVENT, (adInfo: AdInfo) => listener(adInfo));
84
- }
81
+ };
85
82
 
86
83
  const removeAdHiddenEventListener = () => {
87
84
  removeEventListener(ON_APPOPEN_AD_HIDDEN_EVENT);
88
- }
85
+ };
89
86
 
90
87
  const addAdRevenuePaidListener = (listener: (adInfo: AdRevenueInfo) => void) => {
91
88
  addEventListener(ON_APPOPEN_AD_REVENUE_PAID, (adInfo: AdRevenueInfo) => listener(adInfo));
92
- }
89
+ };
93
90
 
94
91
  const removeAdRevenuePaidListener = () => {
95
92
  removeEventListener(ON_APPOPEN_AD_REVENUE_PAID);
96
- }
93
+ };
97
94
 
98
95
  export const AppOpenAd: AppOpenAdType = {
99
96
  isAdReady,
@@ -123,6 +120,6 @@ export const AppOpenAd: AppOpenAdType = {
123
120
 
124
121
  addAdRevenuePaidListener,
125
122
  removeAdRevenuePaidListener,
126
- }
123
+ };
127
124
 
128
125
  export default AppOpenAd;
package/src/BannerAd.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { NativeModules } from "react-native";
2
- import { addEventListener, removeEventListener } from "./EventEmitter"
3
- import type { AdInfo, AdLoadFailedInfo, AdRevenueInfo } from "./types/AdInfo";
4
- import type { BannerAdType } from "./types/BannerAd";
5
- import type { AdViewPosition } from "./AdView";
1
+ import { NativeModules } from 'react-native';
2
+ import { addEventListener, removeEventListener } from './EventEmitter';
3
+ import type { AdInfo, AdLoadFailedInfo, AdRevenueInfo } from './types/AdInfo';
4
+ import type { LocalExtraParameterValue } from './types/AdProps';
5
+ import type { BannerAdType } from './types/BannerAd';
6
+ import type { AdViewPosition } from './AdView';
6
7
 
7
8
  const { AppLovinMAX } = NativeModules;
8
9
 
@@ -17,113 +18,113 @@ const {
17
18
 
18
19
  const createAd = (adUnitId: string, position: AdViewPosition, xOffset?: number, yOffset?: number): void => {
19
20
  AppLovinMAX.createBannerWithOffsets(adUnitId, position, xOffset ?? 0, yOffset ?? 0);
20
- }
21
+ };
21
22
 
22
23
  const destroyAd = (adUnitId: string): void => {
23
24
  AppLovinMAX.destroyBanner(adUnitId);
24
- }
25
+ };
25
26
 
26
27
  const showAd = (adUnitId: string): void => {
27
28
  AppLovinMAX.showBanner(adUnitId);
28
- }
29
+ };
29
30
 
30
31
  const hideAd = (adUnitId: string): void => {
31
32
  AppLovinMAX.hideBanner(adUnitId);
32
- }
33
+ };
33
34
 
34
35
  const setPlacement = (adUnitId: string, placement: string | null): void => {
35
36
  AppLovinMAX.setBannerPlacement(adUnitId, placement);
36
- }
37
+ };
37
38
 
38
39
  const setCustomData = (adUnitId: string, customData: string | null): void => {
39
40
  AppLovinMAX.setBannerCustomData(adUnitId, customData);
40
- }
41
+ };
41
42
 
42
43
  const updatePosition = (adUnitId: string, bannerPosition: AdViewPosition): void => {
43
44
  AppLovinMAX.updateBannerPosition(adUnitId, bannerPosition);
44
- }
45
+ };
45
46
 
46
- const setExtraParameter = (adUnitId: string, key: string, value: any): void => {
47
+ const setExtraParameter = (adUnitId: string, key: string, value: string | null): void => {
47
48
  AppLovinMAX.setBannerExtraParameter(adUnitId, key, value);
48
- }
49
+ };
49
50
 
50
- const setLocalExtraParameter = (adUnitId: string, key: string, value: any): void => {
51
+ const setLocalExtraParameter = (adUnitId: string, key: string, value: LocalExtraParameterValue): void => {
51
52
  AppLovinMAX.setBannerLocalExtraParameter(adUnitId, { [key]: value });
52
- }
53
+ };
53
54
 
54
55
  const startAutoRefresh = (adUnitId: string): void => {
55
56
  AppLovinMAX.startBannerAutoRefresh(adUnitId);
56
- }
57
+ };
57
58
 
58
59
  const stopAutoRefresh = (adUnitId: string): void => {
59
60
  AppLovinMAX.stopBannerAutoRefresh(adUnitId);
60
- }
61
+ };
61
62
 
62
63
  const addAdLoadedEventListener = (listener: (adInfo: AdInfo) => void) => {
63
64
  addEventListener(ON_BANNER_AD_LOADED_EVENT, (adInfo: AdInfo) => listener(adInfo));
64
- }
65
+ };
65
66
 
66
67
  const removeAdLoadedEventListener = () => {
67
68
  removeEventListener(ON_BANNER_AD_LOADED_EVENT);
68
- }
69
+ };
69
70
 
70
71
  const addAdLoadFailedEventListener = (listener: (errorInfo: AdLoadFailedInfo) => void) => {
71
72
  addEventListener(ON_BANNER_AD_LOAD_FAILED_EVENT, (errorInfo: AdLoadFailedInfo) => listener(errorInfo));
72
- }
73
+ };
73
74
 
74
75
  const removeAdLoadFailedEventListener = () => {
75
76
  removeEventListener(ON_BANNER_AD_LOAD_FAILED_EVENT);
76
- }
77
+ };
77
78
 
78
79
  const addAdClickedEventListener = (listener: (adInfo: AdInfo) => void) => {
79
80
  addEventListener(ON_BANNER_AD_CLICKED_EVENT, (adInfo: AdInfo) => listener(adInfo));
80
- }
81
+ };
81
82
 
82
83
  const removeAdClickedEventListener = () => {
83
84
  removeEventListener(ON_BANNER_AD_CLICKED_EVENT);
84
- }
85
+ };
85
86
 
86
87
  const addAdCollapsedEventListener = (listener: (adInfo: AdInfo) => void) => {
87
88
  addEventListener(ON_BANNER_AD_COLLAPSED_EVENT, (adInfo: AdInfo) => listener(adInfo));
88
- }
89
+ };
89
90
 
90
91
  const removeAdCollapsedEventListener = () => {
91
92
  removeEventListener(ON_BANNER_AD_COLLAPSED_EVENT);
92
- }
93
+ };
93
94
 
94
95
  const addAdExpandedEventListener = (listener: (adInfo: AdInfo) => void) => {
95
96
  addEventListener(ON_BANNER_AD_EXPANDED_EVENT, (adInfo: AdInfo) => listener(adInfo));
96
- }
97
+ };
97
98
 
98
99
  const removeAdExpandedEventListener = () => {
99
100
  removeEventListener(ON_BANNER_AD_EXPANDED_EVENT);
100
- }
101
+ };
101
102
 
102
103
  const addAdRevenuePaidListener = (listener: (adInfo: AdRevenueInfo) => void) => {
103
104
  addEventListener(ON_BANNER_AD_REVENUE_PAID, (adInfo: AdRevenueInfo) => listener(adInfo));
104
- }
105
+ };
105
106
 
106
107
  const removeAdRevenuePaidListener = () => {
107
108
  removeEventListener(ON_BANNER_AD_REVENUE_PAID);
108
- }
109
+ };
109
110
 
110
111
  // Banner specific APIs
111
112
 
112
113
  const setBackgroundColor = (adUnitId: string, hexColorCode: string): void => {
113
114
  AppLovinMAX.setBannerBackgroundColor(adUnitId, hexColorCode);
114
- }
115
+ };
115
116
 
116
117
  const setWidth = (adUnitId: string, width: number): void => {
117
118
  AppLovinMAX.setBannerWidth(adUnitId, width);
118
- }
119
+ };
119
120
 
120
121
  const updateOffsets = (adUnitId: string, xOffset: number, yOffset: number): void => {
121
122
  AppLovinMAX.updateBannerOffsets(adUnitId, xOffset, yOffset);
122
- }
123
+ };
123
124
 
124
125
  const getAdaptiveHeightForWidth = (width: number): Promise<number> => {
125
126
  return AppLovinMAX.getAdaptiveBannerHeightForWidth(width);
126
- }
127
+ };
127
128
 
128
129
  export const BannerAd: BannerAdType = {
129
130
  createAd,
@@ -170,6 +171,6 @@ export const BannerAd: BannerAdType = {
170
171
  updateOffsets,
171
172
 
172
173
  getAdaptiveHeightForWidth,
173
- }
174
+ };
174
175
 
175
176
  export default BannerAd;
@@ -1,27 +1,27 @@
1
- import { NativeModules, NativeEventEmitter } from "react-native";
2
- import type { EventSubscription } from "react-native";
3
- import type { AdEventObject, AdEventListener } from "./types/AdEvent";
1
+ import { NativeModules, NativeEventEmitter } from 'react-native';
2
+ import type { EventSubscription } from 'react-native';
3
+ import type { AdEventObject, AdEventListener } from './types/AdEvent';
4
4
 
5
5
  const { AppLovinMAX } = NativeModules;
6
6
 
7
7
  // Note that this is a singleton in ES6 module
8
8
  const emitter = new NativeEventEmitter(AppLovinMAX);
9
9
 
10
- const subscriptions: Record<string, EventSubscription> = { };
10
+ const subscriptions: Record<string, EventSubscription> = {};
11
11
 
12
12
  export const addEventListener = <T extends AdEventObject>(event: string, handler: AdEventListener<T>) => {
13
- let subscription: EventSubscription = emitter.addListener(event, handler);
14
- let currentSubscription = subscriptions[event];
13
+ const subscription: EventSubscription = emitter.addListener(event, handler);
14
+ const currentSubscription = subscriptions[event];
15
15
  if (currentSubscription) {
16
16
  currentSubscription.remove();
17
17
  }
18
18
  subscriptions[event] = subscription;
19
- }
19
+ };
20
20
 
21
21
  export const removeEventListener = (event: string) => {
22
- let currentSubscription = subscriptions[event];
22
+ const currentSubscription = subscriptions[event];
23
23
  if (currentSubscription) {
24
24
  currentSubscription.remove();
25
25
  delete subscriptions[event];
26
26
  }
27
- }
27
+ };
@@ -1,7 +1,8 @@
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 { InterstitialAdType } from "./types/InterstitialAd";
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 { LocalExtraParameterValue } from './types/AdProps';
5
+ import type { InterstitialAdType } from './types/InterstitialAd';
5
6
 
6
7
  const { AppLovinMAX } = NativeModules;
7
8
 
@@ -17,83 +18,81 @@ const {
17
18
 
18
19
  const isAdReady = (adUnitId: string): Promise<boolean> => {
19
20
  return AppLovinMAX.isInterstitialReady(adUnitId);
20
- }
21
+ };
21
22
 
22
23
  const loadAd = (adUnitId: string): void => {
23
24
  AppLovinMAX.loadInterstitial(adUnitId);
24
- }
25
+ };
25
26
 
26
- const showAd = (
27
- adUnitId: string,
28
- placement?: string | null,
29
- customData?: string | null
30
- ): void => {
27
+ const showAd = (adUnitId: string, placement?: string | null, customData?: string | null): void => {
31
28
  AppLovinMAX.showInterstitial(adUnitId, placement ?? null, customData ?? null);
32
- }
29
+ };
33
30
 
34
- const setExtraParameter = (adUnitId: string, key: string, value: any): void => {
31
+ const setExtraParameter = (adUnitId: string, key: string, value: string | null): void => {
35
32
  AppLovinMAX.setInterstitialExtraParameter(adUnitId, key, value);
36
- }
33
+ };
37
34
 
38
- const setLocalExtraParameter = (adUnitId: string, key: string, value: any): void => {
35
+ const setLocalExtraParameter = (adUnitId: string, key: string, value: LocalExtraParameterValue): void => {
39
36
  AppLovinMAX.setInterstitialLocalExtraParameter(adUnitId, { [key]: value });
40
- }
37
+ };
41
38
 
42
39
  const addAdLoadedEventListener = (listener: (adInfo: AdInfo) => void) => {
43
40
  addEventListener(ON_INTERSTITIAL_LOADED_EVENT, (adInfo: AdInfo) => listener(adInfo));
44
- }
41
+ };
45
42
 
46
43
  const removeAdLoadedEventListener = () => {
47
44
  removeEventListener(ON_INTERSTITIAL_LOADED_EVENT);
48
- }
45
+ };
49
46
 
50
47
  const addAdLoadFailedEventListener = (listener: (errorInfo: AdLoadFailedInfo) => void) => {
51
48
  addEventListener(ON_INTERSTITIAL_LOAD_FAILED_EVENT, (errorInfo: AdLoadFailedInfo) => listener(errorInfo));
52
- }
49
+ };
53
50
 
54
51
  const removeAdLoadFailedEventListener = () => {
55
52
  removeEventListener(ON_INTERSTITIAL_LOAD_FAILED_EVENT);
56
- }
53
+ };
57
54
 
58
55
  const addAdClickedEventListener = (listener: (adInfo: AdInfo) => void) => {
59
56
  addEventListener(ON_INTERSTITIAL_CLICKED_EVENT, (adInfo: AdInfo) => listener(adInfo));
60
- }
57
+ };
61
58
 
62
59
  const removeAdClickedEventListener = () => {
63
60
  removeEventListener(ON_INTERSTITIAL_CLICKED_EVENT);
64
- }
61
+ };
65
62
 
66
63
  const addAdDisplayedEventListener = (listener: (adInfo: AdInfo) => void) => {
67
64
  addEventListener(ON_INTERSTITIAL_DISPLAYED_EVENT, (adInfo: AdInfo) => listener(adInfo));
68
- }
65
+ };
69
66
 
70
67
  const removeAdDisplayedEventListener = () => {
71
68
  removeEventListener(ON_INTERSTITIAL_DISPLAYED_EVENT);
72
- }
69
+ };
73
70
 
74
71
  const addAdFailedToDisplayEventListener = (listener: (errorInfo: AdDisplayFailedInfo) => void) => {
75
- addEventListener(ON_INTERSTITIAL_AD_FAILED_TO_DISPLAY_EVENT, (errorInfo: AdDisplayFailedInfo) => listener(errorInfo));
76
- }
72
+ addEventListener(ON_INTERSTITIAL_AD_FAILED_TO_DISPLAY_EVENT, (errorInfo: AdDisplayFailedInfo) =>
73
+ listener(errorInfo)
74
+ );
75
+ };
77
76
 
78
77
  const removeAdFailedToDisplayEventListener = () => {
79
78
  removeEventListener(ON_INTERSTITIAL_AD_FAILED_TO_DISPLAY_EVENT);
80
- }
79
+ };
81
80
 
82
81
  const addAdHiddenEventListener = (listener: (adInfo: AdInfo) => void) => {
83
82
  addEventListener(ON_INTERSTITIAL_HIDDEN_EVENT, (adInfo: AdInfo) => listener(adInfo));
84
- }
83
+ };
85
84
 
86
85
  const removeAdHiddenEventListener = () => {
87
86
  removeEventListener(ON_INTERSTITIAL_HIDDEN_EVENT);
88
- }
87
+ };
89
88
 
90
89
  const addAdRevenuePaidListener = (listener: (adInfo: AdRevenueInfo) => void) => {
91
90
  addEventListener(ON_INTERSTITIAL_AD_REVENUE_PAID, (adInfo: AdRevenueInfo) => listener(adInfo));
92
- }
91
+ };
93
92
 
94
93
  const removeAdRevenuePaidListener = () => {
95
94
  removeEventListener(ON_INTERSTITIAL_AD_REVENUE_PAID);
96
- }
95
+ };
97
96
 
98
97
  export const InterstitialAd: InterstitialAdType = {
99
98
  isAdReady,
@@ -123,6 +122,6 @@ export const InterstitialAd: InterstitialAdType = {
123
122
 
124
123
  addAdRevenuePaidListener,
125
124
  removeAdRevenuePaidListener,
126
- }
125
+ };
127
126
 
128
127
  export default InterstitialAd;