react-native-applovin-max 6.2.1 → 6.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.
@@ -35,8 +35,8 @@ android {
35
35
  defaultConfig {
36
36
  minSdkVersion 16
37
37
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
38
- versionCode 6020100
39
- versionName "6.2.1"
38
+ versionCode 6020200
39
+ versionName "6.2.2"
40
40
  }
41
41
 
42
42
  flavorDimensions("default")
@@ -37,6 +37,8 @@ import com.applovin.mediation.ads.MaxAppOpenAd;
37
37
  import com.applovin.mediation.ads.MaxInterstitialAd;
38
38
  import com.applovin.mediation.ads.MaxRewardedAd;
39
39
  import com.applovin.sdk.AppLovinAdContentRating;
40
+ import com.applovin.sdk.AppLovinCmpError;
41
+ import com.applovin.sdk.AppLovinCmpService;
40
42
  import com.applovin.sdk.AppLovinGender;
41
43
  import com.applovin.sdk.AppLovinMediationProvider;
42
44
  import com.applovin.sdk.AppLovinPrivacySettings;
@@ -668,6 +670,48 @@ public class AppLovinMAXModule
668
670
  debugUserGeographyToSet = userGeography;
669
671
  }
670
672
 
673
+ @ReactMethod
674
+ public void showCmpForExistingUser(final Promise promise)
675
+ {
676
+ if ( sdk == null )
677
+ {
678
+ logUninitializedAccessError( "showCmpForExistingUser", promise );
679
+ return;
680
+ }
681
+
682
+ Activity currentActivity = maybeGetCurrentActivity();
683
+ if ( currentActivity == null )
684
+ {
685
+ promise.reject( new IllegalStateException( "ERROR: Failed to execute showCmpForExistingUser() - unable to get current Activity." ) );
686
+ return;
687
+ }
688
+
689
+ AppLovinCmpService cmpService = sdk.getCmpService();
690
+ cmpService.showCmpForExistingUser( currentActivity, (@Nullable final AppLovinCmpError error) -> {
691
+
692
+ if ( error == null )
693
+ {
694
+ promise.resolve( null );
695
+ return;
696
+ }
697
+
698
+ promise.resolve( error.getCmpCode() );
699
+ } );
700
+ }
701
+
702
+ @ReactMethod
703
+ public void hasSupportedCmp(final Promise promise)
704
+ {
705
+ if ( sdk == null )
706
+ {
707
+ logUninitializedAccessError( "showCmpForExistingUser", promise );
708
+ return;
709
+ }
710
+
711
+ AppLovinCmpService cmpService = sdk.getCmpService();
712
+ promise.resolve( cmpService.hasSupportedCmp() );
713
+ }
714
+
671
715
  // Data Passing
672
716
 
673
717
  @ReactMethod
@@ -2389,7 +2433,20 @@ public class AppLovinMAXModule
2389
2433
 
2390
2434
  public static void logUninitializedAccessError(final String callingMethod)
2391
2435
  {
2392
- e( "ERROR: Failed to execute " + callingMethod + "() - please ensure the AppLovin MAX React Native module has been initialized by calling 'AppLovinMAX.initialize(...);'!" );
2436
+ logUninitializedAccessError( callingMethod, null );
2437
+ }
2438
+
2439
+ public static void logUninitializedAccessError(final String callingMethod, @Nullable final Promise promise)
2440
+ {
2441
+ String message = "ERROR: Failed to execute " + callingMethod + "() - please ensure the AppLovin MAX React Native module has been initialized by calling 'AppLovinMAX.initialize(...);'!";
2442
+
2443
+ if ( promise == null )
2444
+ {
2445
+ e( message );
2446
+ return;
2447
+ }
2448
+
2449
+ promise.reject( new IllegalStateException( message ) );
2393
2450
  }
2394
2451
 
2395
2452
  public static void d(final String message)
@@ -2711,12 +2768,23 @@ public class AppLovinMAXModule
2711
2768
  MaxInterstitialAd interstitial = retrieveInterstitial( adUnitId, "setAmazonResult" );
2712
2769
  if ( interstitial == null )
