react-native-applovin-max 7.0.1 → 7.1.0

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 (35) hide show
  1. package/android/build.gradle +3 -3
  2. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXModule.java +59 -508
  3. package/ios/AppLovinMAX.m +55 -468
  4. package/lib/commonjs/AppLovinMAX.js +19 -3
  5. package/lib/commonjs/AppLovinMAX.js.map +1 -1
  6. package/lib/commonjs/index.js +0 -22
  7. package/lib/commonjs/index.js.map +1 -1
  8. package/lib/module/AppLovinMAX.js +19 -3
  9. package/lib/module/AppLovinMAX.js.map +1 -1
  10. package/lib/module/index.js +0 -1
  11. package/lib/module/index.js.map +1 -1
  12. package/lib/typescript/src/AppLovinMAX.d.ts.map +1 -1
  13. package/lib/typescript/src/index.d.ts +0 -1
  14. package/lib/typescript/src/index.d.ts.map +1 -1
  15. package/lib/typescript/src/types/AppLovinMAX.d.ts +18 -6
  16. package/lib/typescript/src/types/AppLovinMAX.d.ts.map +1 -1
  17. package/package.json +1 -1
  18. package/react-native-applovin-max.podspec +2 -2
  19. package/src/AppLovinMAX.ts +24 -3
  20. package/src/index.ts +0 -1
  21. package/src/types/AppLovinMAX.ts +20 -7
  22. package/lib/commonjs/TargetingData.js +0 -179
  23. package/lib/commonjs/TargetingData.js.map +0 -1
  24. package/lib/commonjs/types/TargetingData.js +0 -6
  25. package/lib/commonjs/types/TargetingData.js.map +0 -1
  26. package/lib/module/TargetingData.js +0 -175
  27. package/lib/module/TargetingData.js.map +0 -1
  28. package/lib/module/types/TargetingData.js +0 -2
  29. package/lib/module/types/TargetingData.js.map +0 -1
  30. package/lib/typescript/src/TargetingData.d.ts +0 -26
  31. package/lib/typescript/src/TargetingData.d.ts.map +0 -1
  32. package/lib/typescript/src/types/TargetingData.d.ts +0 -43
  33. package/lib/typescript/src/types/TargetingData.d.ts.map +0 -1
  34. package/src/TargetingData.ts +0 -212
  35. package/src/types/TargetingData.ts +0 -50
@@ -2,8 +2,6 @@ package com.applovin.reactnative;
2
2
 
3
3
  import android.app.Activity;
4
4
  import android.content.Context;
5
- import android.content.pm.ApplicationInfo;
6
- import android.content.pm.PackageManager;
7
5
  import android.graphics.Color;
8
6
  import android.graphics.Point;
9
7
  import android.graphics.Rect;
@@ -32,6 +30,8 @@ import com.applovin.mediation.MaxMediatedNetworkInfo;
32
30
  import com.applovin.mediation.MaxNetworkResponseInfo;
33
31
  import com.applovin.mediation.MaxReward;
34
32
  import com.applovin.mediation.MaxRewardedAdListener;
33
+ import com.applovin.mediation.MaxSegment;
34
+ import com.applovin.mediation.MaxSegmentCollection;
35
35
  import com.applovin.mediation.ads.MaxAdView;
36
36
  import com.applovin.mediation.ads.MaxAppOpenAd;
37
37
  import com.applovin.mediation.ads.MaxInterstitialAd;
@@ -42,10 +42,8 @@ import com.applovin.sdk.AppLovinPrivacySettings;
42
42
  import com.applovin.sdk.AppLovinSdk;
43
43
  import com.applovin.sdk.AppLovinSdkConfiguration;
44
44
  import com.applovin.sdk.AppLovinSdkConfiguration.ConsentFlowUserGeography;
45
- import com.applovin.sdk.AppLovinSdkSettings;
45
+ import com.applovin.sdk.AppLovinSdkInitializationConfiguration;
46
46
  import com.applovin.sdk.AppLovinSdkUtils;
47
- import com.applovin.sdk.AppLovinTargetingData.AdContentRating;
48
- import com.applovin.sdk.AppLovinTargetingData.Gender;
49
47
  import com.facebook.react.bridge.Arguments;
