react-native-applovin-max 5.1.0 → 5.2.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.
@@ -1,6 +1,6 @@
1
1
  buildscript {
2
2
  ext.versions = [
3
- 'minSdk' : 16,
3
+ 'minSdk' : 21,
4
4
  'compileSdk' : 29,
5
5
  'targetSdk' : 29,
6
6
  'playServicesIdentifier': "16.0.0",
@@ -35,8 +35,8 @@ android {
35
35
  defaultConfig {
36
36
  minSdkVersion 16
37
37
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
38
- versionCode 5010000
39
- versionName "5.1.0"
38
+ versionCode 5020100
39
+ versionName "5.2.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:11.8.2'
143
+ implementation 'com.applovin:applovin-sdk:11.9.0'
144
144
  }
@@ -289,11 +289,11 @@ public class AppLovinMAXNativeAdView
289
289
  @Override
290
290
  public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom)
291
291
  {
292
- if ( view == mediaView.getParent() )
292
+ if ( mediaView != null && view == mediaView.getParent() )
293
293
  {
294
294
  sizeToFit( mediaView, view );
295
295
  }
296
- else if ( view == optionsView.getParent() )
296
+ else if ( optionsView != null && view == optionsView.getParent() )
297
297
  {
298
298
  sizeToFit( optionsView, view );
299
299
  }
@@ -391,6 +391,11 @@ public class AppLovinMAXNativeAdView
391
391
  nativeAdInfo.putString( "body", ad.getBody() );
392
392
  nativeAdInfo.putString( "callToAction", ad.getCallToAction() );
393
393
 
394
+ if ( ad.getStarRating() != null )
395
+ {
396
+ nativeAdInfo.putDouble( "starRating", ad.getStarRating().doubleValue() );
397
+ }
398
+
394
399
  float aspectRatio = ad.getMediaContentAspectRatio();
395
400
  if ( !Float.isNaN( aspectRatio ) )
396
401
  {
@@ -424,6 +429,11 @@ public class AppLovinMAXNativeAdView
424
429
  jsNativeAd.putString( "body", ad.getBody() );
425
430
  jsNativeAd.putString( "callToAction", ad.getCallToAction() );
426
431
 
432
+ if ( ad.getStarRating() != null )
433
+ {
434
+ jsNativeAd.putDouble( "starRating", ad.getStarRating().doubleValue() );
435
+ }
436
+
427
437
  MaxNativeAdImage icon = ad.getIcon();
428
438
  if ( icon != null )
429
439
  {
@@ -11,6 +11,13 @@
11
11
  #import "AppLovinMAX.h"
12
12
  #import "AppLovinMAXNativeAdView.h"
13
13
 
14
+ #define TITLE_LABEL_TAG 1
15
+ #define MEDIA_VIEW_CONTAINER_TAG 2
16
+ #define ICON_VIEW_TAG 3
17
+ #define BODY_VIEW_TAG 4
18
+ #define CALL_TO_ACTION_VIEW_TAG 5
19
+ #define ADVERTISER_VIEW_TAG 8
20
+
14
21
  @interface MANativeAdLoader()
15
22
  - (void)registerClickableViews:(NSArray<UIView *> *)clickableViews
16
23
  withContainer:(UIView *)container
@@ -85,7 +92,7 @@
85
92
  - (void)setAdUnitId:(NSString *)adUnitId
86
93
  {
87
94
  if ( ![adUnitId al_isValidString] ) return;
88
-
95
+
89
96
  _adUnitId = adUnitId;
90
97
 
91
98
  // Explicitly invoke ad load now that Ad Unit ID is set, but do so after 0.25s to allow other props to set
@@ -102,7 +109,7 @@
102
109
  [[AppLovinMAX shared] logUninitializedAccessError: @"AppLovinMAXNativeAdview.loadAd"];
103
110
  return;
104
111
  }
105
-
112
+
106
113
  if ( [self.isLoading compareAndSet: NO update: YES] )
107
114
  {
108
115
  [[AppLovinMAX shared] log: @"Loading a native ad for Ad Unit ID: %@...", self.adUnitId];
@@ -133,7 +140,7 @@
133
140
  - (void)setTitleView:(NSNumber *)tag
134
141
  {
135
142
  if ( !self.nativeAd.nativeAd.title ) return;
136
-
143
+
137
144
  UIView *view = [self.bridge.uiManager viewForReactTag: tag];
138
145
  if ( !view )
139
146
  {
@@ -141,48 +148,56 @@
141
148
  return;
142
149
  }
143
150
 
151
+ view.tag = TITLE_LABEL_TAG;
152
+
144
153
  [self.clickableViews addObject: view];
145
154
  }
146
155
 
147
156
  - (void)setAdvertiserView:(NSNumber *)tag
148
157
  {
149
158
  if ( !self.nativeAd.nativeAd.advertiser ) return;
150
-
159
+
151
160
  UIView *view = [self.bridge.uiManager viewForReactTag: tag];
152
161
  if ( !view )
153
162
  {
154
163
  [[AppLovinMAX shared] log: @"Cannot find an advertiser view with tag \"%@\" for %@", tag, self.adUnitId];
155
164
  return;
156
165
  }
157
-
166
+
167
+ view.tag = ADVERTISER_VIEW_TAG;
168
+
158
169
  [self.clickableViews addObject: view];
159
170
  }
160
171
 
161
172
  - (void)setBodyView:(NSNumber *)tag
162
173
  {
163
174
  if ( !self.nativeAd.nativeAd.body ) return;
164
-
175
+
165
176
  UIView *view = [self.bridge.uiManager viewForReactTag: tag];
166
177
  if ( !view )
167
178
  {
168
179
  [[AppLovinMAX shared] log: @"Cannot find a body view with tag \"%@\" for %@", tag, self.adUnitId];
169
180
  return;
170
181
  }
171
-
182
+
183
+ view.tag = BODY_VIEW_TAG;
184
+
172
185
  [self.clickableViews addObject: view];
173
186
  }
174
187
 
175
188
  - (void)setCallToActionView:(NSNumber *)tag
176
189
  {
177
190
  if ( !self.nativeAd.nativeAd.callToAction ) return;
178
-
191
+
179
192
  UIView *view = [self.bridge.uiManager viewForReactTag: tag];
180
193
  if ( !view )
181
194
  {
182
195
  [[AppLovinMAX shared] log: @"Cannot find a callToAction view with tag \"%@\" for %@", tag, self.adUnitId];
183
196
  return;
184
197
  }
185
-
198
+
199
+ view.tag = CALL_TO_ACTION_VIEW_TAG;
200
+
186
201
  [self.clickableViews addObject: view];
187
202
  }
188
203
 
@@ -195,6 +210,8 @@
195
210
  return;
196
211
  }
197
212
 
213
+ view.tag = ICON_VIEW_TAG;
214
+
198
215
  [self.clickableViews addObject: view];
199
216
 
200
217
  MANativeAdImage *icon = self.nativeAd.nativeAd.icon;
@@ -212,14 +229,14 @@
212
229
  - (void)setOptionsView:(NSNumber *)tag
213
230
  {
214
231
  if ( !self.nativeAd.nativeAd.optionsView ) return;
215
-
232
+
216
233
  UIView *view = [self.bridge.uiManager viewForReactTag: tag];
217
234
  if ( !view )
218
235
  {
219
236
  [[AppLovinMAX shared] log: @"Cannot find an option view with tag \"%@\" for %@", tag, self.adUnitId];
220
237
  return;
221
238
  }
222
-
239
+
223
240
  [view addSubview: self.nativeAd.nativeAd.optionsView];
224
241
  [self.nativeAd.nativeAd.optionsView al_pinToSuperview];
225
242
  }
@@ -234,9 +251,11 @@
234
251
  [[AppLovinMAX shared] log: @"Cannot find a media view with tag \"%@\" for %@", tag, self.adUnitId];
235
252
  return;
236
253
  }
237
-
254
+
255
+ view.tag = MEDIA_VIEW_CONTAINER_TAG;
256
+
238
257
  [self.clickableViews addObject: view];
239
-
258
+
240
259
  [view addSubview: self.nativeAd.nativeAd.mediaView];
241
260
  [self.nativeAd.nativeAd.mediaView al_pinToSuperview];
242
261
  }
@@ -246,7 +265,7 @@
246
265
  - (void)didLoadNativeAd:(nullable MANativeAdView *)nativeAdView forAd:(MAAd *)ad
247
266
  {
248
267
  [[AppLovinMAX shared] log: @"Native ad loaded: %@", ad];
249
-
268
+
250
269
  // Log a warning if it is a template native ad returned - as our plugin will be responsible for re-rendering the native ad's assets
251
270
  if ( nativeAdView )
252
271
  {
@@ -270,7 +289,7 @@
270
289
 
271
290
  [self.adLoader registerClickableViews: self.clickableViews withContainer: self forAd: ad];
272
291
  [self.adLoader handleNativeAdViewRenderedForAd: ad];
273
-
292
+
274
293
  [self.isLoading set: NO];
275
294
  });
276
295
  }
@@ -284,7 +303,8 @@
284
303
  nativeAdInfo[@"advertiser"] = ad.advertiser;
285
304
  nativeAdInfo[@"body"] = ad.body;
286
305
  nativeAdInfo[@"callToAction"] = ad.callToAction;
287
-
306
+ nativeAdInfo[@"starRating"] = ad.starRating;
307
+
288
308
  if ( !isnan(ad.mediaContentAspectRatio) )
289
309
  {
290
310
  // The aspect ratio can be 0.0f when it is not provided by the network.
@@ -301,11 +321,11 @@
301
321
  {
302
322
  nativeAdInfo[@"mediaContentAspectRatio"] = @(1.0);
303
323
  }
304
-
324
+
305
325
  nativeAdInfo[@"isIconImageAvailable"] = @(ad.icon != nil);
306
326
  nativeAdInfo[@"isOptionsViewAvailable"] = @(ad.optionsView != nil);
307
327
  nativeAdInfo[@"isMediaViewAvailable"] = @(ad.mediaView != nil);
308
-
328
+
309
329
  NSMutableDictionary *adInfo = [[AppLovinMAX shared] adInfoForAd: self.nativeAd].mutableCopy;
310
330
  adInfo[@"nativeAd"] = nativeAdInfo;
311
331
 
@@ -316,7 +336,8 @@
316
336
  jsNativeAd[@"advertiser"] = ad.advertiser;
317
337
  jsNativeAd[@"body"] = ad.body;
318
338
  jsNativeAd[@"callToAction"] = ad.callToAction;
319
-
339
+ jsNativeAd[@"starRating"] = ad.starRating;
340
+
320
341
  if ( ad.icon )
321
342
  {
322
343
  if ( ad.icon.URL )
@@ -328,7 +349,7 @@
328
349
  jsNativeAd[@"image"] = @(YES);
329
350
  }
330
351
  }
331
-
352
+
332
353
  jsNativeAd[@"isOptionsViewAvailable"] = ad.optionsView ? @(YES) : @(NO);
333
354
  jsNativeAd[@"isMediaViewAvailable"] = ad.mediaView ? @(YES) : @(NO);
334
355
 
@@ -382,7 +403,7 @@
382
403
 
383
404
  self.nativeAd = nil;
384
405
  }
385
-
406
+
386
407
  [self.clickableViews removeAllObjects];
387
408
  }
