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
@@ -1,208 +0,0 @@
1
- import React, {useContext, useRef, useEffect} from "react";
2
- import {findNodeHandle, Text, Image, View, TouchableOpacity} from "react-native";
3
- import {NativeAdViewContext} from "./NativeAdViewProvider";
4
-
5
- export const TitleView = (props) => {
6
- const titleRef = useRef();
7
- const {nativeAd, nativeAdView} = useContext(NativeAdViewContext);
8
-
9
- useEffect(() => {
10
- if (!nativeAdView || !nativeAd.title) return;
11
-
12
- nativeAdView.setNativeProps({
13
- titleView: findNodeHandle(titleRef.current),
14
- });
15
- }, [nativeAd, nativeAdView]);
16
-
17
- if (!nativeAdView) return null;
18
-
19
- return (
20
- <Text {...props} ref={titleRef}>
21
- {nativeAd.title || null}
22
- </Text>
23
- );
24
- };
25
-
26
- export const AdvertiserView = (props) => {
27
- const advertiserRef = useRef();
28
- const {nativeAd, nativeAdView} = useContext(NativeAdViewContext);
29
-
30
- useEffect(() => {
31
- if (!nativeAdView || !nativeAd.advertiser) return;
32
-
33
- nativeAdView.setNativeProps({
34
- advertiserView: findNodeHandle(advertiserRef.current),
35
- });
36
- }, [nativeAd, nativeAdView]);
37
-
38
- if (!nativeAdView) return null;
39
-
40
- return (
41
- <Text {...props} ref={advertiserRef}>
42
- {nativeAd.advertiser || null}
43
- </Text>
44
- );
45
- };
46
-
47
- export const BodyView = (props) => {
48
- const bodyRef = useRef();
49
- const {nativeAd, nativeAdView} = useContext(NativeAdViewContext);
50
-
51
- useEffect(() => {
52
- if (!nativeAdView || !nativeAd.body) return;
53
-
54
- nativeAdView.setNativeProps({
55
- bodyView: findNodeHandle(bodyRef.current),
56
- });
57
- }, [nativeAd, nativeAdView]);
58
-
59
- if (!nativeAdView) return null;
60
-
61
- return (
62
- <Text {...props} ref={bodyRef}>
63
- {nativeAd.body || null}
64
- </Text>
65
- );
66
- };
67
-
68
- export const CallToActionView = (props) => {
69
- const callToActionRef = useRef();
70
- const {nativeAd, nativeAdView} = useContext(NativeAdViewContext);
71
-
72
- useEffect(() => {
73
- if (!nativeAdView || !nativeAd.callToAction) return;
74
-
75
- nativeAdView.setNativeProps({
76
- callToActionView: findNodeHandle(callToActionRef.current),
77
- });
78
- }, [nativeAd, nativeAdView]);
79
-
80
- if (!nativeAdView) return null;
81
-
82
- return (
83
- <TouchableOpacity {...props} ref={callToActionRef}>
84
- <Text {...props}>
85
- {nativeAd.callToAction || null}
86
- </Text>
87
- </TouchableOpacity>
88
- );
89
- };
90
-
91
- export const IconView = (props) => {
92
- const imageRef = useRef();
93
-
94
- const {nativeAd, nativeAdView} = useContext(NativeAdViewContext);
95
-
96
- useEffect(() => {
97
- if (!nativeAdView || !nativeAd.image || !imageRef.current) return;
98
-
99
- nativeAdView.setNativeProps({
100
- iconView: findNodeHandle(imageRef.current),
101
- });
102
- }, [nativeAd, nativeAdView, imageRef.current]);
103
-
104
- if (!nativeAdView) return null;
105
-
106
- return (
107
- nativeAd.url ? <Image {...props} source={{uri: nativeAd.url}} /> :
108
- nativeAd.image ? <Image {...props} ref={imageRef} /> :
109
- <View {...props} />
110
- );
111
- };
112
-
113
- export const OptionsView = (props) => {
114
- const viewRef = useRef();
115
-
116
- const {nativeAd, nativeAdView} = useContext(NativeAdViewContext);
117
-
118
- useEffect(() => {
119
- if (!nativeAdView || !nativeAd.isOptionsViewAvailable) return;
120
-
121
- nativeAdView.setNativeProps({
122
- optionsView: findNodeHandle(viewRef.current),
123
- });
124
- }, [nativeAd, nativeAdView]);
125
-
126
- if (!nativeAdView) return null;
127
-
128
- return (
129
- <View {...props} ref={viewRef} />
130
- );
131
- };
132
-
133
- export const MediaView = (props) => {
134
- const viewRef = useRef();
135
-
136
- const {nativeAd, nativeAdView} = useContext(NativeAdViewContext);
137
-
138
- useEffect(() => {
139
- if (!nativeAdView || !nativeAd.isMediaViewAvailable) return;
140
-
141
- nativeAdView.setNativeProps({
142
- mediaView: findNodeHandle(viewRef.current),
143
- });
144
- }, [nativeAd, nativeAdView]);
145
-
146
- if (!nativeAdView) return null;
147
-
148
- return (
149
- <View {...props} ref={viewRef} />
150
- );
151
- };
152
-
153
- export const StarRatingView = (props) => {
154
- const {style, ...otherProps} = props;
155
-
156
- const maxStarCount = 5;
157
- const starColor = style.color ?? "#ffe234";
158
- const starSize = style.fontSize ?? 10;
159
-
160
- const {nativeAd, nativeAdView} = useContext(NativeAdViewContext);
161
-
162
- const FilledStar = ({size,color}) => {
163
- return (
164
- // black star in unicode
165
- <Text style={{fontSize: size, color: color}}>{String.fromCodePoint(0x2605)}</Text>
166
- );
167
- };
168
-
169
- const EmptyStar = ({size,color}) => {
170
- return (
171
- // white star in unicode
172
- <Text style={{fontSize: size, color: color}}>{String.fromCodePoint(0x2606)}</Text>
173
- );
174
- };
175
-
176
- const StarView = ({index, rating, size, color}) => {
177
- const width = (rating - index) * size;
178
- return (
179
- <View>
180
- <EmptyStar size={size} color={color} />
181
- {
182
- (rating > index) &&
183
- <View style={{ width: width, overflow: 'hidden', position: 'absolute'}}>
184
- <FilledStar style={{top:0, left:0}} size={size} color={color} />
185
- </View>
186
- }
187
- </View>
188
- );
189
- };
190
-
191
- if (!nativeAdView) return null;
192
-
193
- return (
194
- <View style={[style, {flexDirection: 'row', alignItems: 'center'}]}>
195
- {(() => {
196
- let stars = [];
197
- for (let index = 0; index < maxStarCount; index++) {
198
- if (nativeAd.starRating) {
199
- stars.push(<StarView key={index} index={index} rating={nativeAd.starRating} size={starSize} color={starColor} />);
200
- } else {
201
- stars.push(<Text key={index} style={{fontSize: starSize}}> </Text>);
202
- }
203
- }
204
- return stars;
205
- })()}
206
- </View>
207
- );
208
- };
@@ -1,164 +0,0 @@
1
- import React, { forwardRef, useContext, useImperativeHandle, useRef, useState, useEffect } from "react";
2
- import PropTypes from "prop-types";
3
- import { NativeModules, requireNativeComponent, UIManager, findNodeHandle } from "react-native";
4
- import { NativeAdViewContext, NativeAdViewProvider } from "./NativeAdViewProvider";
5
- import { TitleView, AdvertiserView, BodyView, CallToActionView, IconView, OptionsView, MediaView, StarRatingView } from "./NativeAdComponents";
6
-
7
- const { AppLovinMAX } = NativeModules;
8
-
9
- const NativeAdViewWrapper = forwardRef((props, ref) => {
10
- return (
11
- <NativeAdViewProvider>
12
- <NativeAdView {...props} ref={ref}/>
13
- </NativeAdViewProvider>
14
- );
15
- });
16
-
17
- const AppLovinMAXNativeAdView = requireNativeComponent('AppLovinMAXNativeAdView', NativeAdView);
18
-
19
- // NativeAdView renders itself multiple times:
20
- // 1. initial render
21
- // 2. update of the nativeAdView context by saveElement, which locates and renders the all child
22
- // components including the user's components without nativeAd
23
- // 3. update of the nativeAd context by onNativeAdLoaded, which renders the ad components with nativeAd
24
- const NativeAdView = forwardRef((props, ref) => {
25
-
26
- const {extraParameters, localExtraParameters, ...otherProps} = props;
27
-
28
- // context from NativeAdViewProvider
29
- const {nativeAd, nativeAdView, setNativeAd, setNativeAdView} = useContext(NativeAdViewContext);
30
-
31
- // keep the nativeAdView ref
32
- const nativeAdViewRef = useRef();
33
-
34
- // invoke the native ad loader
35
- const loadAd = () => {
36
- if (nativeAdViewRef) {
37
- UIManager.dispatchViewManagerCommand(
38
- findNodeHandle(nativeAdViewRef.current),
39
- UIManager.getViewManagerConfig("AppLovinMAXNativeAdView").Commands.loadAd,
40
- undefined
41
- );
42
- }
43
- };
44
-
45
- // expose a list of functions via the provided ref
46
- useImperativeHandle(ref, () => ({ loadAd }), []);
47
-
48
- // save the DOM element via the ref callback
49
- const saveElement = (element) => {
50
- if (element) {
51
- nativeAdViewRef.current = element;
52
- setNativeAdView(element);
53
- }
54
- };
55
-
56
- const onAdLoadedEvent = (event) => {
57
- setNativeAd(event.nativeEvent.nativeAd);
58
- if (props.onAdLoaded) props.onAdLoaded(event.nativeEvent.adInfo);
59
- };
60
-
61
- const onAdLoadFailedEvent = (event) => {
62
- if (props.onAdLoadFailed) props.onAdLoadFailed(event.nativeEvent);
63
- };
64
-
65
- const onAdClickedEvent = (event) => {
66
- if (props.onAdClicked) props.onAdClicked(event.nativeEvent);
67
- };
68
-
69
- const onAdRevenuePaidEvent = (event) => {
70
- if (props.onAdRevenuePaid) props.onAdRevenuePaid(event.nativeEvent);
71
- };
72
-
73
- const sanitizeExtraParameters = (name, params) => {
74
- if (!params) return params;
75
-
76
- for (const key in params) {
77
- const value = params[key];
78
-
79
- // `null` and `undefined` are valid values (e.g. for clearing previously-set values)
80
- if (value == null || value == undefined) continue;
81
-
82
- if (typeof value !== 'string') {
83
- console.warn("AppLovinMAXNativeAdView only support string values: " + value + ", deleting value for key: " + key);
84
- delete params[key];
85
- }
86
- }
87
-
88
- return params;
89
- };
90
-
91
- return (
92
- <AppLovinMAXNativeAdView
93
- ref={saveElement}
94
- extraParameters={sanitizeExtraParameters('extraParameters', extraParameters)}
95
- localExtraParameters={localExtraParameters}
96
- onAdLoadedEvent={onAdLoadedEvent}
97
- onAdLoadFailedEvent={onAdLoadFailedEvent}
98
- onAdClickedEvent={onAdClickedEvent}
99
- onAdRevenuePaidEvent={onAdRevenuePaidEvent}
100
- {...otherProps}
101
- >
102
- {props.children}
103
- </AppLovinMAXNativeAdView>
104
- );
105
- });
106
-
107
- NativeAdView.propTypes = {
108
- /**
109
- * A string value representing the ad unit id to load ads for.
110
- */
111
- adUnitId: PropTypes.string.isRequired,
112
-
113
- /**
114
- * A string value representing the placement name that you assign when you integrate each ad format, for granular reporting in ad events.
115
- */
116
- placement: PropTypes.string,
117
-
118
- /**
119
- * A string value representing the customData name that you assign when you integrate each ad format, for granular reporting in ad events.
120
- */
121
- customData: PropTypes.string,
122
-
123
- /**
124
- * A dictionary of extra parameters consisting of key-value string pairs.
125
- */
126
- extraParameters: PropTypes.object,
127
-
128
- /**
129
- * A dictionary of local extra parameters consisting of key-value string pairs.
130
- */
131
- localExtraParameters: PropTypes.object,
132
-
133
- /**
134
- * A callback fuction to be fired when a new ad has been loaded.
135
- */
136
- onAdLoaded: PropTypes.func,
137
-
138
- /**
139
- * A callback fuction to be fired when an ad could not be retrieved.
140
- */
141
- onAdLoadFailed: PropTypes.func,
142
-
143
- /**
144
- * A callback fuction to be fired when ad is clicked.
145
- */
146
- onAdClicked: PropTypes.func,
147
-
148
- /**
149
- * A callback fuction to be fired when the revenue event is detected.
150
- */
151
- onAdRevenuePaid: PropTypes.func,
152
- };
153
-
154
- // Add the child ad components
155
- NativeAdViewWrapper.TitleView = TitleView;
156
- NativeAdViewWrapper.AdvertiserView = AdvertiserView;
157
- NativeAdViewWrapper.BodyView = BodyView;
158
- NativeAdViewWrapper.CallToActionView = CallToActionView;
159
- NativeAdViewWrapper.IconView = IconView;
160
- NativeAdViewWrapper.OptionsView = OptionsView;
161
- NativeAdViewWrapper.MediaView = MediaView;
162
- NativeAdViewWrapper.StarRatingView = StarRatingView;
163
-
164
- export default NativeAdViewWrapper;
@@ -1,19 +0,0 @@
1
- import React, { useState, createContext } from "react";
2
-
3
- export const NativeAdViewContext = createContext();
4
-
5
- export const NativeAdViewProvider = props => {
6
-
7
- const [nativeAd, setNativeAd] = useState({});
8
- const [nativeAdView, setNativeAdView] = useState();
9
-
10
- const providerValue = {
11
- nativeAd, nativeAdView, setNativeAd, setNativeAdView,
12
- };
13
-
14
- return (
15
- <NativeAdViewContext.Provider value={providerValue}>
16
- {props.children}
17
- </NativeAdViewContext.Provider>
18
- );
19
- };
@@ -1,104 +0,0 @@
1
- import { NativeModules } from "react-native";
2
-
3
- const { AppLovinMAX } = NativeModules;
4
-
5
- const AdContentRating = {
6
- None: 0,
7
- AllAudiences: 1,
8
- EveryoneOverTwelve: 2,
9
- MatureAudiences: 3,
10
- };
11
-
12
- const UserGender = {
13
- Unknown: 'U',
14
- Female: 'F',
15
- Male: 'M',
16
- Other: 'O'
17
- };
18
-
19
- const TargetingData = {
20
-
21
- set yearOfBirth(value) {
22
- AppLovinMAX.setTargetingDataYearOfBirth(value ? value : 0);
23
- },
24
-
25
- get yearOfBirth() {
26
- return AppLovinMAX.getTargetingDataYearOfBirth();
27
- },
28
-
29
- set gender(value) {
30
- if ( !value ) {
31
- AppLovinMAX.setTargetingDataGender(UserGender.Unknown);
32
- } else if ( value === UserGender.Unknown ||
33
- value === UserGender.Female ||
34
- value === UserGender.Male ||
35
- value === UserGender.Other ) {
36
- AppLovinMAX.setTargetingDataGender(value);
37
- }
38
- },
39
-
40
- get gender() {
41
- return AppLovinMAX.getTargetingDataGender();
42
- },
43
-
44
- set maximumAdContentRating(value) {
45
- if ( !value ) {
46
- AppLovinMAX.setTargetingDataMaximumAdContentRating(AdContentRating.None);
47
- } else if ( value === AdContentRating.None ||
48
- value === AdContentRating.AllAudiences ||
49
- value === AdContentRating.EveryoneOverTwelve ||
50
- value === AdContentRating.MatureAudiences ) {
51
- AppLovinMAX.setTargetingDataMaximumAdContentRating(value);
52
- }
53
- },
54
-
55
- get maximumAdContentRating() {
56
- return AppLovinMAX.getTargetingDataMaximumAdContentRating();
57
- },
58
-
59
- set email(value) {
60
- AppLovinMAX.setTargetingDataEmail(value);
61
- },
62
-
63
- get email() {
64
- return AppLovinMAX.getTargetingDataEmail();
65
- },
66
-
67
- set phoneNumber(value) {
68
- AppLovinMAX.setTargetingDataPhoneNumber(value);
69
- },
70
-
71
- get phoneNumber() {
72
- return AppLovinMAX.getTargetingDataPhoneNumber();
73
- },
74
-
75
- set keywords(value) {
76
- AppLovinMAX.setTargetingDataKeywords(value);
77
- },
78
-
79
- get keywords() {
80
- return AppLovinMAX.getTargetingDataKeywords();
81
- },
82
-
83
- set interests(value) {
84
- AppLovinMAX.setTargetingDataInterests(value);
85
- },
86
-
87
- get interests() {
88
- return AppLovinMAX.getTargetingDataInterests();
89
- },
90
-
91
- clearAll() {
92
- AppLovinMAX.clearAllTargetingData();
93
- }
94
-
95
- };
96
-
97
- TargetingData.AdContentRating = AdContentRating;
98
- TargetingData.UserGender = UserGender;
99
-
100
- export {
101
- TargetingData,
102
- AdContentRating,
103
- UserGender
104
- };