50
48
  import com.facebook.react.bridge.LifecycleEventListener;
51
49
  import com.facebook.react.bridge.Promise;
@@ -143,36 +141,18 @@ public class AppLovinMAXModule
143
141
  private static Activity currentActivity;
144
142
 
145
143
  // Parent Fields
146
- private AppLovinSdk sdk;
147
- private boolean isPluginInitialized;
148
- private boolean isSdkInitialized;
149
- private AppLovinSdkConfiguration sdkConfiguration;
144
+ private final AppLovinSdk sdk;
145
+ private boolean isPluginInitialized;
146
+ private boolean isSdkInitialized;
147
+ private AppLovinSdkConfiguration sdkConfiguration;
150
148
 
151
149
  private WindowManager windowManager;
152
150
  private int lastRotation;
153
151
 
154
152
  // Store these values if pub attempts to set it before initializing
155
- private List<String> initializationAdUnitIdsToSet;
156
- private String userIdToSet;
157
- private Boolean mutedToSet;
158
- private List<String> testDeviceAdvertisingIdsToSet;
159
- private Boolean verboseLoggingToSet;
160
- private Boolean creativeDebuggerEnabledToSet;
161
- private Boolean locationCollectionEnabledToSet;
162
- private final Map<String, String> extraParametersToSet = new HashMap<>( 8 );
163
-
164
- private Boolean termsAndPrivacyPolicyFlowEnabledToSet;
165
- private Uri privacyPolicyURLToSet;
166
- private Uri termsOfServiceURLToSet;
167
- private String debugUserGeographyToSet;
168
-
169
- private Integer targetingYearOfBirthToSet;
170
- private String targetingGenderToSet;
171
- private Integer targetingMaximumAdContentRatingToSet;
172
- private String targetingEmailToSet;
173
- private String targetingPhoneNumberToSet;
174
- private List targetingKeywordsToSet;
175
- private List targetingInterestsToSet;
153
+ private List<String> initializationAdUnitIdsToSet;
154
+ private List<String> testDeviceAdvertisingIdsToSet;
155
+ private MaxSegmentCollection.Builder segmentCollectionBuilder = MaxSegmentCollection.builder();
176
156
 
177
157
  // Fullscreen Ad Fields
178
158
  private final Map<String, MaxInterstitialAd> interstitials = new HashMap<>( 2 );
@@ -205,6 +185,8 @@ public class AppLovinMAXModule
205
185
  instance = this;
206
186
  currentActivity = reactContext.getCurrentActivity();
207
187
 
188
+ sdk = AppLovinSdk.getInstance( reactContext );
189
+
208
190
  // Listening to Lifecycle Events
209
191
  reactContext.addLifecycleEventListener( this );
210
192
  }
@@ -249,160 +231,32 @@ public class AppLovinMAXModule
249
231
 
250
232
  d( "Initializing AppLovin MAX React Native v" + pluginVersion + "..." );
251
233
 
252
- // If SDK key passed in is empty, check Android Manifest
253
- String sdkKeyToUse = sdkKey;
254
234
  if ( TextUtils.isEmpty( sdkKey ) )
255
235
  {
256
- try
257
- {
258
- PackageManager packageManager = getReactApplicationContext().getPackageManager();
259
- String packageName = getReactApplicationContext().getPackageName();
260
- ApplicationInfo applicationInfo = packageManager.getApplicationInfo( packageName, PackageManager.GET_META_DATA );
261
- Bundle metaData = applicationInfo.metaData;
262
-
263
- sdkKeyToUse = metaData.getString( "applovin.sdk.key", "" );
264
- }
265
- catch ( Throwable th )
266
- {
267
- e( "Unable to retrieve SDK key from Android Manifest: " + th );
268
- }
269
-
270
- if ( TextUtils.isEmpty( sdkKeyToUse ) )
271
- {
272
- promise.reject( new IllegalStateException( "Unable to initialize AppLovin SDK - no SDK key provided and not found in Android Manifest!" ) );
273
- return;
274
- }
236
+ promise.reject( new IllegalStateException( "Unable to initialize AppLovin SDK - no SDK key provided!" ) );
237
+ return;
275
238
  }