388
409
 
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', '11.8.2'
38
+ pod 'AppLovinSDK', '11.9.0'
39
39
 
40
40
  end
package/ios/Podfile.lock CHANGED
@@ -1,5 +1,5 @@
1
1
  PODS:
2
- - AppLovinSDK (11.8.2)
2
+ - AppLovinSDK (11.9.0)
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.8.2)
252
+ - AppLovinSDK (= 11.9.0)
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: cfcf1972d25febb4c0f23837763e3809f0fba159
342
+ AppLovinSDK: 2022f21e5b713b2c04bb7c2f10bde0f2dea89f11
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: 8638b3ebfa25029aca293faa9d5f2513a076845c
371
+ PODFILE CHECKSUM: 13c464ab10da6fc8a379ce53d55c204e98215526
372
372
 
373
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.1.0",
4
+ "version": "5.2.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_5_1_0" }
14
+ s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_5_2_1" }
15
15
 
16
16
  s.source_files = "ios/AppLovinMAX*.{h,m}"
17
17
 
18
18
  s.dependency "React"
19
- s.dependency "AppLovinSDK", "11.8.2"
19
+ s.dependency "AppLovinSDK", "11.9.0"
20
20
  end
@@ -106,7 +106,7 @@ export const IconView = (props) => {
106
106
  return (
107
107
  nativeAd.url ? <Image {...props} source={{uri: nativeAd.url}} /> :
108
108
  nativeAd.image ? <Image {...props} ref={imageRef} /> :
109
- <Image {...props} />
109
+ <View {...props} />
110
110
  );
111
111
  };
