react-native-applovin-max 6.3.1 → 6.4.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.
@@ -35,8 +35,8 @@ android {
35
35
  defaultConfig {
36
36
  minSdkVersion 16
37
37
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
38
- versionCode 6030100
39
- versionName "6.3.1"
38
+ versionCode 6040100
39
+ versionName "6.4.1"
40
40
  }
41
41
 
42
42
  flavorDimensions("default")
@@ -140,5 +140,5 @@ dependencies {
140
140
  // noinspection GradleDynamicVersion
141
141
  api 'com.facebook.react:react-native:+'
142
142
 
143
- implementation 'com.applovin:applovin-sdk:12.3.1'
143
+ implementation 'com.applovin:applovin-sdk:12.4.2'
144
144
  }
@@ -36,10 +36,7 @@ import com.applovin.mediation.ads.MaxAdView;
36
36
  import com.applovin.mediation.ads.MaxAppOpenAd;
37
37
  import com.applovin.mediation.ads.MaxInterstitialAd;
38
38
  import com.applovin.mediation.ads.MaxRewardedAd;
39
- import com.applovin.sdk.AppLovinAdContentRating;
40
39
  import com.applovin.sdk.AppLovinCmpError;
41
- import com.applovin.sdk.AppLovinCmpService;
42
- import com.applovin.sdk.AppLovinGender;
43
40
  import com.applovin.sdk.AppLovinMediationProvider;
44
41
  import com.applovin.sdk.AppLovinPrivacySettings;
45
42
  import com.applovin.sdk.AppLovinSdk;
@@ -47,6 +44,8 @@ import com.applovin.sdk.AppLovinSdkConfiguration;
47
44
  import com.applovin.sdk.AppLovinSdkConfiguration.ConsentFlowUserGeography;
48
45
  import com.applovin.sdk.AppLovinSdkSettings;
49
46
  import com.applovin.sdk.AppLovinSdkUtils;
47
+ import com.applovin.sdk.AppLovinTargetingData.AdContentRating;
48
+ import com.applovin.sdk.AppLovinTargetingData.Gender;
50
49
  import com.facebook.react.bridge.Arguments;
51
50
  import com.facebook.react.bridge.LifecycleEventListener;
52
51
  import com.facebook.react.bridge.Promise;
@@ -2459,7 +2458,7 @@ public class AppLovinMAXModule
2459
2458
 
2460
2459
  if ( promise == null )
2461
2460
  {
2462
- e( message );
2461
+ e( message );
2463
2462
  return;
2464
2463
  }
2465
2464
 
@@ -2531,38 +2530,38 @@ public class AppLovinMAXModule
2531
2530
  return new Point( AppLovinSdkUtils.dpToPx( context, (int) xDp ), AppLovinSdkUtils.dpToPx( context, (int) yDp ) );
2532
2531
  }
2533
2532
 
2534
- private static AppLovinGender getAppLovinGender(@Nullable final String gender)
2533
+ private static Gender getAppLovinGender(@Nullable final String gender)
2535
2534
  {
2536
2535
  if ( gender != null )
2537
2536
  {
2538
2537
  if ( "F".equalsIgnoreCase( gender ) )
2539
2538
  {
2540
- return AppLovinGender.FEMALE;
2539
+ return Gender.FEMALE;
2541
2540
  }
2542
2541
  else if ( "M".equalsIgnoreCase( gender ) )
2543
2542
  {
2544
- return AppLovinGender.MALE;
2543
+ return Gender.MALE;
2545
2544
  }
2546
2545
  else if ( "O".equalsIgnoreCase( gender ) )
2547
2546
  {
2548
- return AppLovinGender.OTHER;
2547
+ return Gender.OTHER;
2549
2548
  }
2550
2549
  }
2551
2550
 
2552
- return AppLovinGender.UNKNOWN;
2551
+ return Gender.UNKNOWN;
2553
2552
  }
2554
2553
 
2555
- private static String getRawAppLovinGender(final AppLovinGender gender)
2554
+ private static String getRawAppLovinGender(final Gender gender)
2556
2555
  {
2557
- if ( gender == AppLovinGender.FEMALE )
2556
+ if ( gender == Gender.FEMALE )
2558
2557
  {
2559
2558
  return "F";
2560
2559
  }
2561
- else if ( gender == AppLovinGender.MALE )
2560
+ else if ( gender == Gender.MALE )
2562
2561
  {
2563
2562
  return "M";
2564
2563
  }
2565
- else if ( gender == AppLovinGender.OTHER )
2564
+ else if ( gender == Gender.OTHER )
2566
2565
  {
2567
2566
  return "O";
2568
2567
  }
@@ -2570,22 +2569,22 @@ public class AppLovinMAXModule
2570
2569
  return "U";
2571
2570
  }
