react-native-applovin-max 7.0.1 → 7.1.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 (49) hide show
  1. package/android/build.gradle +3 -3
  2. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdEvents.java +67 -0
  3. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdView.java +10 -6
  4. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewManager.java +7 -7
  5. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewUiComponent.java +9 -13
  6. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXModule.java +142 -626
  7. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdView.java +6 -6
  8. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdViewManager.java +4 -4
  9. package/ios/AppLovinMAX.m +83 -478
  10. package/ios/AppLovinMAXAdView.h +12 -3
  11. package/ios/AppLovinMAXAdView.m +17 -13
  12. package/ios/AppLovinMAXAdViewManager.m +1 -1
  13. package/ios/AppLovinMAXAdViewUIComponent.h +7 -6
  14. package/ios/AppLovinMAXAdViewUIComponent.m +10 -15
  15. package/ios/AppLovinMAXNativeAdView.m +2 -2
  16. package/lib/commonjs/AppLovinMAX.js +19 -3
  17. package/lib/commonjs/AppLovinMAX.js.map +1 -1
  18. package/lib/commonjs/index.js +0 -22
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/module/AppLovinMAX.js +19 -3
  21. package/lib/module/AppLovinMAX.js.map +1 -1
  22. package/lib/module/index.js +0 -1
  23. package/lib/module/index.js.map +1 -1
  24. package/lib/typescript/src/AppLovinMAX.d.ts.map +1 -1
  25. package/lib/typescript/src/index.d.ts +0 -1
  26. package/lib/typescript/src/index.d.ts.map +1 -1
  27. package/lib/typescript/src/types/AdProps.d.ts +6 -6
  28. package/lib/typescript/src/types/AppLovinMAX.d.ts +18 -6
  29. package/lib/typescript/src/types/AppLovinMAX.d.ts.map +1 -1
  30. package/package.json +1 -1
  31. package/react-native-applovin-max.podspec +2 -2
  32. package/src/AppLovinMAX.ts +24 -3
  33. package/src/index.ts +0 -1
  34. package/src/types/AdProps.ts +6 -6
  35. package/src/types/AppLovinMAX.ts +20 -7
  36. package/lib/commonjs/TargetingData.js +0 -179
  37. package/lib/commonjs/TargetingData.js.map +0 -1
  38. package/lib/commonjs/types/TargetingData.js +0 -6
  39. package/lib/commonjs/types/TargetingData.js.map +0 -1
  40. package/lib/module/TargetingData.js +0 -175
  41. package/lib/module/TargetingData.js.map +0 -1
  42. package/lib/module/types/TargetingData.js +0 -2
  43. package/lib/module/types/TargetingData.js.map +0 -1
  44. package/lib/typescript/src/TargetingData.d.ts +0 -26
  45. package/lib/typescript/src/TargetingData.d.ts.map +0 -1
  46. package/lib/typescript/src/types/TargetingData.d.ts +0 -43
  47. package/lib/typescript/src/types/TargetingData.d.ts.map +0 -1
  48. package/src/TargetingData.ts +0 -212
  49. package/src/types/TargetingData.ts +0 -50
package/ios/AppLovinMAX.m CHANGED
@@ -39,27 +39,8 @@
39
39
 
40
40
  // Store these values if pub attempts to set it before initializing
41
41
  @property (nonatomic, strong, nullable) NSArray<NSString *> *initializationAdUnitIdentifiersToSet;
42
- @property (nonatomic, copy, nullable) NSString *userIdentifierToSet;
43
- @property (nonatomic, strong, nullable) NSNumber *mutedToSet;
44
42
  @property (nonatomic, strong, nullable) NSArray<NSString *> *testDeviceIdentifiersToSet;
45
- @property (nonatomic, strong, nullable) NSNumber *verboseLoggingToSet;
46
- @property (nonatomic, strong, nullable) NSNumber *creativeDebuggerEnabledToSet;
47
- @property (nonatomic, strong, nullable) NSNumber *locationCollectionEnabledToSet;
48
- @property (nonatomic, strong) NSMutableDictionary<NSString *, NSString *> *extraParametersToSet;
49
-
50
- @property (nonatomic, strong, nullable) NSNumber *consentFlowEnabledToSet;
51
- @property (nonatomic, strong, nullable) NSNumber *termsAndPrivacyPolicyFlowEnabledToSet;
52
- @property (nonatomic, strong, nullable) NSURL *privacyPolicyURLToSet;
53
- @property (nonatomic, strong, nullable) NSURL *termsOfServiceURLToSet;
54
- @property (nonatomic, copy, nullable) NSString *debugUserGeographyToSet;
55
-
56
- @property (nonatomic, strong, nullable) NSNumber *targetingYearOfBirthToSet;
57
- @property (nonatomic, copy, nullable) NSString *targetingGenderToSet;
58
- @property (nonatomic, strong, nullable) NSNumber *targetingMaximumAdContentRatingToSet;
59
- @property (nonatomic, copy, nullable) NSString *targetingEmailToSet;
60
- @property (nonatomic, copy, nullable) NSString *targetingPhoneNumberToSet;
61
- @property (nonatomic, strong, nullable) NSArray<NSString *> *targetingKeywordsToSet;
62
- @property (nonatomic, strong, nullable) NSArray<NSString *> *targetingInterestsToSet;
43
+ @property (nonatomic, strong) MASegmentCollectionBuilder *segmentCollectionBuilder;
63
44
 
