react-native-applovin-max 3.1.0 → 3.2.2

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.
@@ -25,6 +25,7 @@
25
25
 
26
26
  // Storage for placement and extra parameters if set before the MAAdView is created
27
27
  @property (nonatomic, strong) NSMutableDictionary<NSNumber *, NSString *> *placementRegistry;
28
+ @property (nonatomic, strong) NSMutableDictionary<NSNumber *, NSString *> *customDataRegistry;
28
29
  @property (nonatomic, strong) NSMutableDictionary<NSNumber *, NSString *> *adaptiveBannerEnabledRegistry;
29
30
 
30
31
  @end
@@ -46,6 +47,7 @@ RCT_EXPORT_MODULE(AppLovinMAXAdView)
46
47
  self.adUnitIdRegistry = [NSMutableDictionary dictionary];
47
48
  self.adFormatRegistry = [NSMutableDictionary dictionary];
48
49
  self.placementRegistry = [NSMutableDictionary dictionary];
50
+ self.customDataRegistry = [NSMutableDictionary dictionary];
49
51
  self.adaptiveBannerEnabledRegistry = [NSMutableDictionary dictionary];
50
52
  }
51
53
  return self;
@@ -82,6 +84,31 @@ RCT_EXPORT_METHOD(setPlacement:(nonnull NSNumber *)viewTag toPlacement:(NSString
82
84
  }];
83
85
  }
84
86
 
87
+ // NOTE: `nonnull` must be annotated here for this RN export to work at runtime
88
+ RCT_EXPORT_METHOD(setCustomData:(nonnull NSNumber *)viewTag toCustomData:(NSString *)customData)
89
+ {
90
+ [self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
91
+
92
+ // NOTE: iOS caches the native view via `viewTag` when you remove it from screen (unlike Android)
93
+ UIView *view = viewRegistry[viewTag];
94
+ if ( !view )
95
+ {
96
+ RCTLogError(@"Cannot find UIView with tag %@", viewTag);
97
+ return;
98
+ }
99
+
100
+ MAAdView *adView = [self adViewFromContainerView: view];
101
+ if ( adView )
102
+ {
103
+ adView.customData = customData;
104
+ }
105
+ else
106
+ {
107
+ self.customDataRegistry[viewTag] = customData;
108
+ }
109
+ }];
110
+ }
111
+
85
112
  // NOTE: `nonnull` must be annotated here for this RN export to work at runtime
86
113
  RCT_EXPORT_METHOD(setAdaptiveBannerEnabled:(nonnull NSNumber *)viewTag toEnabled:(NSString *)enabledStr)