2572
2571
 
2573
- private static AppLovinAdContentRating getAppLovinAdContentRating(final int maximumAdContentRating)
2572
+ private static AdContentRating getAppLovinAdContentRating(final int maximumAdContentRating)
2574
2573
  {
2575
2574
  if ( maximumAdContentRating == 1 )
2576
2575
  {
2577
- return AppLovinAdContentRating.ALL_AUDIENCES;
2576
+ return AdContentRating.ALL_AUDIENCES;
2578
2577
  }
2579
2578
  else if ( maximumAdContentRating == 2 )
2580
2579
  {
2581
- return AppLovinAdContentRating.EVERYONE_OVER_TWELVE;
2580
+ return AdContentRating.EVERYONE_OVER_TWELVE;
2582
2581
  }
2583
2582
  else if ( maximumAdContentRating == 3 )
2584
2583
  {
2585
- return AppLovinAdContentRating.MATURE_AUDIENCES;
2584
+ return AdContentRating.MATURE_AUDIENCES;
2586
2585
  }
2587
2586
 
2588
- return AppLovinAdContentRating.NONE;
2587
+ return AdContentRating.NONE;
2589
2588
  }
2590
2589
 
2591
2590
  private static ConsentFlowUserGeography getAppLovinConsentFlowUserGeography(final String userGeography)
@@ -2629,6 +2628,11 @@ public class AppLovinMAXModule
2629
2628
  adInfo.putMap( "waterfall", createAdWaterfallInfo( ad.getWaterfall() ) );
2630
2629
  adInfo.putString( "dspName", AppLovinSdkUtils.isValidString( ad.getDspName() ) ? ad.getDspName() : "" );
2631
2630
 
2631
+ WritableMap sizeObject = Arguments.createMap();
2632
+ sizeObject.putInt( "width", ad.getSize().getWidth() );
2633
+ sizeObject.putInt( "height", ad.getSize().getHeight() );
2634
+ adInfo.putMap( "size", sizeObject );
2635
+
2632
2636
  return adInfo;
2633
2637
  }
2634
2638
 
package/ios/AppLovinMAX.m CHANGED
@@ -2193,7 +2193,10 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
2193
2193
  @"placement" : ad.placement ?: @"",
2194
2194
  @"revenue" : @(ad.revenue),
2195
2195
  @"waterfall": [self createAdWaterfallInfo: ad.waterfall],
2196
- @"dspName" : ad.DSPName ?: @""};
2196
+ @"dspName" : ad.DSPName ?: @"",
2197
+ @"size" : @{@"width" : @(ad.size.width),
2198
+ @"height" : @(ad.size.height)}
2199
+ };
2197
2200
  }
2198
2201
 
2199
2202
  - (NSDictionary<NSString *, id> *)adLoadFailedInfoForAd:(NSString *)adUnitIdentifier withError:(MAError *)error
package/ios/Podfile CHANGED
@@ -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', '12.3.1'
38
+ pod 'AppLovinSDK', '12.4.1'
39
39
 
40
40
  end
package/ios/Podfile.lock CHANGED
@@ -1,5 +1,5 @@
1
1
  PODS:
2
- - AppLovinSDK (12.3.1)
2
+ - AppLovinSDK (12.4.1)
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 (= 12.3.1)
252
+ - AppLovinSDK (= 12.4.1)
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: d99a5a32b00e844932f4583f863780e1af835722
342
+ AppLovinSDK: c57ad0d34625c971d2db127f8ef60570b28ff51a
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: 9ca7e6154d8697161b5d7f65806d35634fe4a6f5
371
+ PODFILE CHECKSUM: 743d3a03166e4ff89e660e87d59561305c1e0a2e
372
372
 
373
373
  COCOAPODS: 1.15.2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-applovin-max",
3
3
  "author": "AppLovin Corporation",
4
- "version": "6.3.1",
4
+ "version": "6.4.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",
@@ -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_6_3_1" }
14
+ s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_6_4_1" }
15
15
 
16
16
  s.source_files = "ios/AppLovinMAX*.{h,m}"
17
17
 
18
18
  s.dependency "React"