64
45
  // Fullscreen Ad Fields
65
46
  @property (nonatomic, strong) NSMutableDictionary<NSString *, MAInterstitialAd *> *interstitials;
@@ -106,7 +87,7 @@ static NSString *const ON_BANNER_AD_REVENUE_PAID = @"OnBannerAdRevenuePaid";
106
87
 
107
88
  static NSString *const ON_MREC_AD_LOADED_EVENT = @"OnMRecAdLoadedEvent";
108
89
  static NSString *const ON_MREC_AD_LOAD_FAILED_EVENT = @"OnMRecAdLoadFailedEvent";
109
- static NSString *const ON_MREC_AD_CLICKED_EVENT= @"OnMRecAdClickedEvent";
90
+ static NSString *const ON_MREC_AD_CLICKED_EVENT = @"OnMRecAdClickedEvent";
110
91
  static NSString *const ON_MREC_AD_COLLAPSED_EVENT = @"OnMRecAdCollapsedEvent";
111
92
  static NSString *const ON_MREC_AD_EXPANDED_EVENT = @"OnMRecAdExpandedEvent";
112
93
  static NSString *const ON_MREC_AD_REVENUE_PAID = @"OnMRecAdRevenuePaid";
@@ -136,8 +117,8 @@ static NSString *const ON_APPOPEN_AD_FAILED_TO_DISPLAY_EVENT = @"OnAppOpenAdFail
136
117
  static NSString *const ON_APPOPEN_AD_HIDDEN_EVENT = @"OnAppOpenAdHiddenEvent";
137
118
  static NSString *const ON_APPOPEN_AD_REVENUE_PAID = @"OnAppOpenAdRevenuePaid";
138
119
 
139
- static NSString *const ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOADED_EVENT = @"OnNativeUIComponentAdviewAdLoadedEvent";
140
- static NSString *const ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOAD_FAILED_EVENT = @"OnNativeUIComponentAdviewAdLoadFailedEvent";
120
+ static NSString *const ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOADED_EVENT = @"OnNativeUIComponentAdViewAdLoadedEvent";
121
+ static NSString *const ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOAD_FAILED_EVENT = @"OnNativeUIComponentAdViewAdLoadFailedEvent";
141
122
 
142
123
  static NSString *const TOP_CENTER = @"top_center";
143
124
  static NSString *const TOP_LEFT = @"top_left";
