react-native-applovin-max 7.0.0 → 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 (197) hide show
  1. package/android/build.gradle +3 -3
  2. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewUiComponent.java +6 -3
  3. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXModule.java +61 -510
  4. package/ios/AppLovinMAX.m +55 -468
  5. package/lib/commonjs/AdView.js +348 -0
  6. package/lib/commonjs/AdView.js.map +1 -0
  7. package/lib/commonjs/AppLovinMAX.js +68 -0
  8. package/lib/commonjs/AppLovinMAX.js.map +1 -0
  9. package/lib/commonjs/AppOpenAd.js +102 -0
  10. package/lib/commonjs/AppOpenAd.js.map +1 -0
  11. package/lib/commonjs/BannerAd.js +139 -0
  12. package/lib/commonjs/BannerAd.js.map +1 -0
  13. package/lib/commonjs/EventEmitter.js +32 -0
  14. package/lib/commonjs/EventEmitter.js.map +1 -0
  15. package/lib/commonjs/InterstitialAd.js +102 -0
  16. package/lib/commonjs/InterstitialAd.js.map +1 -0
  17. package/lib/commonjs/MRecAd.js +117 -0
  18. package/lib/commonjs/MRecAd.js.map +1 -0
  19. package/lib/commonjs/Privacy.js +12 -0
  20. package/lib/commonjs/Privacy.js.map +1 -0
  21. package/lib/commonjs/RewardedAd.js +116 -0
  22. package/lib/commonjs/RewardedAd.js.map +1 -0
  23. package/lib/commonjs/index.js +234 -0
  24. package/lib/commonjs/index.js.map +1 -0
  25. package/lib/commonjs/nativeAd/NativeAdView.js +147 -0
  26. package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -0
  27. package/lib/commonjs/nativeAd/NativeAdViewComponents.js +197 -0
  28. package/lib/commonjs/nativeAd/NativeAdViewComponents.js.map +1 -0
  29. package/lib/commonjs/nativeAd/NativeAdViewProvider.js +37 -0
  30. package/lib/commonjs/nativeAd/NativeAdViewProvider.js.map +1 -0
  31. package/lib/commonjs/types/AdEvent.js +6 -0
  32. package/lib/commonjs/types/AdEvent.js.map +1 -0
  33. package/lib/commonjs/types/AdInfo.js +48 -0
  34. package/lib/commonjs/types/AdInfo.js.map +1 -0
  35. package/lib/commonjs/types/AdProps.js +6 -0
  36. package/lib/commonjs/types/AdProps.js.map +1 -0
  37. package/lib/commonjs/types/AdViewProps.js +6 -0
  38. package/lib/commonjs/types/AdViewProps.js.map +1 -0
  39. package/lib/commonjs/types/AppLovinMAX.js +6 -0
  40. package/lib/commonjs/types/AppLovinMAX.js.map +1 -0
  41. package/lib/commonjs/types/AppOpenAd.js +6 -0
  42. package/lib/commonjs/types/AppOpenAd.js.map +1 -0
  43. package/lib/commonjs/types/BannerAd.js +6 -0
  44. package/lib/commonjs/types/BannerAd.js.map +1 -0
  45. package/lib/commonjs/types/CMPError.js +6 -0
  46. package/lib/commonjs/types/CMPError.js.map +1 -0
  47. package/lib/commonjs/types/Configuration.js +6 -0
  48. package/lib/commonjs/types/Configuration.js.map +1 -0
  49. package/lib/commonjs/types/FullscreenAd.js +6 -0
  50. package/lib/commonjs/types/FullscreenAd.js.map +1 -0
  51. package/lib/commonjs/types/InterstitialAd.js +6 -0
  52. package/lib/commonjs/types/InterstitialAd.js.map +1 -0
  53. package/lib/commonjs/types/MRecAd.js +6 -0
  54. package/lib/commonjs/types/MRecAd.js.map +1 -0
  55. package/lib/commonjs/types/NativeAd.js +2 -0
  56. package/lib/commonjs/types/NativeAd.js.map +1 -0
  57. package/lib/commonjs/types/NativeAdViewProps.js +6 -0
  58. package/lib/commonjs/types/NativeAdViewProps.js.map +1 -0
  59. package/lib/commonjs/types/Privacy.js +2 -0
  60. package/lib/commonjs/types/Privacy.js.map +1 -0
  61. package/lib/commonjs/types/RewardedAd.js +6 -0
  62. package/lib/commonjs/types/RewardedAd.js.map +1 -0
  63. package/lib/commonjs/types/ViewAd.js +6 -0
  64. package/lib/commonjs/types/ViewAd.js.map +1 -0
  65. package/lib/commonjs/types/index.js +61 -0
  66. package/lib/commonjs/types/index.js.map +1 -0
  67. package/lib/module/AdView.js +335 -0
  68. package/lib/module/AdView.js.map +1 -0
  69. package/lib/module/AppLovinMAX.js +64 -0
  70. package/lib/module/AppLovinMAX.js.map +1 -0
  71. package/lib/module/AppOpenAd.js +96 -0
  72. package/lib/module/AppOpenAd.js.map +1 -0
  73. package/lib/module/BannerAd.js +133 -0
  74. package/lib/module/BannerAd.js.map +1 -0
  75. package/lib/module/EventEmitter.js +24 -0
  76. package/lib/module/EventEmitter.js.map +1 -0
  77. package/lib/module/InterstitialAd.js +96 -0
  78. package/lib/module/InterstitialAd.js.map +1 -0
  79. package/lib/module/MRecAd.js +111 -0
  80. package/lib/module/MRecAd.js.map +1 -0
  81. package/lib/module/Privacy.js +6 -0
  82. package/lib/module/Privacy.js.map +1 -0
  83. package/lib/module/RewardedAd.js +110 -0
  84. package/lib/module/RewardedAd.js.map +1 -0
  85. package/lib/module/index.js +13 -0
  86. package/lib/module/index.js.map +1 -0
  87. package/lib/module/nativeAd/NativeAdView.js +139 -0
  88. package/lib/module/nativeAd/NativeAdView.js.map +1 -0
  89. package/lib/module/nativeAd/NativeAdViewComponents.js +181 -0
  90. package/lib/module/nativeAd/NativeAdViewComponents.js.map +1 -0
  91. package/lib/module/nativeAd/NativeAdViewProvider.js +28 -0
  92. package/lib/module/nativeAd/NativeAdViewProvider.js.map +1 -0
  93. package/lib/module/types/AdEvent.js +2 -0
  94. package/lib/module/types/AdEvent.js.map +1 -0
  95. package/lib/module/types/AdInfo.js +52 -0
  96. package/lib/module/types/AdInfo.js.map +1 -0
  97. package/lib/module/types/AdProps.js +2 -0
  98. package/lib/module/types/AdProps.js.map +1 -0
  99. package/lib/module/types/AdViewProps.js +2 -0
  100. package/lib/module/types/AdViewProps.js.map +1 -0
  101. package/lib/module/types/AppLovinMAX.js +2 -0
  102. package/lib/module/types/AppLovinMAX.js.map +1 -0
  103. package/lib/module/types/AppOpenAd.js +2 -0
  104. package/lib/module/types/AppOpenAd.js.map +1 -0
  105. package/lib/module/types/BannerAd.js +2 -0
  106. package/lib/module/types/BannerAd.js.map +1 -0
  107. package/lib/module/types/CMPError.js +2 -0
  108. package/lib/module/types/CMPError.js.map +1 -0
  109. package/lib/module/types/Configuration.js +2 -0
  110. package/lib/module/types/Configuration.js.map +1 -0
  111. package/lib/module/types/FullscreenAd.js +2 -0
  112. package/lib/module/types/FullscreenAd.js.map +1 -0
  113. package/lib/module/types/InterstitialAd.js +2 -0
  114. package/lib/module/types/InterstitialAd.js.map +1 -0
  115. package/lib/module/types/MRecAd.js +2 -0
  116. package/lib/module/types/MRecAd.js.map +1 -0
  117. package/lib/module/types/NativeAd.js +2 -0
  118. package/lib/module/types/NativeAd.js.map +1 -0
  119. package/lib/module/types/NativeAdViewProps.js +2 -0
  120. package/lib/module/types/NativeAdViewProps.js.map +1 -0
  121. package/lib/module/types/Privacy.js +2 -0
  122. package/lib/module/types/Privacy.js.map +1 -0
  123. package/lib/module/types/RewardedAd.js +2 -0
  124. package/lib/module/types/RewardedAd.js.map +1 -0
  125. package/lib/module/types/ViewAd.js +2 -0
  126. package/lib/module/types/ViewAd.js.map +1 -0
  127. package/lib/module/types/index.js +6 -0
  128. package/lib/module/types/index.js.map +1 -0
  129. package/lib/typescript/src/AdView.d.ts +115 -0
  130. package/lib/typescript/src/AdView.d.ts.map +1 -0
  131. package/lib/typescript/src/AppLovinMAX.d.ts +73 -0
  132. package/lib/typescript/src/AppLovinMAX.d.ts.map +1 -0
  133. package/lib/typescript/src/AppOpenAd.d.ts +4 -0
  134. package/lib/typescript/src/AppOpenAd.d.ts.map +1 -0
  135. package/lib/typescript/src/BannerAd.d.ts +4 -0
  136. package/lib/typescript/src/BannerAd.d.ts.map +1 -0
  137. package/lib/typescript/src/EventEmitter.d.ts +4 -0
  138. package/lib/typescript/src/EventEmitter.d.ts.map +1 -0
  139. package/lib/typescript/src/InterstitialAd.d.ts +4 -0
  140. package/lib/typescript/src/InterstitialAd.d.ts.map +1 -0
  141. package/lib/typescript/src/MRecAd.d.ts +4 -0
  142. package/lib/typescript/src/MRecAd.d.ts.map +1 -0
  143. package/lib/typescript/src/Privacy.d.ts +3 -0
  144. package/lib/typescript/src/Privacy.d.ts.map +1 -0
  145. package/lib/typescript/src/RewardedAd.d.ts +4 -0
  146. package/lib/typescript/src/RewardedAd.d.ts.map +1 -0
  147. package/lib/typescript/src/index.d.ts +13 -0
  148. package/lib/typescript/src/index.d.ts.map +1 -0
  149. package/lib/typescript/src/nativeAd/NativeAdView.d.ts +42 -0
  150. package/lib/typescript/src/nativeAd/NativeAdView.d.ts.map +1 -0
  151. package/lib/typescript/src/nativeAd/NativeAdViewComponents.d.ts +11 -0
  152. package/lib/typescript/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -0
  153. package/lib/typescript/src/nativeAd/NativeAdViewProvider.d.ts +16 -0
  154. package/lib/typescript/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -0
  155. package/lib/typescript/src/types/AdEvent.d.ts +15 -0
  156. package/lib/typescript/src/types/AdEvent.d.ts.map +1 -0
  157. package/lib/typescript/src/types/AdInfo.d.ts +295 -0
  158. package/lib/typescript/src/types/AdInfo.d.ts.map +1 -0
  159. package/lib/typescript/src/types/AdProps.d.ts +58 -0
  160. package/lib/typescript/src/types/AdProps.d.ts.map +1 -0
  161. package/lib/typescript/src/types/AdViewProps.d.ts +73 -0
  162. package/lib/typescript/src/types/AdViewProps.d.ts.map +1 -0
  163. package/lib/typescript/src/types/AppLovinMAX.d.ts +145 -0
  164. package/lib/typescript/src/types/AppLovinMAX.d.ts.map +1 -0
  165. package/lib/typescript/src/types/AppOpenAd.d.ts +3 -0
  166. package/lib/typescript/src/types/AppOpenAd.d.ts.map +1 -0
  167. package/lib/typescript/src/types/BannerAd.d.ts +42 -0
  168. package/lib/typescript/src/types/BannerAd.d.ts.map +1 -0
  169. package/lib/typescript/src/types/CMPError.d.ts +20 -0
  170. package/lib/typescript/src/types/CMPError.d.ts.map +1 -0
  171. package/lib/typescript/src/types/Configuration.d.ts +33 -0
  172. package/lib/typescript/src/types/Configuration.d.ts.map +1 -0
  173. package/lib/typescript/src/types/FullscreenAd.d.ts +123 -0
  174. package/lib/typescript/src/types/FullscreenAd.d.ts.map +1 -0
  175. package/lib/typescript/src/types/InterstitialAd.d.ts +3 -0
  176. package/lib/typescript/src/types/InterstitialAd.d.ts.map +1 -0
  177. package/lib/typescript/src/types/MRecAd.d.ts +12 -0
  178. package/lib/typescript/src/types/MRecAd.d.ts.map +1 -0
  179. package/lib/typescript/src/types/NativeAd.d.ts +42 -0
  180. package/lib/typescript/src/types/NativeAd.d.ts.map +1 -0
  181. package/lib/typescript/src/types/NativeAdViewProps.d.ts +15 -0
  182. package/lib/typescript/src/types/NativeAdViewProps.d.ts.map +1 -0
  183. package/lib/typescript/src/types/Privacy.d.ts +35 -0
  184. package/lib/typescript/src/types/Privacy.d.ts.map +1 -0
  185. package/lib/typescript/src/types/RewardedAd.d.ts +18 -0
  186. package/lib/typescript/src/types/RewardedAd.d.ts.map +1 -0
  187. package/lib/typescript/src/types/ViewAd.d.ts +141 -0
  188. package/lib/typescript/src/types/ViewAd.d.ts.map +1 -0
  189. package/lib/typescript/src/types/index.d.ts +6 -0
  190. package/lib/typescript/src/types/index.d.ts.map +1 -0
  191. package/package.json +19 -11
  192. package/react-native-applovin-max.podspec +2 -2
  193. package/src/AppLovinMAX.ts +24 -3
  194. package/src/index.ts +0 -1
  195. package/src/types/AppLovinMAX.ts +20 -7
  196. package/src/TargetingData.ts +0 -212
  197. 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;
@@ -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
@@ -2057,18 +1718,6 @@ RCT_EXPORT_METHOD(destroyNativeUIComponentAdView:(NSString *)adUnitIdentifier :(
2057
1718
  [NSLayoutConstraint activateConstraints: constraints];
2058
1719
  }
2059
1720
 
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
1721
  - (void)logInvalidAdFormat:(MAAdFormat *)adFormat
2073
1722
  {
2074
1723
  [self logInvalidAdFormat: adFormat withPromiseReject: nil];
@@ -2115,68 +1764,6 @@ RCT_EXPORT_METHOD(destroyNativeUIComponentAdView:(NSString *)adUnitIdentifier :(
2115
1764
  NSLog(@"[%@] [%@] %@", SDK_TAG, TAG, message);
2116
1765
  }
2117
1766
 
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
1767
  - (ALConsentFlowUserGeography)toAppLovinConsentFlowUserGeography:(NSString *)userGeography
2181
1768
  {
2182
1769
  if ( [USER_GEOGRAPHY_GDPR al_isEqualToStringIgnoringCase: userGeography] )