19
- s.dependency "AppLovinSDK", "12.3.1"
19
+ s.dependency "AppLovinSDK", "12.4.1"
20
20
  end
package/src/AdView.tsx CHANGED
@@ -1,7 +1,14 @@
1
1
  import * as React from 'react';
2
- import { useEffect, useState, useRef, useCallback, useImperativeHandle, forwardRef } from 'react';
3
- import { NativeModules, requireNativeComponent, StyleSheet, UIManager, findNodeHandle } from 'react-native';
4
- import type { ViewProps, ViewStyle, StyleProp, NativeMethods } from 'react-native';
2
+ import { useEffect, useState, useRef, useCallback, useImperativeHandle, useReducer, forwardRef } from 'react';
3
+ import {
4
+ NativeModules,
5
+ requireNativeComponent,
6
+ StyleSheet,
7
+ UIManager,
8
+ findNodeHandle,
9
+ useWindowDimensions,
10
+ } from 'react-native';
11
+ import type { ViewProps, ViewStyle, StyleProp, NativeMethods, DimensionValue } from 'react-native';
5
12
  import type { AdDisplayFailedInfo, AdInfo, AdLoadFailedInfo, AdRevenueInfo } from './types/AdInfo';
6
13
  import type { AdNativeEvent } from './types/AdEvent';
7
14
  import type { AdViewProps, AdViewHandler } from './types/AdViewProps';
@@ -67,77 +74,45 @@ const AdViewComponent = requireNativeComponent<AdViewProps & ViewProps & AdViewN
67
74
 
68
75
  type AdViewType = React.Component<AdViewProps> & NativeMethods;
69
76
 
77
+ type SizeKey = 'width' | 'height';
78
+ type SizeRecord = Partial<Record<SizeKey, DimensionValue>>;
79
+
70
80
  const ADVIEW_SIZE = {
71
81
  banner: { width: 320, height: 50 },
72
82
  leader: { width: 728, height: 90 },
73
83
  mrec: { width: 300, height: 250 },
74
84
  };
75
85
 
86
+ // Returns 'auto' for unspecified width / height
76
87
  const getOutlineViewSize = (style: StyleProp<ViewStyle>) => {
77
88
  const viewStyle = StyleSheet.flatten(style || {});
78
- return [viewStyle?.width, viewStyle?.height];
89
+ return [viewStyle?.width ?? 'auto', viewStyle?.height ?? 'auto'];
79
90
  };
80
91
 
