react-native-applovin-max 8.0.1 → 8.0.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.
@@ -53,8 +53,8 @@ android {
53
53
  minSdkVersion getExtOrIntegerDefault("minSdkVersion")
54
54
  targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
55
55
 
56
- buildConfigField("int", "VERSION_CODE", "8000100")
57
- buildConfigField("String", "VERSION_NAME", "\"8.0.1\"")
56
+ buildConfigField("int", "VERSION_CODE", "8000200")
57
+ buildConfigField("String", "VERSION_NAME", "\"8.0.2\"")
58
58
  }
59
59
 
60
60
  buildTypes {
@@ -76,8 +76,9 @@ public class AppLovinMAXModule
76
76
  implements LifecycleEventListener,
77
77
  MaxAdListener, MaxAdViewAdListener, MaxRewardedAdListener, MaxAdRevenueListener
78
78
  {
79
- private static final String SDK_TAG = "AppLovinSdk";
80
- private static final String TAG = "AppLovinMAXModule";
79
+ private static final String SDK_TAG = "AppLovinSdk";
80
+ private static final String TAG = "AppLovinMAXModule";
81
+ private static final String PLUGIN_VERSION = "8.0.1";
81
82
 
82
83
  private static final String USER_GEOGRAPHY_GDPR = "G";
83
84
  private static final String USER_GEOGRAPHY_OTHER = "O";
@@ -95,6 +96,15 @@ public class AppLovinMAXModule
95
96
 
96
97
  private static final Point DEFAULT_AD_VIEW_OFFSET = new Point( 0, 0 );
97
98
 
99
+ private static final Map<String, String> ALCompatibleNativeSdkVersions = new HashMap<>();
100
+
101
+ static
102
+ {
103
+ ALCompatibleNativeSdkVersions.put( "8.0.2", "13.0.0" );
104
+ ALCompatibleNativeSdkVersions.put( "8.0.1", "13.0.0" );
105
+ ALCompatibleNativeSdkVersions.put( "8.0.0", "13.0.0" );
106
+ }
107
+
98
108
  public static AppLovinMAXModule instance;
99
109
  @Nullable
100
110
  private static Activity currentActivity;
@@ -141,6 +151,14 @@ public class AppLovinMAXModule
141
151
  {
142
152
  super( reactContext );
143
153
 
154
+ // Check that plugin version is compatible with native SDK version
155
+ String minCompatibleNativeSdkVersion = ALCompatibleNativeSdkVersions.get( PLUGIN_VERSION );
156
+ boolean isCompatible = isInclusiveVersion( AppLovinSdk.VERSION, minCompatibleNativeSdkVersion, null );
157
+ if ( !isCompatible )
158
+ {
159
+ throw new RuntimeException( "Incompatible native SDK version " + AppLovinSdk.VERSION + " found for plugin " + PLUGIN_VERSION );
160
+ }
161
+
144
162
  instance = this;
145
163
  currentActivity = reactContext.getCurrentActivity();
146
164
 
@@ -2384,4 +2402,55 @@ public class AppLovinMAXModule
2384
2402
 
2385
2403
  return constants;
2386
2404
  }
2405
+
2406
+ //
2407
+ // Version Utils
2408
+ //
2409
+
2410
+ private boolean isInclusiveVersion(final String version, @Nullable final String minVersion, @Nullable final String maxVersion)
2411
+ {
2412
+ if ( TextUtils.isEmpty( version ) ) return true;
2413
+
2414
+ int versionCode = toVersionCode( version );
2415
+
2416
+ // if version is less than the minimum version
2417
+ if ( !TextUtils.isEmpty( minVersion ) )
2418
+ {
2419
+ int minVersionCode = toVersionCode( minVersion );
2420
+
2421
+ if ( versionCode < minVersionCode ) return false;
2422
+ }
2423
+
2424
+ // if version is greater than the maximum version
2425
+ if ( !TextUtils.isEmpty( maxVersion ) )
2426
+ {
2427
+ int maxVersionCode = toVersionCode( maxVersion );
2428
+
2429
+ if ( versionCode > maxVersionCode ) return false;
2430
+ }
2431
+
2432
+ return true;
2433
+ }
2434
+
2435
+ private static int toVersionCode(String versionString)
2436
+ {
2437
+ String[] versionNums = versionString.split( "\\." );
2438
+
2439
+ int versionCode = 0;
2440
+ for ( String num : versionNums )
2441
+ {
2442
+ // Each number gets two digits in the version code.
2443
+ if ( num.length() > 2 )
2444
+ {
2445
+ w( "Version number components cannot be longer than two digits -> " + versionString );
2446
+ return versionCode;
2447
+ }
2448
+
2449
+ versionCode *= 100;
2450
+ versionCode += Integer.parseInt( num );
2451
+ }
2452
+
2453
+ return versionCode;
2454
+ }
2455
+
2387
2456
  }
package/ios/AppLovinMAX.m CHANGED
@@ -29,6 +29,12 @@
29
29
  @property (nonatomic, assign, readonly, getter=al_isValidString) BOOL al_validString;
30
30
  @end
31
31
 
32
+ @interface ALUtils (ALUtils)
33
+ + (BOOL)isInclusiveVersion:(NSString *)version
34
+ forMinVersion:(nullable NSString *)minVersion
35
+ maxVersion:(nullable NSString *)maxVersion;
36
+ @end
37
+
32
38
  @interface AppLovinMAX()
33
39
 
34
40
  // Parent Fields
@@ -67,6 +73,7 @@
67
73
  @implementation AppLovinMAX
68
74
  static NSString *const SDK_TAG = @"AppLovinSdk";
69
75
  static NSString *const TAG = @"AppLovinMAX";
76
+ static NSString *const PLUGIN_VERSION = @"8.0.1";
70
77
 
71
78
  static NSString *const USER_GEOGRAPHY_GDPR = @"G";
72
79
  static NSString *const USER_GEOGRAPHY_OTHER = @"O";
@@ -132,9 +139,22 @@ static NSString *const BOTTOM_RIGHT = @"bottom_right";
132
139
 
133
140
  static AppLovinMAX *AppLovinMAXShared; // Shared instance of this bridge module.
134
141
 
142
+ static NSDictionary<NSString *, NSString *> *ALCompatibleNativeSDKVersions;
143
+
135
144
  // To export a module named AppLovinMAX ("RCT" automatically removed)
136
145
  RCT_EXPORT_MODULE()
137
146
 
147
+ + (void)initialize
148
+ {
149
+ [super initialize];
150
+
151
+ ALCompatibleNativeSDKVersions = @{
152
+ @"8.0.2" : @"13.0.0",
153
+ @"8.0.1" : @"13.0.0",
154
+ @"8.0.0" : @"13.0.0"
155
+ };
156
+ }
157
+
138
158
  // `init` requires main queue b/c of UI code
139
159
  + (BOOL)requiresMainQueueSetup
140
160
  {
@@ -173,13 +193,24 @@ RCT_EXPORT_MODULE()
173
193
  self.adViewConstraints = [NSMutableDictionary dictionaryWithCapacity: 2];
174
194
  self.adUnitIdentifiersToShowAfterCreate = [NSMutableArray arrayWithCapacity: 2];
175
195
  self.disabledAdaptiveBannerAdUnitIdentifiers = [NSMutableSet setWithCapacity: 2];
176
-
196
+
177
197
  self.safeAreaBackground = [[UIView alloc] init];
178
198
  self.safeAreaBackground.hidden = YES;
179
199
  self.safeAreaBackground.backgroundColor = UIColor.clearColor;
180
200
  self.safeAreaBackground.translatesAutoresizingMaskIntoConstraints = NO;
181
201
  self.safeAreaBackground.userInteractionEnabled = NO;
182
202
  [ROOT_VIEW_CONTROLLER.view addSubview: self.safeAreaBackground];
203
+
204
+ // Check that plugin version is compatible with native SDK version
205
+ NSString *minCompatibleNativeSdkVersion = ALCompatibleNativeSDKVersions[PLUGIN_VERSION];
206
+ BOOL isCompatible = [ALUtils isInclusiveVersion: ALSdk.version
207
+ forMinVersion: minCompatibleNativeSdkVersion
208
+ maxVersion: nil];
209
+ if ( !isCompatible )
210
+ {
211
+ [NSException raise: NSInternalInconsistencyException
212
+ format: @"Incompatible native SDK version (%@) found for plugin (%@)", minCompatibleNativeSdkVersion, PLUGIN_VERSION];
213
+ }
183
214
  }
184
215
  return self;
185
216
  }