87
114
  {
@@ -180,6 +207,7 @@ RCT_EXPORT_METHOD(setAdFormat:(nonnull NSNumber *)viewTag toAdFormat:(NSString *
180
207
  adView = [[MAAdView alloc] initWithAdUnitIdentifier: adUnitIdentifier adFormat: adFormat sdk: AppLovinMAX.shared.sdk];
181
208
  adView.frame = (CGRect) { CGPointZero, adFormat.size };
182
209
  adView.delegate = AppLovinMAX.shared; // Go through core class for callback forwarding to React Native layer
210
+ adView.revenueDelegate = AppLovinMAX.shared;
183
211
 
184
212
  NSString *placement = self.placementRegistry[viewTag];
185
213
  if ( placement )
@@ -188,6 +216,13 @@ RCT_EXPORT_METHOD(setAdFormat:(nonnull NSNumber *)viewTag toAdFormat:(NSString *
188
216
  adView.placement = placement;
189
217
  }
190
218
 
219
+ NSString *customData = self.customDataRegistry[viewTag];
220
+ if ( customData )
221
+ {
222
+ [self.customDataRegistry removeObjectForKey: viewTag];
223
+ adView.customData = customData;
224
+ }
225
+
191
226
  NSString *adaptiveBannerEnabledStr = self.adaptiveBannerEnabledRegistry[viewTag];
192
227
  if ( [adaptiveBannerEnabledStr al_isValidString] )
193
228
  {
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.3.2'
38
+ pod 'AppLovinSDK', '11.4.3'
39
39
 
40
40
  end
package/ios/Podfile.lock CHANGED
@@ -1,5 +1,5 @@
1
1
  PODS:
2
- - AppLovinSDK (11.3.2)
2
+ - AppLovinSDK (11.4.3)
3
3
  - boost-for-react-native (1.63.0)
4
4
  - DoubleConversion (1.1.6)
5
5
  - FBLazyVector (0.63.4)
@@ -249,7 +249,7 @@ PODS:
249
249
  - Yoga (1.14.0)
250
250
 
251
251
  DEPENDENCIES:
252
- - AppLovinSDK (= 11.3.2)
252
+ - AppLovinSDK (= 11.4.3)
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: e0bf2984979b082f7c167e4babc3290b4eac5f24
342
+ AppLovinSDK: 221dfbdff620be0ff227ed5b018b97b1f3d15713
343
343
  boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
344
344
  DoubleConversion: cde416483dac037923206447da6e1454df403714
345
345
  FBLazyVector: 3bb422f41b18121b71783a905c10e58606f7dc3e
@@ -368,6 +368,6 @@ SPEC CHECKSUMS:
368
368
  ReactCommon: 73d79c7039f473b76db6ff7c6b159c478acbbb3b
369
369
  Yoga: 4bd86afe9883422a7c4028c00e34790f560923d6
370
370
 
371
- PODFILE CHECKSUM: e821f607c6351511f4f5d0bd7cc5b1e9d39a8e0c
371
+ PODFILE CHECKSUM: 26bc18f6057a79b7f583981eaa607d7b30a63d74
372
372
 
373
373
  COCOAPODS: 1.11.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": "3.1.0",
4
+ "version": "3.2.2",
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_3_1_0" }
14
+ s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_3_2_2" }
15
15
 
16
16
  s.source_files = "ios/AppLovinMAX*.{h,m}"
17
17
 
18
18
  s.dependency "React"
19
- s.dependency "AppLovinSDK", "11.3.2"
19
+ s.dependency "AppLovinSDK", "11.4.3"
20
20
  end
@@ -13,6 +13,7 @@ class AdView extends React.Component {
13
13
  this.setAdUnitId(this.props.adUnitId);
14
14
  this.setAdFormat(this.props.adFormat);
15
15
  this.setPlacement(this.props.placement);
16
+ this.setCustomData(this.props.customData);
16
17
  this.setAdaptiveBannerEnabled(this.props.adaptiveBannerEnabled);
17
18
  }
18
19
 
@@ -30,6 +31,10 @@ class AdView extends React.Component {
30
31
  this.setPlacement(this.props.placement);
31
32
  }
32
33
 
34
+ if (prevProps.customData !== this.props.customData) {
35
+ this.setCustomData(this.props.customData);
36
+ }
37
+
33
38
  if (prevProps.adaptiveBannerEnabled !== this.props.adaptiveBannerEnabled) {
34
39
  this.setAdaptiveBannerEnabled(this.props.adaptiveBannerEnabled);
35
40
  }
@@ -94,6 +99,20 @@ class AdView extends React.Component {
94
99
  );
95
100
  }
96
101
 
102
+ setCustomData(customData) {
103
+ var adUnitId = this.props.adUnitId;
104
+ var adFormat = this.props.adFormat;
105
+
106
+ // If the ad unit id or ad format are unset, we can't set the customData.
107
+ if (adUnitId == null || adFormat == null) return;
108
+
109
+ UIManager.dispatchViewManagerCommand(
110
+ findNodeHandle(this),
111
+ Platform.OS === 'android' ? "setCustomData" : UIManager.getViewManagerConfig("AppLovinMAXAdView").Commands.setCustomData,
112
+ [customData]
113
+ );
114
+ }
115
+
97
116
  setAdaptiveBannerEnabled(enabled) {
98
117
  var adUnitId = this.props.adUnitId;
99
118
  var adFormat = this.props.adFormat;
@@ -129,6 +148,11 @@ AdView.propTypes = {
129
148
  */
130
149
  placement: PropTypes.string,
131
150
 
151
+ /**
152
+ * A string value representing the customData name that you assign when you integrate each ad format, for granular reporting in ad events.
153
+ */
154
+ customData: PropTypes.string,
155
+
132
156
  /**
133
157
  * A boolean value representing whether or not to enable adaptive banners. Note that adaptive banners are enabled by default as of v2.3.0.
134
158
  */
@@ -0,0 +1,12 @@
1
+ import AppLovinMAX from "./index.js";
2
+
3
+ let UserSegment = {
4
+
5
+ set name(value) {
6
+ AppLovinMAX.setUserSegment(value);
7
+ },
8
+ };
9
+
10
+ export {
11
+ UserSegment,
12
+ };
package/src/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { NativeModules, NativeEventEmitter } from "react-native";
2
2
  import AdView from "./AppLovinMAXAdView";
3
3
  import { TargetingData as targetingData, AdContentRating, UserGender } from "./TargetingData";
4
+ import { UserSegment as userSegment } from "./UserSegment";
4
5
 
5
6
  const { AppLovinMAX } = NativeModules;
6
7
 
7
- const VERSION = "3.1.0";
8
+ const VERSION = "3.2.2";
8
9
 
9
10
  /**
10
11
  * This enum represents whether or not the consent dialog should be shown for this user.
@@ -34,6 +35,7 @@ const AdFormat = {
34
35
 
35
36
  const AdViewPosition = {
36
37
  TOP_CENTER: "top_center",
38
+ TOP_LEFT: "top_left",
37
39
  TOP_RIGHT: "top_right",
38
40
  CENTERED: "centered",
39
41
  CENTER_LEFT: "center_left",
@@ -65,9 +67,44 @@ const removeEventListener = (event) => {
65
67
  }
66
68
  };
67
69
 
70
+ const showInterstitial = (adUnitId, ...args) => {
71
+ switch (args.length) {
72
+ case 0:
73
+ AppLovinMAX.showInterstitial(adUnitId, null, null);
74
+ break;
75
+ case 1:
76
+ AppLovinMAX.showInterstitial(adUnitId, args[0], null);
77
+ break;
78
+ case 2:
79
+ AppLovinMAX.showInterstitial(adUnitId, args[0], args[1]);
80
+ break;
81
+ default:
82
+ // do nothing - unexpected number of arguments
83
+ break;
84
+ }
85
+ };
86
+
87
+ const showRewardedAd = (adUnitId, ...args) => {
88
+ switch (args.length) {
89
+ case 0:
90
+ AppLovinMAX.showRewardedAd(adUnitId, null, null);
91
+ break;
92
+ case 1:
93
+ AppLovinMAX.showRewardedAd(adUnitId, args[0], null);
94
+ break;
95
+ case 2:
96
+ AppLovinMAX.showRewardedAd(adUnitId, args[0], args[1]);
97
+ break;
98
+ default:
99
+ // do nothing - unexpected number of arguments
100
+ break;
101
+ }
102
+ };
103
+
68
104
  export default {
69
105
  ...AppLovinMAX,
70
106
  AdView,
107
+ userSegment,
71
108
  targetingData,
72
109
  AdContentRating,
73
110
  UserGender,
@@ -80,6 +117,8 @@ export default {
80
117
  initialize(sdkKey, callback) {
81
118
  AppLovinMAX.initialize(VERSION, sdkKey, callback); // Inject VERSION into native code
82
119
  },
120
+ showInterstitial,
121
+ showRewardedAd,
83
122
 
84
123
  /*----------------------*/
85
124
  /** AUTO-DECLARED APIs **/
@@ -119,6 +158,18 @@ export default {
119
158
  /* setTermsOfServiceUrl(urlString) */
120
159
  /* setLocationCollectionEnabled(locationCollectionEnabled) */
121
160
 
161
+ /*----------------*/
162
+ /* DATA PASSING */
163
+ /*----------------*/
164
+ /* setTargetingDataYearOfBirth(yearOfBirth) */
165
+ /* setTargetingDataGender(gender) */
166
+ /* setTargetingDataMaximumAdContentRating(maximumAdContentRating) */
167
+ /* setTargetingDataEmail(email) */
168
+ /* setTargetingDataPhoneNumber(phoneNumber) */
169
+ /* setTargetingDataKeywords(keywords) */
170
+ /* setTargetingDataInterests(interests) */
171
+ /* clearAllTargetingData() */
172
+
122
173
  /*----------------*/
123
174
  /* EVENT TRACKING */
124
175
  /*----------------*/