81
- const sizeAdViewDimensions = (
82
- adFormat: AdFormat,
83
- adaptiveBannerEnabled?: boolean,
84
- width?: number | string | null,
85
- height?: number | string | null
86
- ): Promise<Record<string, number>> => {
92
+ const sizeBannerDimensions = (
93
+ sizeProps: SizeRecord,
94
+ adaptiveBannerEnabled: boolean,
95
+ screenWidth: number,
96
+ bannerFormatSize: SizeRecord
97
+ ): Promise<SizeRecord> => {
87
98
  const sizeForBannerFormat = async () => {
88
- const isTablet = await AppLovinMAX.isTablet();
89
-
90
- const minWidth = isTablet ? ADVIEW_SIZE.leader.width : ADVIEW_SIZE.banner.width;
99
+ const width = sizeProps.width === 'auto' ? screenWidth : sizeProps.width;
91
100
 
92
- let minHeight;
93
- if (adaptiveBannerEnabled) {
94
- if (typeof width === 'number' && width > minWidth) {
95
- minHeight = await AppLovinMAX.getAdaptiveBannerHeightForWidth(width);
101
+ let height;
102
+ if (sizeProps.height === 'auto') {
103
+ if (adaptiveBannerEnabled) {
104
+ height = await AppLovinMAX.getAdaptiveBannerHeightForWidth(screenWidth);
96
105
  } else {
97
- minHeight = await AppLovinMAX.getAdaptiveBannerHeightForWidth(minWidth);
106
+ height = bannerFormatSize.height;
98
107
  }
99
108
  } else {
100
- minHeight = isTablet ? ADVIEW_SIZE.leader.height : ADVIEW_SIZE.banner.height;
109
+ height = sizeProps.height;
101
110
  }
102
111
 
103
- return Promise.resolve({
104
- ...(width === 'auto'
105
- ? {
106
- width: minWidth,
107
- }
108
- : {
109
- minWidth: minWidth,
110
- }),
111
- ...(height === 'auto'
112
- ? {
113
- height: minHeight,
114
- }
115
- : {
116
- minHeight: minHeight,
117
- }),
118
- });
112
+ return Promise.resolve({ width: width, height: height });
119
113
  };
120
114
 
121
- if (adFormat === AdFormat.BANNER) {
122
- return sizeForBannerFormat();
123
- } else {
124
- return Promise.resolve({
125
- ...(width === 'auto'
126
- ? {
127
- width: ADVIEW_SIZE.mrec.width,
128
- }
129
- : {
130
- minWidth: ADVIEW_SIZE.mrec.width,
131
- }),
132
- ...(height === 'auto'
133
- ? {
134
- height: ADVIEW_SIZE.mrec.height,
135
- }
136
- : {
137
- minHeight: ADVIEW_SIZE.mrec.height,
138
- }),
139
- });
140
- }
115
+ return sizeForBannerFormat();
141
116
  };
142
117
 
143
118
  /**
@@ -186,14 +161,19 @@ export const AdView = forwardRef<AdViewHandler, AdViewProps & ViewProps>(functio
186
161
  },
187
162
  ref
188
163
  ) {
164
+ const { width: screenWidth } = useWindowDimensions();
165
+ const adFormatSize = useRef<SizeRecord>({});
166
+ const [, forceUpdate] = useReducer((x) => x + 1, 0);
189
167
  const adViewRef = useRef<AdViewType | null>(null);
190
168
  const [isInitialized, setIsInitialized] = useState<boolean>(false);
191
- const [dimensions, setDimensions] = useState({});
169
+ const sizeProps = useRef<SizeRecord>({});
170
+ const dimensions = useRef<SizeRecord>({});
192
171
 
193
172
  const loadAd = () => {
194
173
  if (adViewRef.current) {
195
174
  UIManager.dispatchViewManagerCommand(
196
175
  findNodeHandle(adViewRef.current),
176
+ // @ts-ignore: Issue in RN ts defs
197
177
  UIManager.getViewManagerConfig('AppLovinMAXAdView').Commands.loadAd,
198
178
  undefined
199
179
  );
@@ -209,23 +189,55 @@ export const AdView = forwardRef<AdViewHandler, AdViewProps & ViewProps>(functio
209
189
  }, []);
210
190
 
211
191
  useEffect(() => {
192
+ if (adFormat === AdFormat.BANNER) {
193
+ AppLovinMAX.isTablet().then((result: boolean) => {
194
+ if (result) {
195
+ adFormatSize.current = { width: ADVIEW_SIZE.leader.width, height: ADVIEW_SIZE.leader.height };
196
+ } else {
197
+ adFormatSize.current = { width: ADVIEW_SIZE.banner.width, height: ADVIEW_SIZE.banner.height };
198
+ }
199
+ });
200
+ } else {
201
+ adFormatSize.current = { width: ADVIEW_SIZE.mrec.width, height: ADVIEW_SIZE.mrec.height };
202
+ }
203
+
212
204
  AppLovinMAX.isInitialized().then((result: boolean) => {
213
205
  setIsInitialized(result);
214
206
  if (!result) {
215
207
  console.warn('AdView is mounted before the initialization of the AppLovin MAX React Native module');
216
208
  }
217
209
  });
218
- }, []);
210
+ }, []); // Run once when mounted
219
211
 
220
212
  useEffect(() => {
221
213
  if (!isInitialized) return;
214
+
222
215
  const [width, height] = getOutlineViewSize(style);
223
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
224
- // @ts-ignore: width and height should be of type DimensionValue in react-native 0.72.0 and above
225
- sizeAdViewDimensions(adFormat, adaptiveBannerEnabled, width, height).then((value: Record<string, number>) => {
226
- setDimensions(value);
227
- });
228
- }, [isInitialized]);
216
+
217
+ if (sizeProps.current.width === width && sizeProps.current.height === height) return;
218
+
219
+ sizeProps.current = { width: width, height: height };
220
+
221
+ if (adFormat === AdFormat.BANNER) {
222
+ sizeBannerDimensions(sizeProps.current, adaptiveBannerEnabled, screenWidth, adFormatSize.current).then(
223
+ (adaptedSize: SizeRecord) => {
224
+ if (
225
+ dimensions.current.width !== adaptedSize.width ||
226
+ dimensions.current.height !== adaptedSize.height
227
+ ) {
228
+ dimensions.current = adaptedSize;
229
+ forceUpdate();
230
+ }
231
+ }
232
+ );
233
+ } else {
234
+ dimensions.current = {
235
+ width: width === 'auto' ? adFormatSize.current.width : width,
236
+ height: height === 'auto' ? adFormatSize.current.height : height,
237
+ };
238
+ forceUpdate();
239
+ }
240
+ }); // Run every render
229
241
 
230
242
  const onAdLoadedEvent = (event: AdNativeEvent<AdInfo>) => {
231
243
  if (onAdLoaded) onAdLoaded(event.nativeEvent);
@@ -259,7 +271,7 @@ export const AdView = forwardRef<AdViewHandler, AdViewProps & ViewProps>(functio
259
271
  if (!isInitialized) {
260
272
  return null;
261
273
  } else {
262
- const isDimensionsSet = Object.keys(dimensions).length > 0;
274
+ const isDimensionsSet = Object.keys(dimensions.current).length > 0;
263
275
 
264
276
  // Not sized yet
265
277
  if (!isDimensionsSet) {
@@ -286,7 +298,7 @@ export const AdView = forwardRef<AdViewHandler, AdViewProps & ViewProps>(functio
286
298
  onAdExpandedEvent={onAdExpandedEvent}
287
299
  onAdCollapsedEvent={onAdCollapsedEvent}
288
300
  onAdRevenuePaidEvent={onAdRevenuePaidEvent}
289
- style={Object.assign({}, style, dimensions)}
301
+ style={Object.assign({}, style, dimensions.current)}
290
302
  {...otherProps}
291
303
  />
292
304
  );
@@ -4,7 +4,7 @@ import type { Configuration } from './types/Configuration';
4
4
 
5
5
  const NativeAppLovinMAX = NativeModules.AppLovinMAX;
6
6
 
7
- const VERSION = '6.3.1';
7
+ const VERSION = '6.4.1';
8
8
 
9
9
  /**
10
10
  * This enum represents the user's geography used to determine the type of consent flow shown to the
package/src/BannerAd.ts CHANGED
@@ -18,6 +18,7 @@ const {
18
18
 
19
19
  const createAd = (adUnitId: string, position: AdViewPosition, xOffset?: number, yOffset?: number): void => {
20
20
  AppLovinMAX.createBannerWithOffsets(adUnitId, position, xOffset ?? 0, yOffset ?? 0);
21
+ AppLovinMAX.setBannerExtraParameter(adUnitId, 'adaptive_banner', 'true');
21
22
  };
22
23
 
23
24
  const destroyAd = (adUnitId: string): void => {
@@ -116,6 +116,7 @@ const NativeAdViewImpl = forwardRef<NativeAdViewHandler, NativeAdViewProps & Vie
116
116
  if (nativeAdViewRef) {
117
117
  UIManager.dispatchViewManagerCommand(
118
118
  findNodeHandle(nativeAdViewRef.current),
119
+ // @ts-ignore: Issue in RN ts defs
119
120
  UIManager.getViewManagerConfig('AppLovinMAXNativeAdView').Commands.loadAd,
120
121
  undefined
121
122
  );
@@ -88,7 +88,7 @@ export const IconView = (props: Omit<ImageProps, 'source'>) => {
88
88
  const { nativeAd, nativeAdView } = useContext(NativeAdViewContext);
89
89
 
90
90
  useEffect(() => {
91
- if (!nativeAd.image || !imageRef.current) return;
91
+ if (!(nativeAd.image || nativeAd.url) || !imageRef.current) return;
92
92
 
93
93
  nativeAdView?.setNativeProps({
94
94
  iconView: findNodeHandle(imageRef.current),
@@ -96,7 +96,7 @@ export const IconView = (props: Omit<ImageProps, 'source'>) => {
96
96
  }, [nativeAd]);
97
97
 
98
98
  return nativeAd.url ? (
99
- <Image {...props} source={{ uri: nativeAd.url }} />
99
+ <Image {...props} ref={imageRef} source={{ uri: nativeAd.url }} />
100
100
  ) : nativeAd.image ? (
101
101
  <Image {...props} ref={imageRef} source={0} />
102
102
  ) : (
@@ -48,6 +48,14 @@ export type AdInfo = {
48
48
  * The native ad info.
49
49
  */
50
50
  nativeAd?: AdNativeInfo | null;
51
+
52
+ /**
53
+ * The size of the AdView format ad, or size with (width: 0, height: 0) otherwise.
54
+ */
55
+ size: {
56
+ width: number;
57
+ height: number;
58
+ };
51
59
  };
52
60
 
53
61
  /**