2713
2770
  {
2714
- e( "Failed to set Amazon result - unable to retrieve interstitial" );
2771
+ e( "Failed to set Amazon result - unable to find interstitial" );
2715
2772
  return;
2716
2773
  }
2717
2774
 
2718
2775
  interstitial.setLocalExtraParameter( key, result );
2719
2776
  }
2777
+ else if ( adFormat == MaxAdFormat.REWARDED )
2778
+ {
2779
+ MaxRewardedAd rewardedAd = retrieveRewardedAd( adUnitId, "setAmazonResult" );
2780
+ if ( rewardedAd == null )
2781
+ {
2782
+ e( "Failed to set Amazon result - unable to find rewarded ad" );
2783
+ return;
2784
+ }
2785
+
2786
+ rewardedAd.setLocalExtraParameter( key, result );
2787
+ }
2720
2788
  else // MaxAdFormat.BANNER or MaxAdFormat.MREC
2721
2789
  {
2722
2790
  MaxAdView adView = AppLovinMAXAdView.getInstance( adUnitId );
@@ -2732,7 +2800,7 @@ public class AppLovinMAXModule
2732
2800
  }
2733
2801
  else
2734
2802
  {
2735
- e( "Failed to set Amazon result - unable to retrieve " + adFormat );
2803
+ e( "Failed to set Amazon result - unable to find " + adFormat );
2736
2804
  }
2737
2805
  }
2738
2806
  }
@@ -471,7 +471,7 @@ public class AppLovinMAXNativeAdView
471
471
 
472
472
  private static void sizeToFit(final @Nullable View view, final View parentView)