@@ -178,6 +159,9 @@ RCT_EXPORT_MODULE()
178
159
  {
179
160
  AppLovinMAXShared = self;
180
161
 
162
+ self.sdk = [ALSdk shared];
163
+ self.segmentCollectionBuilder = [MASegmentCollection builder];
164
+
181
165
  self.interstitials = [NSMutableDictionary dictionaryWithCapacity: 2];
182
166
  self.rewardedAds = [NSMutableDictionary dictionaryWithCapacity: 2];
183
167
  self.adViews = [NSMutableDictionary dictionaryWithCapacity: 2];
@@ -189,8 +173,7 @@ RCT_EXPORT_MODULE()
189
173
  self.adViewConstraints = [NSMutableDictionary dictionaryWithCapacity: 2];
190
174
  self.adUnitIdentifiersToShowAfterCreate = [NSMutableArray arrayWithCapacity: 2];
191
175
  self.disabledAdaptiveBannerAdUnitIdentifiers = [NSMutableSet setWithCapacity: 2];
192
- self.extraParametersToSet = [NSMutableDictionary dictionaryWithCapacity: 8];
193
-
176
+
194
177
  self.safeAreaBackground = [[UIView alloc] init];
195
178
  self.safeAreaBackground.hidden = YES;
196
179
  self.safeAreaBackground.backgroundColor = UIColor.clearColor;
@@ -222,162 +205,28 @@ RCT_EXPORT_METHOD(initialize:(NSString *)pluginVersion :(NSString *)sdkKey :(RCT
222
205
  // If SDK key passed in is empty, check Info.plist
223
206
  if ( ![sdkKey al_isValidString] )
224
207
  {
225
- if ( [[NSBundle mainBundle].infoDictionary al_containsValueForKey: @"AppLovinSdkKey"] )
226
- {
227
- sdkKey = [NSBundle mainBundle].infoDictionary[@"AppLovinSdkKey"];
228
- }
229
- else
230
- {
231
- reject(RCTErrorUnspecified, @"Unable to initialize AppLovin SDK - no SDK key provided and not found in Info.plist!", nil);
232
- return;
233
- }
234
- }
235
-
236
- ALSdkSettings *settings = [[ALSdkSettings alloc] init];
237
-
238
- // Selective init
239
- if ( self.initializationAdUnitIdentifiersToSet )
240
- {
241
- settings.initializationAdUnitIdentifiers = self.initializationAdUnitIdentifiersToSet;
242
- self.initializationAdUnitIdentifiersToSet = nil;
243
- }
244
-
245
- // Deprecated consent flow which automatically moves to the new flow
246
- if ( self.consentFlowEnabledToSet )
247
- {
248
- settings.consentFlowSettings.enabled = self.consentFlowEnabledToSet.boolValue;
249
- self.consentFlowEnabledToSet = nil;
250
-
251
- if ( self.privacyPolicyURLToSet )
252
- {
253
- settings.consentFlowSettings.privacyPolicyURL = self.privacyPolicyURLToSet;
254
- self.privacyPolicyURLToSet = nil;
255
- }
256
-
257
- if (self.termsOfServiceURLToSet )
258
- {
259
- settings.consentFlowSettings.termsOfServiceURL = self.termsOfServiceURLToSet;
260
- self.termsOfServiceURLToSet = nil;
261
- }
208
+ reject(RCTErrorUnspecified, @"Unable to initialize AppLovin SDK - no SDK key provided!", nil);
209
+ return;
262
210
  }
263
211
 
264
- // New terms and privacy policy flow
265
- if ( self.termsAndPrivacyPolicyFlowEnabledToSet )
266
- {
267
- settings.termsAndPrivacyPolicyFlowSettings.enabled = self.termsAndPrivacyPolicyFlowEnabledToSet.boolValue;
268
- self.termsAndPrivacyPolicyFlowEnabledToSet = nil;
269
-
270
- if ( self.privacyPolicyURLToSet )
271
- {
272
- settings.termsAndPrivacyPolicyFlowSettings.privacyPolicyURL = self.privacyPolicyURLToSet;
273
- self.privacyPolicyURLToSet = nil;
274
- }
275
-
276
- if ( self.termsOfServiceURLToSet )
212
+ ALSdkInitializationConfiguration *initConfig = [ALSdkInitializationConfiguration configurationWithSdkKey: sdkKey builderBlock:^(ALSdkInitializationConfigurationBuilder *builder) {
213
+
214
+ builder.mediationProvider = ALMediationProviderMAX;
215
+ builder.pluginVersion = [@"React-Native-" stringByAppendingString: pluginVersion];
216
+ builder.segmentCollection = [self.segmentCollectionBuilder build];
217
+ if ( self.initializationAdUnitIdentifiersToSet )
277
218
  {
278
- settings.termsAndPrivacyPolicyFlowSettings.termsOfServiceURL = self.termsOfServiceURLToSet;
279
- self.termsOfServiceURLToSet = nil;
219
+ builder.adUnitIdentifiers = self.initializationAdUnitIdentifiersToSet;
220
+ self.initializationAdUnitIdentifiersToSet = nil;
280
221
  }
281
-
282
- if ( self.debugUserGeographyToSet )
222
+ if ( self.testDeviceIdentifiersToSet )
283
223
  {
284
- settings.termsAndPrivacyPolicyFlowSettings.debugUserGeography = [self toAppLovinConsentFlowUserGeography: self.debugUserGeographyToSet];
285
- self.debugUserGeographyToSet = nil;
224
+ builder.testDeviceAdvertisingIdentifiers = self.testDeviceIdentifiersToSet;
225
+ self.testDeviceIdentifiersToSet = nil;
286
226
  }
287
- }
288
-
289
- // Set muted if needed
290
- if ( self.mutedToSet )
291
- {
292
- settings.muted = self.mutedToSet;
293
- self.mutedToSet = nil;
294
- }
295
-
296
- // Set test device ids if needed
297
- if ( self.testDeviceIdentifiersToSet )
298
- {
299
- settings.testDeviceAdvertisingIdentifiers = self.testDeviceIdentifiersToSet;
300
- self.testDeviceIdentifiersToSet = nil;
301
- }
302
-
303
- // Set verbose logging state if needed
304
- if ( self.verboseLoggingToSet )
305
- {
306
- settings.verboseLoggingEnabled = self.verboseLoggingToSet.boolValue;
307
- self.verboseLoggingToSet = nil;
308
- }
309
-
310
- // Set creative debugger enabled if needed.
311
- if ( self.creativeDebuggerEnabledToSet )
312
- {
313
- settings.creativeDebuggerEnabled = self.creativeDebuggerEnabledToSet.boolValue;
314
- self.creativeDebuggerEnabledToSet = nil;
315
- }
316
-
317
- // Set location collection enabled if needed
318
- if ( self.locationCollectionEnabledToSet )
319
- {
320
- settings.locationCollectionEnabled = self.locationCollectionEnabledToSet.boolValue;
321
- self.locationCollectionEnabledToSet = nil;
322
- }
323
-
324
- [self setPendingExtraParametersIfNeeded: settings];
325
-
326
- // Initialize SDK
327
- self.sdk = [ALSdk sharedWithKey: sdkKey settings: settings];
328
- [self.sdk setPluginVersion: [@"React-Native-" stringByAppendingString: pluginVersion]];
329
- [self.sdk setMediationProvider: ALMediationProviderMAX];
330
-
331
- // Set user id if needed
332
- if ( [self.userIdentifierToSet al_isValidString] )
333
- {
334
- self.sdk.userIdentifier = self.userIdentifierToSet;
335
- self.userIdentifierToSet = nil;
336
- }
337
-
338
- if ( self.targetingYearOfBirthToSet )
339
- {
340
- self.sdk.targetingData.yearOfBirth = self.targetingYearOfBirthToSet.intValue <= 0 ? nil : self.targetingYearOfBirthToSet;
341
- self.targetingYearOfBirthToSet = nil;
342
- }
343
-
344
- if ( self.targetingGenderToSet )
345
- {
346
- self.sdk.targetingData.gender = [self toAppLovinGender: self.targetingGenderToSet];
347
- self.targetingGenderToSet = nil;
348
- }
349
-
350
- if ( self.targetingMaximumAdContentRatingToSet )
351
- {
352
- self.sdk.targetingData.maximumAdContentRating = [self toAppLovinAdContentRating: self.targetingMaximumAdContentRatingToSet];
353
- self.targetingMaximumAdContentRatingToSet = nil;
354
- }
355
-
356
- if ( self.targetingEmailToSet )
357
- {
358
- self.sdk.targetingData.email = self.targetingEmailToSet;
359
- self.targetingEmailToSet = nil;
360
- }
361
-
362
- if ( self.targetingPhoneNumberToSet )
363
- {
364
- self.sdk.targetingData.phoneNumber = self.targetingPhoneNumberToSet;
365
- self.targetingPhoneNumberToSet = nil;
366
- }
367
-
368
- if ( self.targetingKeywordsToSet )
369
- {
370
- self.sdk.targetingData.keywords = self.targetingKeywordsToSet;
371
- self.targetingKeywordsToSet = nil;
372
- }
373
-
374
- if ( self.targetingInterestsToSet )
375
- {
376
- self.sdk.targetingData.interests = self.targetingInterestsToSet;
377
- self.targetingInterestsToSet = nil;
378
- }
227
+ }];
379
228
 
380
- [self.sdk initializeSdkWithCompletionHandler:^(ALSdkConfiguration *configuration) {
229
+ [self.sdk initializeWithConfiguration: initConfig completionHandler:^(ALSdkConfiguration *configuration) {
381
230
 
382
231
  [self log: @"SDK initialized"];
383
232
 
@@ -412,7 +261,7 @@ RCT_EXPORT_METHOD(isTablet:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlo
412
261
 
413
262
  RCT_EXPORT_METHOD(showMediationDebugger)
414
263
  {
415
- if ( !self.sdk )
264
+ if ( !self.isSDKInitialized )
416
265
  {
417
266
  [self logUninitializedAccessError: @"showMediationDebugger"];
418
267
  return;
@@ -453,72 +302,32 @@ RCT_EXPORT_METHOD(isDoNotSell:(RCTPromiseResolveBlock)resolve :(RCTPromiseReject
453
302
 
454
303
  RCT_EXPORT_METHOD(setUserId:(NSString *)userId)
455
304
  {
456
- if ( [self isPluginInitialized] )
457
- {
458
- self.sdk.userIdentifier = userId;
459
- self.userIdentifierToSet = nil;
460
- }
461
- else
462
- {
463
- self.userIdentifierToSet = userId;
464
- }
305
+ self.sdk.settings.userIdentifier = userId;
465
306
  }
466
307
 
467
308
  RCT_EXPORT_METHOD(setMuted:(BOOL)muted)
468
309
  {
469
- if ( [self isPluginInitialized] )
470
- {
471
- self.sdk.settings.muted = muted;
472
- self.mutedToSet = nil;
473
- }
474
- else
475
- {
476
- self.mutedToSet = @(muted);
477
- }
310
+ self.sdk.settings.muted = muted;
478
311
  }
479
312
 
480
313
  RCT_EXPORT_METHOD(isMuted:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
481
314
  {
482
- resolve([self isPluginInitialized] ? @(self.sdk.settings.muted) : @(NO) );
315
+ resolve(@(self.sdk.settings.muted));
483
316
  }
484
317
 
485
318
  RCT_EXPORT_METHOD(setVerboseLogging:(BOOL)enabled)
486
319
  {
487
- if ( [self isPluginInitialized] )
488
- {
489
- self.sdk.settings.verboseLoggingEnabled = enabled;
490
- self.verboseLoggingToSet = nil;
491
- }
492
- else
493
- {
494
- self.verboseLoggingToSet = @(enabled);
495
- }
320
+ self.sdk.settings.verboseLoggingEnabled = enabled;
496
321
  }
497
322
 
498
323
  RCT_EXPORT_METHOD(setTestDeviceAdvertisingIds:(NSArray<NSString *> *)testDeviceAdvertisingIds)
499
324
  {
500
- if ( [self isPluginInitialized] )
501
- {
502
- self.sdk.settings.testDeviceAdvertisingIdentifiers = testDeviceAdvertisingIds;
503
- self.testDeviceIdentifiersToSet = nil;
504
- }
505
- else
506
- {
507
- self.testDeviceIdentifiersToSet = testDeviceAdvertisingIds;
508
- }
325
+ self.testDeviceIdentifiersToSet = testDeviceAdvertisingIds;
509
326
  }
510
327
 
511
328
  RCT_EXPORT_METHOD(setCreativeDebuggerEnabled:(BOOL)enabled)
512
329
  {
513
- if ( [self isPluginInitialized] )
514
- {
515
- self.sdk.settings.creativeDebuggerEnabled = enabled;
516
- self.creativeDebuggerEnabledToSet = nil;
517
- }
518
- else
519
- {
520
- self.creativeDebuggerEnabledToSet = @(enabled);
521
- }
330
+ self.sdk.settings.creativeDebuggerEnabled = enabled;
522
331
  }
523
332
 
524
333
  RCT_EXPORT_METHOD(setExtraParameter:(NSString *)key :(nullable NSString *)value)
@@ -529,16 +338,7 @@ RCT_EXPORT_METHOD(setExtraParameter:(NSString *)key :(nullable NSString *)value)
529
338
  return;
530
339
  }
531
340
 
532
- if ( self.sdk )
533
- {
534
- ALSdkSettings *settings = self.sdk.settings;
535
- [settings setExtraParameterForKey: key value: value];
536
- [self setPendingExtraParametersIfNeeded: settings];
537
- }
538
- else
539
- {
540
- self.extraParametersToSet[key] = value;
541
- }
341
+ [self.sdk.settings setExtraParameterForKey: key value: value];
542
342
  }
543
343
 
544
344
  RCT_EXPORT_METHOD(setInitializationAdUnitIds:(NSArray<NSString *> *)adUnitIds)
@@ -550,27 +350,31 @@ RCT_EXPORT_METHOD(setInitializationAdUnitIds:(NSArray<NSString *> *)adUnitIds)
550
350
 
551
351
  RCT_EXPORT_METHOD(setConsentFlowEnabled:(BOOL)enabled)
552
352
  {
553
- self.consentFlowEnabledToSet = @(enabled);
353
+ self.sdk.settings.consentFlowSettings.enabled = enabled;
554
354
  }
555
355
 
556
356
  RCT_EXPORT_METHOD(setTermsAndPrivacyPolicyFlowEnabled:(BOOL)enabled)
557
357
  {
558
- self.termsAndPrivacyPolicyFlowEnabledToSet = @(enabled);
358
+ self.sdk.settings.termsAndPrivacyPolicyFlowSettings.enabled = enabled;
559
359
  }
560
360
 
561
361
  RCT_EXPORT_METHOD(setPrivacyPolicyUrl:(NSString *)urlString)
562
362
  {
563
- self.privacyPolicyURLToSet = [NSURL URLWithString: urlString];
363
+ NSURL *url = [NSURL URLWithString: urlString];
364
+ self.sdk.settings.termsAndPrivacyPolicyFlowSettings.privacyPolicyURL = url;
365
+ self.sdk.settings.consentFlowSettings.privacyPolicyURL = url;
564
366
  }
565
367
 
566
368
  RCT_EXPORT_METHOD(setTermsOfServiceUrl:(NSString *)urlString)
567
369
  {
568
- self.termsOfServiceURLToSet = [NSURL URLWithString: urlString];
370
+ NSURL *url = [NSURL URLWithString: urlString];
371
+ self.sdk.settings.termsAndPrivacyPolicyFlowSettings.termsOfServiceURL = url;
372
+ self.sdk.settings.consentFlowSettings.termsOfServiceURL = url;
569
373
  }
570
374
 
571
375
  RCT_EXPORT_METHOD(setConsentFlowDebugUserGeography:(NSString *)userGeography)
572
376
  {
573
- self.debugUserGeographyToSet = userGeography;
377
+ self.sdk.settings.termsAndPrivacyPolicyFlowSettings.debugUserGeography = [self toAppLovinConsentFlowUserGeography: userGeography];
574
378
  }
575
379
 
576
380
  RCT_EXPORT_METHOD(showCmpForExistingUser:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
@@ -607,190 +411,47 @@ RCT_EXPORT_METHOD(hasSupportedCmp:(RCTPromiseResolveBlock)resolve :(RCTPromiseRe
607
411
  resolve(@([self.sdk.cmpService hasSupportedCMP]));
608
412
  }
609
413
 
610
- #pragma mark - Data Passing
611
-
612
- RCT_EXPORT_METHOD(setTargetingDataYearOfBirth:(nonnull NSNumber *)yearOfBirth)
613
- {
614
- if ( !self.sdk )
615
- {
616
- self.targetingYearOfBirthToSet = yearOfBirth;
617
- return;
618
- }
619
-
620
- self.sdk.targetingData.yearOfBirth = yearOfBirth.intValue <= 0 ? nil : yearOfBirth;
621
- }
622
-
623
- RCT_EXPORT_METHOD(getTargetingDataYearOfBirth:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
624
- {
625
- if ( !self.sdk )
626
- {
627
- resolve(self.targetingYearOfBirthToSet ? self.targetingYearOfBirthToSet : @0);
628
- return;
629
- }
630
-
631
- resolve(self.sdk.targetingData.yearOfBirth ? self.sdk.targetingData.yearOfBirth : @0);
632
- }
414
+ #pragma mark - Segment Targeting
633
415
 
634
- RCT_EXPORT_METHOD(setTargetingDataGender:(nullable NSString *)gender)
416
+ RCT_EXPORT_METHOD(addSegment:(nonnull NSNumber *)key :(NSArray<NSNumber *> *)values :(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
635
417
  {
636
- if ( !self.sdk )
637
- {
638
- self.targetingGenderToSet = gender;
639
- return;
640
- }
641
-
642
- self.sdk.targetingData.gender = [self toAppLovinGender: gender];
643
- }
644
-
645
- RCT_EXPORT_METHOD(getTargetingDataGender:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
646
- {
647
- if ( !self.sdk )
648
- {
649
- resolve(self.targetingGenderToSet ? self.targetingGenderToSet : @"U");
650
- return;
651
- }
652
-
653
- resolve([self fromAppLovinGender: self.sdk.targetingData.gender]);
654
- }
655
-
656
- RCT_EXPORT_METHOD(setTargetingDataMaximumAdContentRating:(nonnull NSNumber *)maximumAdContentRating)
657
- {
658
- if ( !self.sdk )
659
- {
660
- self.targetingMaximumAdContentRatingToSet = maximumAdContentRating;
661
- return;
662
- }
663
-
664
- self.sdk.targetingData.maximumAdContentRating = [self toAppLovinAdContentRating: maximumAdContentRating];
665
- }
666
-
667
- RCT_EXPORT_METHOD(getTargetingDataMaximumAdContentRating:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
668
- {
669
- if ( !self.sdk )
670
- {
671
- resolve(self.targetingMaximumAdContentRatingToSet ? self.targetingMaximumAdContentRatingToSet : @0);
672
- return;
673
- }
674
-
675
- resolve(@(self.sdk.targetingData.maximumAdContentRating));
676
- }
677
-
678
- RCT_EXPORT_METHOD(setTargetingDataEmail:(nullable NSString *)email)
679
- {
680
- if ( !self.sdk )
681
- {
682
- self.targetingEmailToSet = email;
683
- return;
684
- }
685
-
686
- self.sdk.targetingData.email = email;
687
- }
688
-
689
- RCT_EXPORT_METHOD(getTargetingDataEmail:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
690
- {
691
- if ( !self.sdk )
692
- {
693
- resolve(self.targetingEmailToSet);
694
- return;
695
- }
696
-
697
- resolve(self.sdk.targetingData.email);
698
- }
699
-
700
- RCT_EXPORT_METHOD(setTargetingDataPhoneNumber:(nullable NSString *)phoneNumber)
701
- {
702
- if ( !self.sdk )
703
- {
704
- self.targetingPhoneNumberToSet = phoneNumber;
705
- return;
706
- }
707
-
708
- self.sdk.targetingData.phoneNumber = phoneNumber;
709
- }
710
-
711
- RCT_EXPORT_METHOD(getTargetingDataPhoneNumber:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
712
- {
713
- if ( !self.sdk )
418
+ if ( [self isPluginInitialized] )
714
419
  {
715
- resolve(self.targetingPhoneNumberToSet);
420
+ reject(RCTErrorUnspecified, @"A segment must be added before calling 'AppLovinMAX.initialize(...);'", nil);
716
421
  return;
717
422
  }
718
423
 
719
- resolve(self.sdk.targetingData.phoneNumber);
720
- }
721
-
722
- RCT_EXPORT_METHOD(setTargetingDataKeywords:(nullable NSArray<NSString *> *)keywords)
723
- {
724
- if ( !self.sdk )
725
- {
726
- self.targetingKeywordsToSet = keywords;
727
- return;
728
- }
424
+ [self.segmentCollectionBuilder addSegment: [[MASegment alloc] initWithKey: key values: values]];
729
425
 
730
- self.sdk.targetingData.keywords = keywords;
426
+ resolve(nil);
731
427
  }
732
428
 
733
- RCT_EXPORT_METHOD(getTargetingDataKeywords:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
429
+ RCT_EXPORT_METHOD(getSegments:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
734
430
  {
735
- if ( !self.sdk )
431
+ if ( ![self isSDKInitialized] )
736
432
  {
737
- resolve(self.targetingKeywordsToSet);
433
+ reject(RCTErrorUnspecified, @"Segments cannot be retrieved before calling 'AppLovinMAX.initialize(...).'", nil);
738
434
  return;
739
435
  }
740
436
 
741
- resolve(self.sdk.targetingData.keywords);
742
- }
437
+ NSArray<MASegment *> *segments = self.sdk.segmentCollection.segments;
743
438
 
744
- RCT_EXPORT_METHOD(setTargetingDataInterests:(nullable NSArray<NSString *> *)interests)
745
- {
746
- if ( !self.sdk )
439
+ if ( ![segments count] )
747
440
  {
748
- self.targetingInterestsToSet = interests;
441
+ resolve(nil);
749
442
  return;
750
443
  }
751
444
 
752
- self.sdk.targetingData.interests = interests;
753
- }
754
-
755
- RCT_EXPORT_METHOD(getTargetingDataInterests:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
756
- {
757
- if ( !self.sdk )
758
- {
759
- resolve(self.targetingInterestsToSet);
760
- return;
761
- }
445
+ NSMutableDictionary<NSString *, NSArray<NSNumber *> *> *jsObj = [NSMutableDictionary dictionaryWithCapacity: [segments count]];
762
446
 
763
- resolve(self.sdk.targetingData.interests);
764
- }
765
-
766
- RCT_EXPORT_METHOD(clearAllTargetingData)
767
- {
768
- if ( !self.sdk )
447
+ for ( MASegment *segment in segments )
769
448
  {
770
- self.targetingYearOfBirthToSet = nil;
771
- self.targetingGenderToSet = nil;
772
- self.targetingMaximumAdContentRatingToSet = nil;
773
- self.targetingEmailToSet = nil;
774
- self.targetingPhoneNumberToSet = nil;
775
- self.targetingKeywordsToSet = nil;
776
- self.targetingInterestsToSet = nil;
777
- return;
449
+ // JavaScript can't have integer as a key.
450
+ NSString *strKey = [segment.key stringValue];
451
+ jsObj[strKey] = segment.values;
778
452
  }
779
-
780
- [self.sdk.targetingData clearAll];
781
- }
782
453
 
783
- RCT_EXPORT_METHOD(setLocationCollectionEnabled:(BOOL)enabled)
784
- {
785
- if ( [self isPluginInitialized] )
786
- {
787
- self.sdk.settings.locationCollectionEnabled = enabled;
788
- self.locationCollectionEnabledToSet = nil;
789
- }
790
- else
791
- {
792
- self.locationCollectionEnabledToSet = @(enabled);
793
- }
454
+ resolve(jsObj);
794
455
  }
795
456
 
796
457
  #pragma mark - Event Tracking
@@ -1271,7 +932,14 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
1271
932
 
1272
933
  #pragma mark - AdView Preloading
1273
934
 
1274
- RCT_EXPORT_METHOD(preloadNativeUIComponentAdView:(NSString *)adUnitIdentifier :(NSString *)adFormatStr :(NSString *)placement :(NSString *)customData :(NSDictionary<NSString *, id> *)extraParameterDict :(NSDictionary<NSString *, id> *)localExtraParameterDict :(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
935
+ RCT_EXPORT_METHOD(preloadNativeUIComponentAdView:(NSString *)adUnitIdentifier
936
+ :(NSString *)adFormatStr
937
+ :(nullable NSString *)placement
938
+ :(nullable NSString *)customData
939
+ :(nullable NSDictionary<NSString *, id> *)extraParameterDict
940
+ :(nullable NSDictionary<NSString *, id> *)localExtraParameterDict
941
+ :(RCTPromiseResolveBlock)resolve
942
+ :(RCTPromiseRejectBlock)reject)
1275
943
  {
1276
944
  MAAdFormat *adFormat;
1277
945
 
@@ -1289,12 +957,23 @@ RCT_EXPORT_METHOD(preloadNativeUIComponentAdView:(NSString *)adUnitIdentifier :(
1289
957
  return;
1290
958
  }
1291
959
 
1292
- [AppLovinMAXAdView preloadNativeUIComponentAdView:adUnitIdentifier adFormat:adFormat placement:placement customData:customData extraParameters:extraParameterDict localExtraParameters:localExtraParameterDict withPromiseResolver:resolve withPromiseRejecter:reject];
960
+ [AppLovinMAXAdView preloadNativeUIComponentAdView: adUnitIdentifier
961
+ adFormat: adFormat
962
+ placement: placement
963
+ customData: customData
964
+ extraParameters: extraParameterDict
965
+ localExtraParameters: localExtraParameterDict
966
+ withPromiseResolver: resolve
967
+ withPromiseRejecter: reject];
1293
968
  }
1294
969
 
1295
- RCT_EXPORT_METHOD(destroyNativeUIComponentAdView:(NSString *)adUnitIdentifier :(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
970
+ RCT_EXPORT_METHOD(destroyNativeUIComponentAdView:(NSString *)adUnitIdentifier
971
+ :(RCTPromiseResolveBlock)resolve
972
+ :(RCTPromiseRejectBlock)reject)
1296
973
  {
1297
- [AppLovinMAXAdView destroyNativeUIComponentAdView:adUnitIdentifier withPromiseResolver:resolve withPromiseRejecter:reject];
974
+ [AppLovinMAXAdView destroyNativeUIComponentAdView: adUnitIdentifier
975
+ withPromiseResolver: resolve
976
+ withPromiseRejecter: reject];
1298
977
  }
1299
978
 
1300
979
  #pragma mark - Ad Callbacks
@@ -1351,7 +1030,7 @@ RCT_EXPORT_METHOD(destroyNativeUIComponentAdView:(NSString *)adUnitIdentifier :(
1351
1030
  NSString *name;
1352
1031
  if ( self.adViews[adUnitIdentifier] )
1353
1032
  {
1354
- name = ( MAAdFormat.mrec == self.adViewAdFormats[adUnitIdentifier] ) ? @"OnMRecAdLoadFailedEvent" : @"OnBannerAdLoadFailedEvent";
1033
+ name = ( MAAdFormat.mrec == self.adViewAdFormats[adUnitIdentifier] ) ? ON_MREC_AD_LOAD_FAILED_EVENT : ON_BANNER_AD_LOAD_FAILED_EVENT;
1355
1034
  }
1356
1035
  else if ( self.interstitials[adUnitIdentifier] )
1357
1036
  {
@@ -2057,18 +1736,6 @@ RCT_EXPORT_METHOD(destroyNativeUIComponentAdView:(NSString *)adUnitIdentifier :(
2057
1736
  [NSLayoutConstraint activateConstraints: constraints];
2058
1737
  }
2059
1738
 
2060
- - (void)setPendingExtraParametersIfNeeded:(ALSdkSettings *)settings
2061
- {
2062
- if ( self.extraParametersToSet.count <= 0 ) return;
2063
-
2064
- for ( NSString *key in self.extraParametersToSet.allKeys )
2065
- {
2066
- [settings setExtraParameterForKey: key value: self.extraParametersToSet[key]];
2067
- }
2068
-
2069
- [self.extraParametersToSet removeAllObjects];
2070
- }
2071
-
2072
1739
  - (void)logInvalidAdFormat:(MAAdFormat *)adFormat
2073
1740
  {
2074
1741
  [self logInvalidAdFormat: adFormat withPromiseReject: nil];
@@ -2076,7 +1743,7 @@ RCT_EXPORT_METHOD(destroyNativeUIComponentAdView:(NSString *)adUnitIdentifier :(
2076
1743
 
2077
1744
  - (void)logInvalidAdFormat:(MAAdFormat *)adFormat withPromiseReject:(nullable RCTPromiseRejectBlock)reject
2078
1745
  {
2079
- NSString *message = [NSString stringWithFormat:@"invalid ad format: %@, from %@", adFormat, [NSThread callStackSymbols]];
1746
+ NSString *message = [NSString stringWithFormat: @"invalid ad format: %@, from %@", adFormat, [NSThread callStackSymbols]];
2080
1747
 
2081
1748
  if ( !reject )
2082
1749
  {
@@ -2094,7 +1761,7 @@ RCT_EXPORT_METHOD(destroyNativeUIComponentAdView:(NSString *)adUnitIdentifier :(
2094
1761
 
2095
1762
  - (void)logUninitializedAccessError:(NSString *)callingMethod withPromiseReject:(nullable RCTPromiseRejectBlock)reject
2096
1763
  {
2097
- NSString *message = [NSString stringWithFormat:@"ERROR: Failed to execute %@() - please ensure the AppLovin MAX React Native module has been initialized by calling 'AppLovinMAX.initialize(...);'!", callingMethod];
1764
+ NSString *message = [NSString stringWithFormat: @"ERROR: Failed to execute %@() - please ensure the AppLovin MAX React Native module has been initialized by calling 'AppLovinMAX.initialize(...);'!", callingMethod];
2098
1765
 
2099
1766
  if ( !reject )
2100
1767
  {
@@ -2115,68 +1782,6 @@ RCT_EXPORT_METHOD(destroyNativeUIComponentAdView:(NSString *)adUnitIdentifier :(
2115
1782
  NSLog(@"[%@] [%@] %@", SDK_TAG, TAG, message);
2116
1783
  }
2117
1784
 
2118
- - (ALGender)toAppLovinGender:(nullable NSString *)gender
2119
- {
2120
- if ( gender )
2121
- {
2122
- if ( [@"F" al_isEqualToStringIgnoringCase: gender] )
2123
- {
2124
- return ALGenderFemale;
2125
- }
2126
- else if ( [@"M" al_isEqualToStringIgnoringCase: gender] )
2127
- {
2128
- return ALGenderMale;
2129
- }
2130
- else if ( [@"O" al_isEqualToStringIgnoringCase: gender] )
2131
- {
2132
- return ALGenderOther;
2133
- }
2134
- }
2135
-
2136
- return ALGenderUnknown;
2137
- }
2138
-
2139
- - (NSString *)fromAppLovinGender:(ALGender)gender
2140
- {
2141
- if ( gender == ALGenderFemale )
2142
- {
2143
- return @"F";
2144
- }
2145
- else if ( gender == ALGenderMale )
2146
- {
2147
- return @"M";
2148
- }
2149
- else if ( gender == ALGenderOther )
2150
- {
2151
- return @"O";
2152
- }
2153
-
2154
- return @"U";
2155
- }
2156
-
2157
- - (ALAdContentRating)toAppLovinAdContentRating:(nullable NSNumber *)maximumAdContentRating
2158
- {
2159
- if ( maximumAdContentRating )
2160
- {
2161
- int intVal = maximumAdContentRating.intValue;
2162
-
2163
- if ( intVal == 1 )
2164
- {
2165
- return ALAdContentRatingAllAudiences;
2166
- }
2167
- else if ( intVal == 2 )
2168
- {
2169
- return ALAdContentRatingEveryoneOverTwelve;
2170
- }
2171
- else if ( intVal == 3 )
2172
- {
2173
- return ALAdContentRatingMatureAudiences;
2174
- }
2175
- }
2176
-
2177
- return ALAdContentRatingNone;
2178
- }
2179
-
2180
1785
  - (ALConsentFlowUserGeography)toAppLovinConsentFlowUserGeography:(NSString *)userGeography
2181
1786
  {
2182
1787
  if ( [USER_GEOGRAPHY_GDPR al_isEqualToStringIgnoringCase: userGeography] )