react-native-applovin-max 3.3.0 → 3.3.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.
@@ -21,6 +21,17 @@ export const AdViewPosition = {
21
21
  BOTTOM_RIGHT: "bottom_right",
22
22
  };
23
23
 
24
+ /**
25
+ * Returns AdView when AppLovinMax has been initialized or returns a black empty View as
26
+ * a placeholder of AdView when AppLovinMax has not been initialized.
27
+ *
28
+ * The purpose of this AdView wrapper is for the application not to access AdView
29
+ * before the completion of the AppLovinMax initialization.
30
+ *
31
+ * Note: this does not re-render itself when the status of the AppLovinMax initialization
32
+ * has changed so that the black view may stay even after the completion of
33
+ * the AppLovinMax initialization.
34
+ */
24
35
  const AdViewWrapper = (props) => {
25
36
  const {style, ...rest} = props;
26
37
  return (
@@ -32,7 +43,7 @@ const AdViewWrapper = (props) => {
32
43
  console.warn('[AppLovinSdk] [AppLovinMAX] <AdView/> has been mounted before AppLovin initialization')
33
44
  }
34
45
  </View>
35
- )
46
+ );
36
47
  };
37
48
 
38
49
  const styles = StyleSheet.create({
@@ -44,71 +55,17 @@ const styles = StyleSheet.create({
44
55
  borderColor: 'whitesmoke',
45
56
  borderWidth: 1,
46
57
  },
47
- message: {
48
- color: 'white',
49
- },
50
58
  });
51
59
 
52
- class AdView extends React.Component {
53
-
54
- static defaultProps = {
55
- adaptiveBannerEnabled: true
56
- }
57
-
58
- componentDidMount() {
59
- this.setAdUnitId(this.props.adUnitId);
60
- this.setAdFormat(this.props.adFormat);
61
- this.setPlacement(this.props.placement);
62
- this.setCustomData(this.props.customData);
63
- this.setAdaptiveBannerEnabled(this.props.adaptiveBannerEnabled);
64
- this.setAutoRefresh(this.props.autoRefresh);
65
- }
66
-
67
- componentDidUpdate(prevProps) {
68
- // Only call setters for actual changes.
69
- if (prevProps.adUnitId !== this.props.adUnitId) {
70
- this.setAdUnitId(this.props.adUnitId);
71
- }
72
-
73
- if (prevProps.adFormat !== this.props.adFormat) {
74
- this.setAdFormat(this.props.adFormat);
75
- }
76
-
77
- if (prevProps.placement !== this.props.placement) {
78
- this.setPlacement(this.props.placement);
79
- }
80
-
81
- if (prevProps.customData !== this.props.customData) {
82
- this.setCustomData(this.props.customData);
83
- }
84
-
85
- if (prevProps.adaptiveBannerEnabled !== this.props.adaptiveBannerEnabled) {
86
- this.setAdaptiveBannerEnabled(this.props.adaptiveBannerEnabled);
87
- }
88
-
89
- if (prevProps.autoRefresh !== this.props.autoRefresh) {
90
- this.setAutoRefresh(this.props.autoRefresh);
91
- }
92
- }
93
-
94
- render() {
95
- let { style, ...otherProps } = this.props;
60
+ const AdView = (props) => {
61
+ const {style, ...otherProps} = props;
96
62
 
97
- return <AppLovinMAXAdView
98
- // This merges the pub-specified style with ours, but overwrites width/height.
99
- style = { Object.assign({}, style, this.sizeForAdFormat(otherProps.adFormat)) } {...otherProps }
100
- />;
101
- }
63
+ const sizeForAdFormat = () => {
64
+ if (props.adFormat === AdFormat.BANNER) {
65
+ let width = AppLovinMAX.isTablet() ? 728 : 320;
66
+ let height;
102
67
 
103
- // Helper Functions
104
-
105
- sizeForAdFormat(adFormat) {
106
- if (adFormat === AdFormat.BANNER) {
107
-
108
- var width = AppLovinMAX.isTablet() ? 728 : 320;
109
- var height;
110
-
111
- if (this.props.adaptiveBannerEnabled) {
68
+ if (props.adaptiveBannerEnabled) {
112
69
  height = AppLovinMAX.getAdaptiveBannerHeightForWidth(-1);
113
70
  } else {
114
71
  height = AppLovinMAX.isTablet() ? 90 : 50;
@@ -118,86 +75,15 @@ class AdView extends React.Component {
118
75
  } else {
119
76
  return { width: 300, height: 250 }
120
77
  }
121
- }
122
-
123
- setAdUnitId(adUnitId) {
124
- UIManager.dispatchViewManagerCommand(
125
- findNodeHandle(this),
126
- Platform.OS === 'android' ? "setAdUnitId" : UIManager.getViewManagerConfig("AppLovinMAXAdView").Commands.setAdUnitId,
127
- [adUnitId]
128
- );
129
- }
130
-
131
- setAdFormat(adFormatStr) {
132
- UIManager.dispatchViewManagerCommand(
133
- findNodeHandle(this),
134
- Platform.OS === 'android' ? "setAdFormat" : UIManager.getViewManagerConfig("AppLovinMAXAdView").Commands.setAdFormat,
135
- [adFormatStr]
136
- );
137
- }
138
-
139
- setPlacement(placement) {
140
- var adUnitId = this.props.adUnitId;
141
- var adFormat = this.props.adFormat;
142
-
143
- // If the ad unit id or ad format are unset, we can't set the placement.
144
- if (adUnitId == null || adFormat == null) return;
145
-
146
- UIManager.dispatchViewManagerCommand(
147
- findNodeHandle(this),
148
- Platform.OS === 'android' ? "setPlacement" : UIManager.getViewManagerConfig("AppLovinMAXAdView").Commands.setPlacement,
149
- [placement]
150
- );
151
- }
152
-
153
- setCustomData(customData) {
154
- var adUnitId = this.props.adUnitId;
155
- var adFormat = this.props.adFormat;
156
-
157
- // If the ad unit id or ad format are unset, we can't set the customData.
158
- if (adUnitId == null || adFormat == null) return;
159
-
160
- UIManager.dispatchViewManagerCommand(
161
- findNodeHandle(this),
162
- Platform.OS === 'android' ? "setCustomData" : UIManager.getViewManagerConfig("AppLovinMAXAdView").Commands.setCustomData,
163
- [customData]
164
- );
165
- }
166
-
167
- setAdaptiveBannerEnabled(enabled) {
168
- var adUnitId = this.props.adUnitId;
169
- var adFormat = this.props.adFormat;
170
-
171
- // If the ad unit id or ad format are unset, we can't set the value
172
- if (adUnitId == null || adFormat == null) return;
173
-
174
- if (adFormat === AdFormat.BANNER) {
175
- if (enabled === true || enabled === false) {
176
- UIManager.dispatchViewManagerCommand(
177
- findNodeHandle(this),
178
- Platform.OS === 'android' ? "setAdaptiveBannerEnabled" : UIManager.getViewManagerConfig("AppLovinMAXAdView").Commands.setAdaptiveBannerEnabled,
179
- [enabled ? "true" : "false"]
180
- );
181
- }
182
- }
183
- }
184
-
185
- setAutoRefresh(enabled) {
186
- var adUnitId = this.props.adUnitId;
187
- var adFormat = this.props.adFormat;
188
-
189
- // If the ad unit id or ad format are unset, we can't set the autorefresh.
190
- if (adUnitId == null || adFormat == null) return;
78
+ };
191
79
 
192
- if (enabled === true || enabled === false) {
193
- UIManager.dispatchViewManagerCommand(
194
- findNodeHandle(this),
195
- Platform.OS === 'android' ? "setAutoRefresh" : UIManager.getViewManagerConfig("AppLovinMAXAdView").Commands.setAutoRefresh,
196
- [enabled]
197
- );
198
- }
199
- }
200
- }
80
+ return (
81
+ <AppLovinMAXAdView
82
+ style={[sizeForAdFormat(), style]}
83
+ {...otherProps }
84
+ />
85
+ );
86
+ };
201
87
 
202
88
  AdView.propTypes = {
203
89
  /**
@@ -231,7 +117,14 @@ AdView.propTypes = {
231
117
  autoRefresh: PropTypes.bool,
232
118
  };
233
119
 
120
+ // Defiens default values for the props.
121
+ AdView.defaultProps = {
122
+ adaptiveBannerEnabled: true,
123
+ autoRefresh: true,
124
+ };
125
+
126
+
234
127
  // requireNativeComponent automatically resolves 'AppLovinMAXAdView' to 'AppLovinMAXAdViewManager'
235
- var AppLovinMAXAdView = requireNativeComponent("AppLovinMAXAdView", AdView);
128
+ const AppLovinMAXAdView = requireNativeComponent("AppLovinMAXAdView", AdView);
236
129
 
237
130
  export default AdViewWrapper;
package/src/index.js CHANGED
@@ -4,7 +4,7 @@ import { TargetingData as targetingData, AdContentRating, UserGender } from "./T
4
4
 
5
5
  const { AppLovinMAX } = NativeModules;
6
6
 
7
- const VERSION = "3.3.0";
7
+ const VERSION = "3.3.1";
8
8
 
9
9
  /**
10
10
  * This enum represents whether or not the consent dialog should be shown for this user.