276
239
 
277
- AppLovinSdkSettings settings = new AppLovinSdkSettings( getReactApplicationContext() );
278
-
279
- // Selective init
240
+ AppLovinSdkInitializationConfiguration.Builder initConfigBuidler = AppLovinSdkInitializationConfiguration.builder( sdkKey, getReactApplicationContext() );
241
+ initConfigBuidler.setPluginVersion( "React-Native-" + pluginVersion );
242
+ initConfigBuidler.setMediationProvider( AppLovinMediationProvider.MAX );
243
+ initConfigBuidler.setSegmentCollection( segmentCollectionBuilder.build() );
280
244
  if ( initializationAdUnitIdsToSet != null )
281
245
  {
282
- settings.setInitializationAdUnitIds( initializationAdUnitIdsToSet );
246
+ initConfigBuidler.setAdUnitIds( initializationAdUnitIdsToSet );
283
247
  initializationAdUnitIdsToSet = null;
284
248
  }
285
-
286
- if ( termsAndPrivacyPolicyFlowEnabledToSet != null )
287
- {
288
- settings.getTermsAndPrivacyPolicyFlowSettings().setEnabled( termsAndPrivacyPolicyFlowEnabledToSet );
289
- termsAndPrivacyPolicyFlowEnabledToSet = null;
290
- }
291
-
292
- if ( privacyPolicyURLToSet != null )
293
- {
294
- settings.getTermsAndPrivacyPolicyFlowSettings().setPrivacyPolicyUri( privacyPolicyURLToSet );
295
- privacyPolicyURLToSet = null;
296
- }
297
-
298
- if ( termsOfServiceURLToSet != null )
299
- {
300
- settings.getTermsAndPrivacyPolicyFlowSettings().setTermsOfServiceUri( termsOfServiceURLToSet );
301
- termsOfServiceURLToSet = null;
302
- }
303
-
304
- if ( AppLovinSdkUtils.isValidString( debugUserGeographyToSet ) )
305
- {
306
- settings.getTermsAndPrivacyPolicyFlowSettings().setDebugUserGeography( getAppLovinConsentFlowUserGeography( debugUserGeographyToSet ) );
307
- debugUserGeographyToSet = null;
308
- }
309
-
310
- // Set muted if needed
311
- if ( mutedToSet != null )
312
- {
313
- settings.setMuted( mutedToSet );
314
- mutedToSet = null;
315
- }
316
-
317
- // Set test device ids if needed
318
249
  if ( testDeviceAdvertisingIdsToSet != null )
319
250
  {
320
- settings.setTestDeviceAdvertisingIds( testDeviceAdvertisingIdsToSet );
251
+ initConfigBuidler.setTestDeviceAdvertisingIds( testDeviceAdvertisingIdsToSet );
321
252
  testDeviceAdvertisingIdsToSet = null;
322
253
  }
323
254
 
324
- // Set verbose logging state if needed
325
- if ( verboseLoggingToSet != null )
326
- {
327
- settings.setVerboseLogging( verboseLoggingToSet );
328
- verboseLoggingToSet = null;
329
- }
330
-
331
- // Set creative debugger enabled if needed.
332
- if ( creativeDebuggerEnabledToSet != null )
333
- {
334
- settings.setCreativeDebuggerEnabled( creativeDebuggerEnabledToSet );
335
- creativeDebuggerEnabledToSet = null;
336
- }
337
-
338
- // Set location collection enabled if needed
339
- if ( locationCollectionEnabledToSet != null )
340
- {
341
- settings.setLocationCollectionEnabled( locationCollectionEnabledToSet );
342
- locationCollectionEnabledToSet = null;
343
- }
344
-
345
- setPendingExtraParametersIfNeeded( settings );
346
-
347
255
  // Initialize SDK