112
112
 
@@ -126,7 +126,7 @@ export const OptionsView = (props) => {
126
126
  if (!nativeAdView) return null;
127
127
 
128
128
  return (
129
- <View {...props} ref={viewRef}/>
129
+ <View {...props} ref={viewRef} />
130
130
  );
131
131
  };
132
132
 
@@ -146,6 +146,63 @@ export const MediaView = (props) => {
146
146
  if (!nativeAdView) return null;
147
147
 
148
148
  return (
149
- <View {...props} ref={viewRef}/>
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>
150
207
  );
151
208
  };
@@ -2,7 +2,7 @@ import React, { forwardRef, useContext, useImperativeHandle, useRef, useState, u
2
2
  import PropTypes from "prop-types";
3
3
  import { NativeModules, requireNativeComponent, UIManager, findNodeHandle } from "react-native";
4
4
  import { NativeAdViewContext, NativeAdViewProvider } from "./NativeAdViewProvider";
5
- import { TitleView, AdvertiserView, BodyView, CallToActionView, IconView, OptionsView, MediaView } from "./NativeAdComponents";
5
+ import { TitleView, AdvertiserView, BodyView, CallToActionView, IconView, OptionsView, MediaView, StarRatingView } from "./NativeAdComponents";
6
6
 
7
7
  const { AppLovinMAX } = NativeModules;
8
8
 
@@ -159,5 +159,6 @@ NativeAdViewWrapper.CallToActionView = CallToActionView;
159
159
  NativeAdViewWrapper.IconView = IconView;
160
160
  NativeAdViewWrapper.OptionsView = OptionsView;
161
161
  NativeAdViewWrapper.MediaView = MediaView;
162
+ NativeAdViewWrapper.StarRatingView = StarRatingView;
162
163
 
163
164
  export default NativeAdViewWrapper;
package/src/index.js CHANGED
@@ -6,7 +6,7 @@ import EventListeners from "./AppLovinMAXEventListeners";
6
6
 
7
7
  const { AppLovinMAX } = NativeModules;
8
8
 
9
- const VERSION = "5.1.0";
9
+ const VERSION = "5.2.1";
10
10
 
11
11
  /*---------*/
12
12
  /* BANNERS */