@@ -210,7 +241,7 @@ RCT_EXPORT_METHOD(initialize:(NSString *)pluginVersion :(NSString *)sdkKey :(RCT
210
241
  }
211
242
 
212
243
  ALSdkInitializationConfiguration *initConfig = [ALSdkInitializationConfiguration configurationWithSdkKey: sdkKey builderBlock:^(ALSdkInitializationConfigurationBuilder *builder) {
213
-
244
+
214
245
  builder.mediationProvider = ALMediationProviderMAX;
215
246
  builder.pluginVersion = [@"React-Native-" stringByAppendingString: pluginVersion];
216
247
  builder.segmentCollection = [self.segmentCollectionBuilder build];
@@ -425,7 +456,7 @@ RCT_EXPORT_METHOD(getSegments:(RCTPromiseResolveBlock)resolve :(RCTPromiseReject
425
456
  }
426
457
 
427
458
  NSArray<MASegment *> *segments = self.sdk.segmentCollection.segments;
428
-
459
+
429
460
  if ( ![segments count] )
430
461
  {
431
462
  resolve(nil);
@@ -440,7 +471,7 @@ RCT_EXPORT_METHOD(getSegments:(RCTPromiseResolveBlock)resolve :(RCTPromiseReject
440
471
  NSString *strKey = [segment.key stringValue];
441
472
  jsObj[strKey] = segment.values;
442
473
  }
443
-
474
+
444
475
  resolve(jsObj);
445
476
  }
446
477
 
@@ -2070,7 +2101,7 @@ RCT_EXPORT_METHOD(destroyNativeUIComponentAdView:(NSString *)adUnitIdentifier
2070
2101
  ON_APPOPEN_AD_FAILED_TO_DISPLAY_EVENT,
2071
2102
  ON_APPOPEN_AD_HIDDEN_EVENT,
2072
2103
  ON_APPOPEN_AD_REVENUE_PAID,
2073
-
2104
+
2074
2105
  ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOADED_EVENT,
2075
2106
  ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOAD_FAILED_EVENT];
2076
2107
  }
@@ -2118,7 +2149,7 @@ RCT_EXPORT_METHOD(destroyNativeUIComponentAdView:(NSString *)adUnitIdentifier
2118
2149
 
2119
2150
  @"ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOADED_EVENT" : ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOADED_EVENT,
2120
2151
  @"ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOAD_FAILED_EVENT" : ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOAD_FAILED_EVENT,
2121
-
2152
+
2122
2153
  @"TOP_CENTER_POSITION" : TOP_CENTER,
2123
2154
  @"TOP_LEFT_POSITION" : TOP_LEFT,
2124
2155
  @"TOP_RIGHT_POSITION" : TOP_RIGHT,
@@ -2131,7 +2162,7 @@ RCT_EXPORT_METHOD(destroyNativeUIComponentAdView:(NSString *)adUnitIdentifier
2131
2162
 
2132
2163
  @"BANNER_AD_FORMAT_LABEL" : MAAdFormat.banner.label,
2133
2164
  @"MREC_AD_FORMAT_LABEL" : MAAdFormat.mrec.label,
2134
-
2165
+
2135
2166
  @"MAX_ERROR_CODE_UNSPECIFIED" : @(MAErrorCodeUnspecified),
2136
2167
  @"MAX_ERROR_CODE_NO_FILL" : @(MAErrorCodeNoFill),
2137
2168
  @"MAX_ERROR_CODE_AD_LOAD_FAILED" : @(MAErrorCodeAdLoadFailed),
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = exports.ConsentFlowUserGeography = exports.CMPErrorCode = exports.AppTrackingStatus = exports.AppLovinMAX = void 0;
7
7
  var _reactNative = require("react-native");
8
8
  const NativeAppLovinMAX = _reactNative.NativeModules.AppLovinMAX;
9
- const VERSION = '8.0.1';
9
+ const VERSION = '8.0.2';
10
10
 
11
11
  /**
12
12
  * This enum represents the user's geography used to determine the type of consent flow shown to the
@@ -1,6 +1,6 @@
1
1
  import { NativeModules } from 'react-native';
2
2
  const NativeAppLovinMAX = NativeModules.AppLovinMAX;
3
- const VERSION = '8.0.1';
3
+ const VERSION = '8.0.2';
4
4
 
5
5
  /**
6
6
  * This enum represents the user's geography used to determine the type of consent flow shown to the
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-applovin-max",
3
3
  "author": "AppLovin Corporation <support@applovin.com> (https://applovin.com)",
4
- "version": "8.0.1",
4
+ "version": "8.0.2",
5
5
  "description": "AppLovin MAX React Native Plugin for Android and iOS",
6
6
  "main": "lib/commonjs/index",
7
7
  "module": "lib/module/index",
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
12
12
  s.authors = package["author"]
13
13
 
14
14
  s.platforms = { :ios => min_ios_version_supported }
15
- s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_8_0_1" }
15
+ s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_8_0_2" }
16
16
 
17
17
  s.source_files = "ios/AppLovinMAX*.{h,m}"
18
18
 
@@ -4,7 +4,7 @@ import type { Configuration } from './types/Configuration';
4
4
 
5
5
  const NativeAppLovinMAX = NativeModules.AppLovinMAX;
6
6
 
7
- const VERSION = '8.0.1';
7
+ const VERSION = '8.0.2';
8
8
 
9
9
  /**
10
10
  * This enum represents the user's geography used to determine the type of consent flow shown to the