473
473
  {
474
- if ( view != null )
474
+ if ( view != null && parentView != null )
475
475
  {
476
476
  view.measure( MeasureSpec.makeMeasureSpec( parentView.getWidth(), MeasureSpec.EXACTLY ),
477
477
  MeasureSpec.makeMeasureSpec( parentView.getHeight(), MeasureSpec.EXACTLY ) );
package/ios/AppLovinMAX.m CHANGED
@@ -554,6 +554,39 @@ RCT_EXPORT_METHOD(setConsentFlowDebugUserGeography:(NSString *)userGeography)
554
554
  self.debugUserGeographyToSet = userGeography;
555
555
  }
556
556
 
557
+ RCT_EXPORT_METHOD(showCmpForExistingUser:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
558
+ {
559
+ if ( !self.sdk )
560
+ {
561
+ [self logUninitializedAccessError: @"showCmpForExistingUser" withPromiseReject: reject];
562
+ return;
563
+ }
564
+
565
+ ALCMPService *cmpService = self.sdk.cmpService;
566
+ [cmpService showCMPForExistingUserWithCompletion:^(ALCMPError * _Nullable error) {
567
+
568
+ if ( !error )
569
+ {
570
+ resolve(nil);
571
+ return;
572
+ }
573
+
574
+ resolve(@(error.code));
575
+ }];
576
+ }
577
+
578
+ RCT_EXPORT_METHOD(hasSupportedCmp:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
579
+ {
580
+ if ( !self.sdk )
581
+ {
582
+ [self logUninitializedAccessError: @"hasSupportedCmp" withPromiseReject: reject];
583
+ return;
584
+ }
585
+
586
+ ALCMPService *cmpService = self.sdk.cmpService;
587
+ resolve(@([cmpService hasSupportedCMP]));
588
+ }
589
+
557
590
  #pragma mark - Data Passing
558
591
 
559
592
  RCT_EXPORT_METHOD(setTargetingDataYearOfBirth:(nonnull NSNumber *)yearOfBirth)
@@ -1995,7 +2028,20 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
1995
2028
 
1996
2029
  - (void)logUninitializedAccessError:(NSString *)callingMethod
1997
2030
  {
1998
- [self log: @"ERROR: Failed to execute %@() - please ensure the AppLovin MAX React Native module has been initialized by calling 'AppLovinMAX.initialize(...);'!", callingMethod];
2031
+ [self logUninitializedAccessError: callingMethod withPromiseReject: nil];
2032
+ }
2033
+
2034
+ - (void)logUninitializedAccessError:(NSString *)callingMethod withPromiseReject:(nullable RCTPromiseRejectBlock)reject
2035
+ {
2036
+ NSString *message = [NSString stringWithFormat:@"ERROR: Failed to execute %@() - please ensure the AppLovin MAX React Native module has been initialized by calling 'AppLovinMAX.initialize(...);'!", callingMethod];
2037
+
2038
+ if ( !reject )
2039
+ {
2040
+ NSLog(@"[%@] [%@] %@", SDK_TAG, TAG, message);
2041
+ return;
2042
+ }
2043
+
2044
+ reject(TAG, message, nil);
1999
2045
  }
2000
2046
 
2001
2047
  - (void)log:(NSString *)format, ...
@@ -2275,6 +2321,17 @@ RCT_EXPORT_METHOD(setAppOpenAdLocalExtraParameter:(NSString *)adUnitIdentifier :
2275
2321
 
2276
2322
  [interstitial setLocalExtraParameterForKey: key value: result];
2277
2323
  }
2324
+ else if ( adFormat == MAAdFormat.rewarded )
2325
+ {
2326
+ MARewardedAd *rewardedAd = [self retrieveRewardedAdForAdUnitIdentifier: adUnitIdentifier];
2327
+ if ( !rewardedAd )
2328
+ {
2329
+ [self log: @"Failed to set Amazon result - unable to find rewarded ad"];
2330
+ return;
2331
+ }
2332
+
2333
+ [rewardedAd setLocalExtraParameterForKey: key value: result];
2334
+ }
2278
2335
  else // MAAdFormat.banner or MAAdFormat.mrec
2279
2336
  {
2280
2337
  MAAdView *adView = [AppLovinMAXAdView sharedWithAdUnitIdentifier: adUnitIdentifier];
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.2.1",
4
+ "version": "6.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,7 +11,7 @@ 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_2_1" }
14
+ s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_6_2_2" }
15
15
 
16
16
  s.source_files = "ios/AppLovinMAX*.{h,m}"
17
17
 
@@ -4,7 +4,88 @@ import type { Configuration } from './types/Configuration';
4
4
 
5
5
  const NativeAppLovinMAX = NativeModules.AppLovinMAX;
6
6
 
7
- const VERSION = '6.2.1';
7
+ const VERSION = '6.2.2';
8
+
9
+ /**
10
+ * This enum represents the user's geography used to determine the type of consent flow shown to the
11
+ * user.
12
+ */
13
+ export enum ConsentFlowUserGeography {
14
+ /**
15
+ * User's geography is unknown.
16
+ */
17
+ UNKNOWN = 'U',
18
+
19
+ /**
20
+ * The user is in GDPR region.
21
+ */
22
+ GDPR = 'G',
23
+
24
+ /**
25
+ * The user is in a non-GDPR region.
26
+ */
27
+ OTHER = 'O',
28
+ }
29
+
30
+ /**
31
+ * AppLovin SDK-defined app tracking transparency status values (extended to include "unavailable"
32
+ * state on iOS before iOS14).
33
+ */
34
+ export enum AppTrackingStatus {
35
+ /**
36
+ * Device is on iOS before iOS14, AppTrackingTransparency.framework is not available.
37
+ */
38
+ UNAVAILABLE = 'U',
39
+
40
+ /**
41
+ * The user has not yet received an authorization request to authorize access to app-related
42
+ * data that can be used for tracking the user or the device.
43
+ */
44
+ NOT_DETERMINED = 'N',
45
+
46
+ /**
47
+ * Authorization to access app-related data that can be used for tracking the user or the device
48
+ * is restricted.
49
+ */
50
+ RESTRICTED = 'R',
51
+
52
+ /**
53
+ * The user denies authorization to access app-related data that can be used for tracking the
54
+ * user or the device.
55
+ */
56
+ DENIED = 'D',
57
+
58
+ /**
59
+ * The user authorizes access to app-related data that can be used for tracking the user or the
60
+ * device.
61
+ */
62
+ AUTHORIZED = 'A',
63
+ }
64
+
65
+ /**
66
+ * Represents errors for CMP flow.
67
+ */
68
+ export enum CmpError {
69
+ /**
70
+ * Indicates that an unspecified error has occurred.
71
+ */
72
+ UNSPECIFIED = -1,
73
+
74
+ /**
75
+ * Indicates that the CMP has not been integrated correctly.
76
+ */
77
+ INTEGRATION_ERROR = 1,
78
+
79
+ /**
80
+ * Indicates that the CMP form is unavailable.
81
+ */
82
+ FORM_UNAVAILABLE = 2,
83
+
84
+ /**
85
+ * Indicates that the CMP form is not required.
86
+ */
87
+ FORM_NOT_REQUIRED = 3,
88
+ }
8
89
 
9
90
  const initialize = async (sdkKey: string): Promise<Configuration> => {
10
91
  return NativeAppLovinMAX.initialize(VERSION, sdkKey);
package/src/Privacy.ts CHANGED
@@ -3,60 +3,4 @@ import type { PrivacyType } from './types/Privacy';
3
3
 
4
4
  const { AppLovinMAX } = NativeModules;
5
5
 
6
- /**
7
- * This enum represents the user's geography used to determine the type of consent flow shown to the
8
- * user.
9
- */
10
- export enum ConsentFlowUserGeography {
11
- /**
12
- * User's geography is unknown.
13
- */
14
- UNKNOWN = 'U',
15
-
16
- /**
17
- * The user is in GDPR region.
18
- */
19
- GDPR = 'G',
20
-
21
- /**
22
- * The user is in a non-GDPR region.
23
- */
24
- OTHER = 'O',
25
- }
26
-
27
- /**
28
- * AppLovin SDK-defined app tracking transparency status values (extended to include "unavailable"
29
- * state on iOS before iOS14).
30
- */
31
- export enum AppTrackingStatus {
32
- /**
33
- * Device is on iOS before iOS14, AppTrackingTransparency.framework is not available.
34
- */
35
- UNAVAILABLE = 'U',
36
-
37
- /**
38
- * The user has not yet received an authorization request to authorize access to app-related
39
- * data that can be used for tracking the user or the device.
40
- */
41
- NOT_DETERMINED = 'N',
42
-
43
- /**
44
- * Authorization to access app-related data that can be used for tracking the user or the device
45
- * is restricted.
46
- */
47
- RESTRICTED = 'R',
48
-
49
- /**
50
- * The user denies authorization to access app-related data that can be used for tracking the
51
- * user or the device.
52
- */
53
- DENIED = 'D',
54
-
55
- /**
56
- * The user authorizes access to app-related data that can be used for tracking the user or the
57
- * device.
58
- */
59
- AUTHORIZED = 'A',
60
- }
61
-
62
6
  export const Privacy: PrivacyType = AppLovinMAX;
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { default, AppLovinMAX } from './AppLovinMAX';
2
- export { Privacy, ConsentFlowUserGeography, AppTrackingStatus } from './Privacy';
1
+ export { default, AppLovinMAX, ConsentFlowUserGeography, AppTrackingStatus, CmpError } from './AppLovinMAX';
2
+ export { Privacy } from './Privacy';
3
3
  export { TargetingData, AdContentRating, UserGender } from './TargetingData';
4
4
  export { InterstitialAd } from './InterstitialAd';
5
5
  export { RewardedAd } from './RewardedAd';
@@ -1,4 +1,5 @@
1
1
  import type { Configuration } from './Configuration';
2
+ import type { ConsentFlowUserGeography, CmpError } from '../AppLovinMAX';
2
3
 
3
4
  /**
4
5
  * Represents the AppLovinMAX module.
@@ -90,4 +91,61 @@ export type AppLovinMAXType = {
90
91
  * @param enabled Defaults to true.
91
92
  */
92
93
  setLocationCollectionEnabled(enabled: boolean): void;
94
+
95
+ /**
96
+ * @deprecated Use {@link setTermsAndPrivacyPolicyFlowEnabled()} instead.
97
+ *
98
+ * Enables the MAX Terms Flow.
99
+ *
100
+ * @param enabled true to enable the MAX Terms Flow.
101
+ */
102
+ setConsentFlowEnabled(enabled: boolean): void;
103
+
104
+ /**
105
+ * Enables the MAX Terms and Privacy Policy Flow.
106
+ *
107
+ * @param enabled true to enable the MAX Terms and Privacy Policy Flow.
108
+ */
109
+ setTermsAndPrivacyPolicyFlowEnabled(enabled: boolean): void;
110
+
111
+ /**
112
+ * The URL of your company’s privacy policy, as a string. This is required in order to enable
113
+ * the Terms Flow.
114
+ *
115
+ * @param urlString The URL string to point your company’s privacy policy.
116
+ */
117
+ setPrivacyPolicyUrl(urlString: string): void;
118
+
119
+ /**
120
+ * The URL of your company’s terms of service, as a string. This is optional; you can enable
121
+ * the Terms Flow with or without it.
122
+ *
123
+ * @param urlString The URL string to point your company’s terms of service.
124
+ */
125
+ setTermsOfServiceUrl(urlString: string): void;
126
+
127
+ /**
128
+ * Set debug user geography. You may use this to test CMP flow by setting this to {@link ConsentFlowUserGeography.GDPR}.
129
+ *
130
+ * @note The debug geography is used only when the app is in debug mode.
131
+ */
132
+ setConsentFlowDebugUserGeography(userGeography: ConsentFlowUserGeography): void;
133
+
134
+ /**
135
+ * Shows the CMP flow to an existing user.
136
+ * Note that this resets the user’s existing consent information.
137
+ *
138
+ * The function returns when the flow finishes showing. On success, returns null. On failure,
139
+ * returns one of the {@link CmpError} codes.
140
+ *
141
+ * @return {Promise<CmpError|null>}
142
+ */
143
+ showCmpForExistingUser(): Promise<CmpError | null>;
144
+
145
+ /**
146
+ * Returns true if a supported CMP SDK is detected.
147
+ *
148
+ * @return {boolean}
149
+ */
150
+ hasSupportedCmp(): Promise<boolean>;
93
151
  };
@@ -1,4 +1,4 @@
1
- import type { ConsentFlowUserGeography, AppTrackingStatus } from '../Privacy';
1
+ import type { ConsentFlowUserGeography, AppTrackingStatus } from '../AppLovinMAX';
2
2
 
3
3
  /**
4
4
  * Encapsulates data for the AppLovinMAX SDK configuration.
@@ -1,5 +1,3 @@
1
- import type { ConsentFlowUserGeography } from '../Privacy';
2
-
3
1
  export type PrivacyType = {
4
2
  /**********************************************************************************/
5
3
  /* Privacy */
@@ -40,47 +38,4 @@ export type PrivacyType = {
40
38
  * Checks if the user opted out of the sale of their personal information.
41
39
  */
42
40
  isDoNotSell(): Promise<boolean>;
43
-
44
- /**********************************************************************************/
45
- /* TERM FLow */
46
- /**********************************************************************************/
47
-
48
- /**
49
- * @deprecated Use {@link setTermsAndPrivacyPolicyFlowEnabled()} instead.
50
- *
51
- * Enables the MAX Terms Flow.
52
- *
53
- * @param enabled true to enable the MAX Terms Flow.
54
- */
55
- setConsentFlowEnabled(enabled: boolean): void;
56
-
57
- /**
58
- * Enables the MAX Terms and Privacy Policy Flow.
59
- *
60
- * @param enabled true to enable the MAX Terms and Privacy Policy Flow.
61
- */
62
- setTermsAndPrivacyPolicyFlowEnabled(enabled: boolean): void;
63
-
64
- /**
65
- * The URL of your company’s privacy policy, as a string. This is required in order to enable
66
- * the Terms Flow.
67
- *
68
- * @param urlString The URL string to point your company’s privacy policy.
69
- */
70
- setPrivacyPolicyUrl(urlString: string): void;
71
-
72
- /**
73
- * The URL of your company’s terms of service, as a string. This is optional; you can enable
74
- * the Terms Flow with or without it.
75
- *
76
- * @param urlString The URL string to point your company’s terms of service.
77
- */
78
- setTermsOfServiceUrl(urlString: string): void;
79
-
80
- /**
81
- * Set debug user geography. You may use this to test CMP flow by setting this to {@link ConsentFlowUserGeography.GDPR}.
82
- *
83
- * @note The debug geography is used only when the app is in debug mode.
84
- */
85
- setConsentFlowDebugUserGeography(userGeography: ConsentFlowUserGeography): void;
86
41
  };