348
- sdk = AppLovinSdk.getInstance( sdkKeyToUse, settings, getReactApplicationContext() );
349
- sdk.setPluginVersion( "React-Native-" + pluginVersion );
350
- sdk.setMediationProvider( AppLovinMediationProvider.MAX );
351
-
352
- // Set user id if needed
353
- if ( AppLovinSdkUtils.isValidString( userIdToSet ) )
354
- {
355
- sdk.setUserIdentifier( userIdToSet );
356
- userIdToSet = null;
357
- }
358
-
359
- if ( targetingYearOfBirthToSet != null )
360
- {
361
- sdk.getTargetingData().setYearOfBirth( targetingYearOfBirthToSet <= 0 ? null : targetingYearOfBirthToSet );
362
- targetingYearOfBirthToSet = null;
363
- }
364
-
365
- if ( targetingGenderToSet != null )
366
- {
367
- sdk.getTargetingData().setGender( getAppLovinGender( targetingGenderToSet ) );
368
- targetingGenderToSet = null;
369
- }
370
-
371
- if ( targetingMaximumAdContentRatingToSet != null )
372
- {
373
- sdk.getTargetingData().setMaximumAdContentRating( getAppLovinAdContentRating( targetingMaximumAdContentRatingToSet ) );
374
- targetingMaximumAdContentRatingToSet = null;
375
- }
376
-
377
- if ( targetingEmailToSet != null )
378
- {
379
- sdk.getTargetingData().setEmail( targetingEmailToSet );
380
- targetingEmailToSet = null;
381
- }
382
-
383
- if ( targetingPhoneNumberToSet != null )
384
- {
385
- sdk.getTargetingData().setPhoneNumber( targetingPhoneNumberToSet );
386
- targetingPhoneNumberToSet = null;
387
- }
388
-
389
- if ( targetingKeywordsToSet != null )
390
- {
391
- sdk.getTargetingData().setKeywords( targetingKeywordsToSet );
392
- targetingKeywordsToSet = null;
393
- }
394
-
395
- if ( targetingInterestsToSet != null )
396
- {
397
- sdk.getTargetingData().setInterests( targetingInterestsToSet );
398
- targetingInterestsToSet = null;
399
- }
400
-
401
- sdk.initializeSdk( configuration -> {
402
-
256
+ sdk.initialize( initConfigBuidler.build(), appLovinSdkConfiguration -> {
403
257
  d( "SDK initialized" );
404
258
 
405
- sdkConfiguration = configuration;
259
+ sdkConfiguration = appLovinSdkConfiguration;
406
260
  isSdkInitialized = true;
407
261
 
408
262
  windowManager = (WindowManager) getReactApplicationContext().getSystemService( Context.WINDOW_SERVICE );
@@ -458,7 +312,7 @@ public class AppLovinMAXModule
458
312
  @ReactMethod
459
313
  public void showMediationDebugger()
460
314
  {
461
- if ( sdk == null )
315
+ if ( !isSdkInitialized )
462
316
  {
463
317
  logUninitializedAccessError( "showMediationDebugger" );
464
318
  return;
@@ -506,63 +360,31 @@ public class AppLovinMAXModule
506
360
  @ReactMethod
507
361
  public void setUserId(final String userId)
508
362
  {
509
- if ( isPluginInitialized )
510
- {
511
- sdk.setUserIdentifier( userId );
512
- userIdToSet = null;
513
- }
514
- else
515
- {
516
- userIdToSet = userId;
517
- }
363
+ sdk.getSettings().setUserIdentifier( userId );
518
364
  }
519
365
 
520
366
  @ReactMethod
521
367
  public void setMuted(final boolean muted)
522
368
  {
523
- if ( isPluginInitialized )
524
- {
525
- sdk.getSettings().setMuted( muted );
526
- mutedToSet = null;
527
- }
528
- else
529
- {
530
- mutedToSet = muted;
531
- }
369
+ sdk.getSettings().setMuted( muted );
532
370
  }
533
371
 
534
372
  @ReactMethod
535
373
  public void isMuted(final Promise promise)
536
374
  {
537
- promise.resolve( isPluginInitialized && sdk.getSettings().isMuted() );
375
+ promise.resolve( sdk.getSettings().isMuted() );
538
376
  }
539
377
 
540
378
  @ReactMethod
541
379
  public void setVerboseLogging(final boolean enabled)
542
380
  {
543
- if ( isPluginInitialized )
544
- {
545
- sdk.getSettings().setVerboseLogging( enabled );
546
- verboseLoggingToSet = null;
547
- }
548
- else
549
- {
550
- verboseLoggingToSet = enabled;
551
- }
381
+ sdk.getSettings().setVerboseLogging( enabled );
552
382
  }
553
383
 
554
384
  @ReactMethod
555
385
  public void setCreativeDebuggerEnabled(final boolean enabled)
556
386
  {
557
- if ( isPluginInitialized )
558
- {
559
- sdk.getSettings().setCreativeDebuggerEnabled( enabled );
560
- creativeDebuggerEnabledToSet = null;
561
- }
562
- else
563
- {
564
- creativeDebuggerEnabledToSet = enabled;
565
- }
387
+ sdk.getSettings().setCreativeDebuggerEnabled( enabled );
566
388
  }
567
389
 
568
390
  @ReactMethod
@@ -576,15 +398,7 @@ public class AppLovinMAXModule
576
398
  advertisingIds.add( (String) rawAdvertisingId );
577
399
  }
578
400
 
579
- if ( isPluginInitialized )
580
- {
581
- sdk.getSettings().setTestDeviceAdvertisingIds( advertisingIds );
582
- testDeviceAdvertisingIdsToSet = null;
583
- }
584
- else
585
- {
586
- testDeviceAdvertisingIdsToSet = advertisingIds;
587
- }
401
+ testDeviceAdvertisingIdsToSet = advertisingIds;
588
402
  }
589
403
 
590
404
  @ReactMethod
@@ -596,16 +410,7 @@ public class AppLovinMAXModule
596
410
  return;
597
411
  }
598
412
 
599
- if ( sdk != null )
600
- {
601
- AppLovinSdkSettings settings = sdk.getSettings();
602
- settings.setExtraParameter( key, value );
603
- setPendingExtraParametersIfNeeded( settings );
604
- }
605
- else
606
- {
607
- extraParametersToSet.put( key, value );
608
- }
413
+ sdk.getSettings().setExtraParameter( key, value );
609
414
  }
610
415
 
611
416
  @ReactMethod
@@ -628,25 +433,25 @@ public class AppLovinMAXModule
628
433
  @ReactMethod
629
434
  public void setTermsAndPrivacyPolicyFlowEnabled(final boolean enabled)
630
435
  {
631
- termsAndPrivacyPolicyFlowEnabledToSet = enabled;
436
+ sdk.getSettings().getTermsAndPrivacyPolicyFlowSettings().setEnabled( enabled );
632
437
  }
633
438
 
634
439
  @ReactMethod
635
440
  public void setPrivacyPolicyUrl(final String urlString)
636
441
  {
637
- privacyPolicyURLToSet = Uri.parse( urlString );
442
+ sdk.getSettings().getTermsAndPrivacyPolicyFlowSettings().setPrivacyPolicyUri( Uri.parse( urlString ) );
638
443
  }
639
444
 
640
445
  @ReactMethod
641
446
  public void setTermsOfServiceUrl(final String urlString)
642
447
  {
643
- termsOfServiceURLToSet = Uri.parse( urlString );
448
+ sdk.getSettings().getTermsAndPrivacyPolicyFlowSettings().setTermsOfServiceUri( Uri.parse( urlString ) );
644
449
  }
645
450
 
646
451
  @ReactMethod
647
452
  public void setConsentFlowDebugUserGeography(final String userGeography)
648
453
  {
649
- debugUserGeographyToSet = userGeography;
454
+ sdk.getSettings().getTermsAndPrivacyPolicyFlowSettings().setDebugUserGeography( getAppLovinConsentFlowUserGeography( userGeography ) );
650
455
  }
651
456
 
652
457
  @ReactMethod
@@ -694,253 +499,68 @@ public class AppLovinMAXModule
694
499
  promise.resolve( sdk.getCmpService().hasSupportedCmp() );
695
500
  }
696
501
 
697
- // Data Passing
698
-
699
- @ReactMethod
700
- public void setTargetingDataYearOfBirth(final int yearOfBirth)
701
- {
702
- if ( sdk == null )
703
- {
704
- targetingYearOfBirthToSet = yearOfBirth;
705
- return;
706
- }
707
-
708
- sdk.getTargetingData().setYearOfBirth( yearOfBirth <= 0 ? null : yearOfBirth );
709
- }
710
-
711
- @ReactMethod
712
- public void getTargetingDataYearOfBirth(final Promise promise)
713
- {
714
- if ( sdk == null )
715
- {
716
- promise.resolve( targetingYearOfBirthToSet == null ? 0 : targetingYearOfBirthToSet );
717
- return;
718
- }
719
-
720
- Integer yearOfBirth = sdk.getTargetingData().getYearOfBirth();
721
- promise.resolve( yearOfBirth != null ? yearOfBirth : 0 );
722
- }
723
-
724
- @ReactMethod
725
- public void setTargetingDataGender(@Nullable final String gender)
726
- {
727
- if ( sdk == null )
728
- {
729
- targetingGenderToSet = gender;
730
- return;
731
- }
732
-
733
- sdk.getTargetingData().setGender( getAppLovinGender( gender ) );
734
- }
735
-
736
- @ReactMethod
737
- public void getTargetingDataGender(final Promise promise)
738
- {
739
- if ( sdk == null )
740
- {
741
- promise.resolve( targetingGenderToSet == null ? "U" : targetingGenderToSet );
742
- return;
743
- }
744
-
745
- if ( sdk.getTargetingData().getGender() == null )
746
- {
747
- promise.resolve( "U" );
748
- }
749
- else
750
- {
751
- promise.resolve( getRawAppLovinGender( sdk.getTargetingData().getGender() ) );
752
- }
753
- }
754
-
755
- @ReactMethod
756
- public void setTargetingDataMaximumAdContentRating(final int maximumAdContentRating)
757
- {
758
- if ( sdk == null )
759
- {
760
- targetingMaximumAdContentRatingToSet = maximumAdContentRating;
761
- return;
762
- }
763
-
764
- sdk.getTargetingData().setMaximumAdContentRating( getAppLovinAdContentRating( maximumAdContentRating ) );
765
- }
766
-
767
- @ReactMethod
768
- public void getTargetingDataMaximumAdContentRating(final Promise promise)
769
- {
770
- if ( sdk == null )
771
- {
772
- promise.resolve( targetingMaximumAdContentRatingToSet == null ? 0 : targetingMaximumAdContentRatingToSet );
773
- return;
774
- }
775
-
776
- if ( sdk.getTargetingData().getMaximumAdContentRating() == null )
777
- {
778
- promise.resolve( 0 );
779
- }
780
- else
781
- {
782
- promise.resolve( sdk.getTargetingData().getMaximumAdContentRating().ordinal() );
783
- }
784
- }
785
-
786
- @ReactMethod
787
- public void setTargetingDataEmail(@Nullable final String email)
788
- {
789
- if ( sdk == null )
790
- {
791
- targetingEmailToSet = email;
792
- return;
793
- }
794
-
795
- sdk.getTargetingData().setEmail( email );
796
- }
797
-
798
- @ReactMethod
799
- public void getTargetingDataEmail(final Promise promise)
800
- {
801
- if ( sdk == null )
802
- {
803
- promise.resolve( targetingEmailToSet );
804
- return;
805
- }
806
-
807
- promise.resolve( sdk.getTargetingData().getEmail() );
808
- }
809
-
810
- @ReactMethod
811
- public void setTargetingDataPhoneNumber(@Nullable final String phoneNumber)
812
- {
813
- if ( sdk == null )
814
- {
815
- targetingPhoneNumberToSet = phoneNumber;
816
- return;
817
- }
818
-
819
- sdk.getTargetingData().setPhoneNumber( phoneNumber );
820
- }
821
-
822
- @ReactMethod
823
- public void getTargetingDataPhoneNumber(final Promise promise)
824
- {
825
- if ( sdk == null )
826
- {
827
- promise.resolve( targetingPhoneNumberToSet );
828
- return;
829
- }
830
-
831
- promise.resolve( sdk.getTargetingData().getPhoneNumber() );
832
- }
502
+ // Segment Targeting
833
503
 
834
504
  @ReactMethod
835
- public void setTargetingDataKeywords(@Nullable final ReadableArray rawKeywords)
505
+ public void addSegment(final int key, final ReadableArray values, final Promise promise)
836
506
  {
837
- if ( sdk == null )
507
+ if ( isPluginInitialized )
838
508
  {
839
- targetingKeywordsToSet = Arguments.toList( rawKeywords );
509
+ promise.reject( new IllegalStateException( "A segment must be added before calling 'AppLovinMAX.initialize(...);'" ) );
840
510
  return;
841
511
  }
842
512
 
843
- sdk.getTargetingData().setKeywords( Arguments.toList( rawKeywords ) );
844
- }
513
+ List<Integer> integerArray = new ArrayList<>( values.size() );
845
514
 
846
- @ReactMethod
847
- public void getTargetingDataKeywords(final Promise promise)
848
- {
849
- if ( sdk == null )
515
+ for ( Object object : values.toArrayList() )
850
516
  {
851
- if ( targetingKeywordsToSet == null || targetingKeywordsToSet.isEmpty() )
517
+ if ( object instanceof Number )
852
518
  {
853
- promise.resolve( null );
519
+ integerArray.add( ( (Number) object ).intValue() );
854
520
  }
855
521
  else
856
522
  {
857
- promise.resolve( Arguments.fromList( targetingKeywordsToSet ) );
523
+ break;
858
524
  }
859
- return;
860
525
  }
861
526
 
862
- List<String> keywords = sdk.getTargetingData().getKeywords();
863
-
864
- if ( keywords == null || keywords.isEmpty() )
527
+ if ( values.size() != integerArray.size() )
865
528
  {
866
- promise.resolve( null );
867
- }
868
- else
869
- {
870
- promise.resolve( Arguments.makeNativeArray( keywords ) );
871
- }
872
- }
873
-
874
- @ReactMethod
875
- public void setTargetingDataInterests(@Nullable final ReadableArray rawInterests)
876
- {
877
- if ( sdk == null )
878
- {
879
- targetingKeywordsToSet = Arguments.toList( rawInterests );
529
+ promise.reject( new IllegalStateException( "Value for key " + key + " is not an array of integers." ) );
880
530
  return;
881
531
  }
882
532
 
883
- sdk.getTargetingData().setInterests( Arguments.toList( rawInterests ) );
533
+ segmentCollectionBuilder.addSegment( new MaxSegment( key, integerArray ) );
534
+
535
+ promise.resolve( null );
884
536
  }
885
537
 
886
538
  @ReactMethod
887
- public void getTargetingDataInterests(final Promise promise)
539
+ public void getSegments(final Promise promise)
888
540
  {
889
- if ( sdk == null )
541
+ if ( !isSdkInitialized )
890
542
  {
891
- if ( targetingInterestsToSet == null || targetingInterestsToSet.isEmpty() )
892
- {
893
- promise.resolve( null );
894
- }
895
- else
896
- {
897
- promise.resolve( Arguments.fromList( targetingInterestsToSet ) );
898
- }
543
+ promise.reject( new IllegalStateException( "Segments cannot be retrieved before calling 'AppLovinMAX.initialize(...).'" ) );
899
544
  return;
900
545
  }
901
546
 
902
- List<String> interests = sdk.getTargetingData().getInterests();
547
+ List<MaxSegment> segments = sdk.getSegmentCollection().getSegments();
903
548
 
904
- if ( interests == null || interests.isEmpty() )
549
+ if ( segments.isEmpty() )
905
550
  {
906
551
  promise.resolve( null );
907
- }
908
- else
909
- {
910
- promise.resolve( Arguments.makeNativeArray( interests ) );
911
- }
912
- }
913
-
914
- @ReactMethod
915
- public void clearAllTargetingData()
916
- {
917
- if ( sdk == null )
918
- {
919
- targetingYearOfBirthToSet = null;
920
- targetingGenderToSet = null;
921
- targetingMaximumAdContentRatingToSet = null;
922
- targetingEmailToSet = null;
923
- targetingPhoneNumberToSet = null;
924
- targetingKeywordsToSet = null;
925
- targetingInterestsToSet = null;
926
552
  return;
927
553
  }
928
554
 
929
- sdk.getTargetingData().clearAll();
930
- }
555
+ Bundle bundle = new Bundle();
931
556
 
932
- @ReactMethod
933
- public void setLocationCollectionEnabled(final boolean enabled)
934
- {
935
- if ( isPluginInitialized )
557
+ for ( MaxSegment segment : segments )
936
558
  {
937
- sdk.getSettings().setLocationCollectionEnabled( enabled );
938
- locationCollectionEnabledToSet = null;
939
- }
940
- else
941
- {
942
- locationCollectionEnabledToSet = enabled;
559
+ // JavaScript can't have integer as a key.
560
+ bundle.putIntegerArrayList( String.valueOf( segment.getKey() ), (ArrayList<Integer>) segment.getValues() );
943
561
  }
562
+
563
+ promise.resolve( Arguments.fromBundle( bundle ) );
944
564
  }
945
565
 
946
566
  // EVENT TRACKING
@@ -2374,18 +1994,6 @@ public class AppLovinMAXModule
2374
1994
  relativeLayout.setPadding( adViewOffset.x, adViewOffset.y, adViewOffset.x, adViewOffset.y );
2375
1995
  }
2376
1996
 
2377
- private void setPendingExtraParametersIfNeeded(final AppLovinSdkSettings settings)
2378
- {
2379
- if ( extraParametersToSet.isEmpty() ) return;
2380
-
2381
- for ( final String key : extraParametersToSet.keySet() )
2382
- {
2383
- settings.setExtraParameter( key, extraParametersToSet.get( key ) );
2384
- }
2385
-
2386
- extraParametersToSet.clear();
2387
- }
2388
-
2389
1997
  // Utility Methods
2390
1998
 
2391
1999
  private void logInvalidAdFormat(MaxAdFormat adFormat)
@@ -2449,63 +2057,6 @@ public class AppLovinMAXModule
2449
2057
  return new Point( AppLovinSdkUtils.dpToPx( context, (int) xDp ), AppLovinSdkUtils.dpToPx( context, (int) yDp ) );
2450
2058
  }
2451
2059
 
2452
- private static Gender getAppLovinGender(@Nullable final String gender)
2453
- {
2454
- if ( gender != null )
2455
- {
2456
- if ( "F".equalsIgnoreCase( gender ) )
2457
- {
2458
- return Gender.FEMALE;
2459
- }
2460
- else if ( "M".equalsIgnoreCase( gender ) )
2461
- {
2462
- return Gender.MALE;
2463
- }
2464
- else if ( "O".equalsIgnoreCase( gender ) )
2465
- {
2466
- return Gender.OTHER;
2467
- }
2468
- }
2469
-
2470
- return Gender.UNKNOWN;
2471
- }
2472
-
2473
- private static String getRawAppLovinGender(final Gender gender)
2474
- {
2475
- if ( gender == Gender.FEMALE )
2476
- {
2477
- return "F";
2478
- }
2479
- else if ( gender == Gender.MALE )
2480
- {
2481
- return "M";
2482
- }
2483
- else if ( gender == Gender.OTHER )
2484
- {
2485
- return "O";
2486
- }
2487
-
2488
- return "U";
2489
- }
2490
-
2491
- private static AdContentRating getAppLovinAdContentRating(final int maximumAdContentRating)
2492
- {
2493
- if ( maximumAdContentRating == 1 )
2494
- {
2495
- return AdContentRating.ALL_AUDIENCES;
2496
- }
2497
- else if ( maximumAdContentRating == 2 )
2498
- {
2499
- return AdContentRating.EVERYONE_OVER_TWELVE;
2500
- }
2501
- else if ( maximumAdContentRating == 3 )
2502
- {
2503
- return AdContentRating.MATURE_AUDIENCES;
2504
- }
2505
-
2506
- return AdContentRating.NONE;
2507
- }
2508
-
2509
2060
  private static ConsentFlowUserGeography getAppLovinConsentFlowUserGeography(final String userGeography)
2510
2061
  {
2511
2062
  if ( USER_GEOGRAPHY_GDPR.equalsIgnoreCase( userGeography ) )