react-native-applovin-max 3.0.2 → 3.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.
@@ -41,8 +41,8 @@ android {
41
41
  defaultConfig {
42
42
  minSdkVersion 16
43
43
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
44
- versionCode 3000200
45
- versionName "3.0.2"
44
+ versionCode 3010000
45
+ versionName "3.1.0"
46
46
  }
47
47
 
48
48
  flavorDimensions("default")
@@ -29,12 +29,15 @@ import com.applovin.mediation.MaxRewardedAdListener;
29
29
  import com.applovin.mediation.ads.MaxAdView;
30
30
  import com.applovin.mediation.ads.MaxInterstitialAd;
31
31
  import com.applovin.mediation.ads.MaxRewardedAd;
32
+ import com.applovin.sdk.AppLovinAdContentRating;
33
+ import com.applovin.sdk.AppLovinGender;
32
34
  import com.applovin.sdk.AppLovinMediationProvider;
33
35
  import com.applovin.sdk.AppLovinPrivacySettings;
34
36
  import com.applovin.sdk.AppLovinSdk;
35
37
  import com.applovin.sdk.AppLovinSdkConfiguration;
36
38
  import com.applovin.sdk.AppLovinSdkSettings;
37
39
  import com.applovin.sdk.AppLovinSdkUtils;
40
+ import com.applovin.sdk.AppLovinUserService;
38
41
  import com.facebook.react.bridge.Arguments;
39
42
  import com.facebook.react.bridge.Callback;
40
43
  import com.facebook.react.bridge.ReactApplicationContext;
@@ -273,6 +276,168 @@ public class AppLovinMAXModule
273
276
  } );
274
277
  }
275
278
 
279
+ // Data Passing
280
+
281
+ @ReactMethod()
282
+ public void setTargetingDataYearOfBirth(final int yearOfBirth)
283
+ {
284
+ if ( sdk == null )
285
+ {
286
+ logUninitializedAccessError( "setTargetingDataYearOfBirth" );
287
+ return;
288
+ }
289
+
290
+ sdk.getTargetingData().setYearOfBirth( yearOfBirth <= 0 ? null : yearOfBirth );
291
+ }
292
+
293
+ @ReactMethod()
294
+ public void setTargetingDataGender(final String gender)
295
+ {
296
+ if ( sdk == null )
297
+ {
298
+ logUninitializedAccessError( "setTargetingDataGender" );
299
+ return;
300
+ }
301
+
302
+ AppLovinGender alGender = AppLovinGender.UNKNOWN;
303
+
304
+ if ( "F".equals( gender ) )
305
+ {
306
+ alGender = AppLovinGender.FEMALE;
307
+ }
308
+ else if ( "M".equals( gender ) )
309
+ {
310
+ alGender = AppLovinGender.MALE;
311
+ }
312
+ else if ( "O".equals( gender ) )
313
+ {
314
+ alGender = AppLovinGender.OTHER;
315
+ }
316
+
317
+ sdk.getTargetingData().setGender( alGender );
318
+ }
319
+
320
+ @ReactMethod()
321
+ public void setTargetingDataMaximumAdContentRating(final int maximumAdContentRating)
322
+ {
323
+ if ( sdk == null )
324
+ {
325
+ logUninitializedAccessError( "setTargetingDataMaximumAdContentRating" );
326
+ return;
327
+ }
328
+
329
+ AppLovinAdContentRating rating = AppLovinAdContentRating.NONE;
330
+
331
+ if ( maximumAdContentRating == 1 )
332
+ {
333
+ rating = AppLovinAdContentRating.ALL_AUDIENCES;
334
+ }
335
+ else if ( maximumAdContentRating == 2 )
336
+ {
337
+ rating = AppLovinAdContentRating.EVERYONE_OVER_TWELVE;
338
+ }
339
+ else if ( maximumAdContentRating == 3 )
340
+ {
341
+ rating = AppLovinAdContentRating.MATURE_AUDIENCES;
342
+ }
343
+
344
+ sdk.getTargetingData().setMaximumAdContentRating( rating );
345
+ }
346
+
347
+ @ReactMethod()
348
+ public void setTargetingDataEmail(final String email)
349
+ {
350
+ if ( sdk == null )
351
+ {
352
+ logUninitializedAccessError( "setTargetingDataEmail" );
353
+ return;
354
+ }
355
+
356
+ sdk.getTargetingData().setEmail( email );
357
+ }
358
+
359
+ @ReactMethod()
360
+ public void setTargetingDataPhoneNumber(final String phoneNumber)
361
+ {
362
+ if ( sdk == null )
363
+ {
364
+ logUninitializedAccessError( "setTargetingDataPhoneNumber" );
365
+ return;
366
+ }
367
+
368
+ sdk.getTargetingData().setPhoneNumber( phoneNumber );
369
+ }
370
+
371
+ @ReactMethod()
372
+ public void setTargetingDataKeywords(final ReadableArray rawKeywords)
373
+ {
374
+ if ( sdk == null )
375
+ {
376
+ logUninitializedAccessError( "setTargetingDataKeywords" );
377
+ return;
378
+ }
379
+
380
+ List<String> keywords = null;
381
+
382
+ if ( rawKeywords != null )
383
+ {
384
+ keywords = new ArrayList<>( rawKeywords.size() );
385
+ for ( Object rawKeyword : rawKeywords.toArrayList() )
386
+ {
387
+ keywords.add( (String) rawKeyword );
388
+ }
389
+ }
390
+
391
+ sdk.getTargetingData().setKeywords( keywords );
392
+ }
393
+
394
+ @ReactMethod()
395
+ public void setTargetingDataInterests(final ReadableArray rawInterests)
396
+ {
397
+ if ( sdk == null )
398
+ {
399
+ logUninitializedAccessError( "setTargetingDataInterests" );
400
+ return;
401
+ }
402
+
403
+ List<String> interests = null;
404
+
405
+ if ( rawInterests != null )
406
+ {
407
+ interests = new ArrayList<>( rawInterests.size() );
408
+ for ( Object rawInterest : rawInterests.toArrayList() )
409
+ {
410
+ interests.add( (String) rawInterest );
411
+ }
412
+ }
413
+
414
+ sdk.getTargetingData().setInterests( interests );
415
+ }
416
+
417
+ @ReactMethod()
418
+ public void clearAllTargetingData()
419
+ {
420
+ if ( sdk == null )
421
+ {
422
+ logUninitializedAccessError( "clearAllTargetingData" );
423
+ return;
424
+ }
425
+
426
+ sdk.getTargetingData().clearAll();
427
+ }
428
+
429
+ @ReactMethod()
430
+ public void setLocationCollectionEnabled(final boolean locationCollectionEnabled)
431
+ {
432
+ if ( sdk == null )
433
+ {
434
+ logUninitializedAccessError( "setLocationCollectionEnabled" );
435
+ return;
436
+ }
437
+
438
+ sdk.getSettings().setLocationCollectionEnabled( locationCollectionEnabled );
439
+ }
440
+
276
441
  // General Public API
277
442
 
278
443
  @ReactMethod(isBlockingSynchronousMethod = true)
@@ -287,13 +452,32 @@ public class AppLovinMAXModule
287
452
  {
288
453
  if ( sdk == null )
289
454
  {
290
- Log.e( "[" + TAG + "]", "Failed to show mediation debugger - please ensure the AppLovin MAX React Native module has been initialized by calling 'AppLovinMAX.initialize(...);'!" );
455
+ logUninitializedAccessError( "showMediationDebugger" );
291
456
  return;
292
457
  }
293
458
 
294
459
  sdk.showMediationDebugger();
295
460
  }
296
461
 
462
+ @ReactMethod()
463
+ public void showConsentDialog(final Callback callback)
464
+ {
465
+ if ( sdk == null )
466
+ {
467
+ logUninitializedAccessError( "showConsentDialog" );
468
+ return;
469
+ }
470
+
471
+ sdk.getUserService().showConsentDialog( maybeGetCurrentActivity(), new AppLovinUserService.OnConsentDialogDismissListener()
472
+ {
473
+ @Override
474
+ public void onDismiss()
475
+ {
476
+ callback.invoke();
477
+ }
478
+ } );
479
+ }
480
+
297
481
  @ReactMethod(isBlockingSynchronousMethod = true)
298
482
  public int getConsentDialogState()
299
483
  {
@@ -1174,6 +1358,11 @@ public class AppLovinMAXModule
1174
1358
  e( Log.getStackTraceString( e ) );
1175
1359
  }
1176
1360
 
1361
+ private static void logUninitializedAccessError(final String callingMethod)
1362
+ {
1363
+ e( "ERROR: Failed to execute " + callingMethod + "() - please ensure the AppLovin MAX React Native module has been initialized by calling 'AppLovinMAX.initialize(...);'!" );
1364
+ }
1365
+
1177
1366
  public static void d(final String message)
1178
1367
  {
1179
1368
  final String fullMessage = "[" + TAG + "] " + message;
package/ios/AppLovinMAX.m CHANGED
@@ -206,6 +206,139 @@ RCT_EXPORT_METHOD(initialize:(NSString *)pluginVersion :(NSString *)sdkKey :(RCT
206
206
  }];
207
207
  }
208
208
 
209
+ #pragma mark - Data Passing
210
+
211
+ RCT_EXPORT_METHOD(setTargetingDataYearOfBirth:(nonnull NSNumber *)yearOfBirth)
212
+ {
213
+ if ( !_sdk )
214
+ {
215
+ [self logUninitializedAccessError: @"setTargetingDataYearOfBirth"];
216
+ return;
217
+ }
218
+
219
+ self.sdk.targetingData.yearOfBirth = yearOfBirth.intValue <= 0 ? nil : yearOfBirth;
220
+ }
221
+
222
+ RCT_EXPORT_METHOD(setTargetingDataGender:(nullable NSString *)gender)
223
+ {
224
+ if ( !_sdk )
225
+ {
226
+ [self logUninitializedAccessError: @"setTargetingDataGender"];
227
+ return;
228
+ }
229
+
230
+ ALGender alGender = ALGenderUnknown;
231
+
232
+ if ( [@"F" isEqualToString: gender] )
233
+ {
234
+ alGender = ALGenderFemale;
235
+ }
236
+ else if ( [@"M" isEqualToString: gender] )
237
+ {
238
+ alGender = ALGenderMale;
239
+ }
240
+ else if ( [@"O" isEqualToString: gender] )
241
+ {
242
+ alGender = ALGenderOther;
243
+ }
244
+
245
+ self.sdk.targetingData.gender = alGender;
246
+ }
247
+
248
+ RCT_EXPORT_METHOD(setTargetingDataMaximumAdContentRating:(nonnull NSNumber *)maximumAdContentRating)
249
+ {
250
+ if ( !_sdk )
251
+ {
252
+ [self logUninitializedAccessError: @"setTargetingDataMaximumAdContentRating"];
253
+ return;
254
+ }
255
+
256
+ ALAdContentRating rating = ALAdContentRatingNone;
257
+
258
+ int intVal = maximumAdContentRating.intValue;
259
+
260
+ if ( intVal == 1 )
261
+ {
262
+ rating = ALAdContentRatingAllAudiences;
263
+ }
264
+ else if ( intVal == 2 )
265
+ {
266
+ rating = ALAdContentRatingEveryoneOverTwelve;
267
+ }
268
+ else if ( intVal == 3 )
269
+ {
270
+ rating = ALAdContentRatingMatureAudiences;
271
+ }
272
+
273
+ self.sdk.targetingData.maximumAdContentRating = rating;
274
+ }
275
+
276
+ RCT_EXPORT_METHOD(setTargetingDataEmail:(nullable NSString *)email)
277
+ {
278
+ if ( !_sdk )
279
+ {
280
+ [self logUninitializedAccessError: @"setTargetingDataEmail"];
281
+ return;
282
+ }
283
+
284
+ self.sdk.targetingData.email = email;
285
+ }
286
+
287
+ RCT_EXPORT_METHOD(setTargetingDataPhoneNumber:(nullable NSString *)phoneNumber)
288
+ {
289
+ if ( !_sdk )
290
+ {
291
+ [self logUninitializedAccessError: @"setTargetingDataPhoneNumber"];
292
+ return;
293
+ }
294
+
295
+ self.sdk.targetingData.phoneNumber = phoneNumber;
296
+ }
297
+
298
+ RCT_EXPORT_METHOD(setTargetingDataKeywords:(nullable NSArray<NSString *> *)keywords)
299
+ {
300
+ if ( !_sdk )
301
+ {
302
+ [self logUninitializedAccessError: @"setTargetingDataKeywords"];
303
+ return;
304
+ }
305
+
306
+ self.sdk.targetingData.keywords = keywords;
307
+ }
308
+
309
+ RCT_EXPORT_METHOD(setTargetingDataInterests:(nullable NSArray<NSString *> *)interests)
310
+ {
311
+ if ( !_sdk )
312
+ {
313
+ [self logUninitializedAccessError: @"setTargetingDataInterests"];
314
+ return;
315
+ }
316
+
317
+ self.sdk.targetingData.interests = interests;
318
+ }
319
+
320
+ RCT_EXPORT_METHOD(clearAllTargetingData)
321
+ {
322
+ if ( !_sdk )
323
+ {
324
+ [self logUninitializedAccessError: @"clearAllTargetingData"];
325
+ return;
326
+ }
327
+
328
+ [self.sdk.targetingData clearAll];
329
+ }
330
+
331
+ RCT_EXPORT_METHOD(setLocationCollectionEnabled:(BOOL)locationCollectionEnabled)
332
+ {
333
+ if ( !_sdk )
334
+ {
335
+ [self logUninitializedAccessError: @"setLocationCollectionEnabled"];
336
+ return;
337
+ }
338
+
339
+ self.sdk.settings.locationCollectionEnabled = locationCollectionEnabled;
340
+ }
341
+
209
342
  #pragma mark - General Public API
210
343
 
211
344
  RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(isTablet)
@@ -217,13 +350,20 @@ RCT_EXPORT_METHOD(showMediationDebugger)
217
350
  {
218
351
  if ( !_sdk )
219
352
  {
220
- [self log: @"Failed to show mediation debugger - please ensure the AppLovin MAX Unity Plugin has been initialized by calling 'AppLovinMAX.initialize(...);'!"];
353
+ [self logUninitializedAccessError: @"showMediationDebugger"];
221
354
  return;
222
355
  }
223
356
 
224
357
  [self.sdk showMediationDebugger];
225
358
  }
226
359
 
360
+ RCT_EXPORT_METHOD(showConsentDialog:(RCTResponseSenderBlock)callback)
361
+ {
362
+ [self log: @"Failed to show consent dialog - Unavailable on iOS, please use the consent flow: https://dash.applovin.com/documentation/mediation/react-native/getting-started/consent-flow"];
363
+
364
+ callback(nil);
365
+ }
366
+
227
367
  RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getConsentDialogState)
228
368
  {
229
369
  if ( ![self isInitialized] ) return @(ALConsentDialogStateUnknown);
@@ -916,6 +1056,11 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
916
1056
  [self log: @"invalid ad format: %@, from %@", adFormat, [NSThread callStackSymbols]];
917
1057
  }
918
1058
 
1059
+ - (void)logUninitializedAccessError:(NSString *)callingMethod
1060
+ {
1061
+ [self log: @"ERROR: Failed to execute %@() - please ensure the AppLovin MAX React Native module has been initialized by calling 'AppLovinMAX.initialize(...);'!", callingMethod];
1062
+ }
1063
+
919
1064
  - (void)log:(NSString *)format, ...
920
1065
  {
921
1066
  va_list valist;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-applovin-max",
3
3
  "author": "AppLovin Corporation",
4
- "version": "3.0.2",
4
+ "version": "3.1.0",
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_3_0_2" }
14
+ s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_3_1_0" }
15
15
 
16
16
  s.source_files = "ios/AppLovinMAX*.{h,m}"
17
17
 
@@ -0,0 +1,70 @@
1
+ import AppLovinMAX from "./index.js";
2
+
3
+ const AdContentRating = {
4
+ None: 0,
5
+ AllAudiences: 1,
6
+ EveryoneOverTwelve: 2,
7
+ MatureAudiences: 3,
8
+ };
9
+
10
+ const UserGender = {
11
+ Unknown: 'U',
12
+ Female: 'F',
13
+ Male: 'M',
14
+ Other: 'O'
15
+ };
16
+
17
+ let TargetingData = {
18
+
19
+ set yearOfBirth(value) {
20
+ AppLovinMAX.setTargetingDataYearOfBirth(value);
21
+ },
22
+
23
+ set gender(value) {
24
+ if ( value === UserGender.Unknown ||
25
+ value === UserGender.Female ||
26
+ value === UserGender.Male ||
27
+ value === UserGender.Other ) {
28
+ AppLovinMAX.setTargetingDataGender(value);
29
+ }
30
+ },
31
+
32
+ set maximumAdContentRating(value) {
33
+ if ( value === AdContentRating.None ||
34
+ value === AdContentRating.AllAudiences ||
35
+ value === AdContentRating.EveryoneOverTwelve ||
36
+ value === AdContentRating.MatureAudiences ) {
37
+ AppLovinMAX.setTargetingDataMaximumAdContentRating(value);
38
+ }
39
+ },
40
+
41
+ set email(value) {
42
+ AppLovinMAX.setTargetingDataEmail(value);
43
+ },
44
+
45
+ set phoneNumber(value) {
46
+ AppLovinMAX.setTargetingDataPhoneNumber(value);
47
+ },
48
+
49
+ set keywords(value) {
50
+ AppLovinMAX.setTargetingDataKeywords(value);
51
+ },
52
+
53
+ set interests(value) {
54
+ AppLovinMAX.setTargetingDataInterests(value);
55
+ },
56
+
57
+ clearAll() {
58
+ AppLovinMAX.clearAllTargetingData();
59
+ }
60
+
61
+ };
62
+
63
+ TargetingData.AdContentRating = AdContentRating;
64
+ TargetingData.UserGender = UserGender;
65
+
66
+ export {
67
+ TargetingData,
68
+ AdContentRating,
69
+ UserGender
70
+ };
package/src/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { NativeModules, NativeEventEmitter } from "react-native";
2
2
  import AdView from "./AppLovinMAXAdView";
3
+ import { TargetingData as targetingData, AdContentRating, UserGender } from "./TargetingData";
3
4
 
4
5
  const { AppLovinMAX } = NativeModules;
5
6
 
6
- const VERSION = "3.0.2";
7
+ const VERSION = "3.1.0";
7
8
 
8
9
  /**
9
10
  * This enum represents whether or not the consent dialog should be shown for this user.
@@ -67,6 +68,9 @@ const removeEventListener = (event) => {
67
68
  export default {
68
69
  ...AppLovinMAX,
69
70
  AdView,
71
+ targetingData,
72
+ AdContentRating,
73
+ UserGender,
70
74
  ConsentDialogState,
71
75
  AdViewPosition,
72
76
  AdFormat,
@@ -91,6 +95,7 @@ export default {
91
95
  /*--------------*/
92
96
  /* PRIVACY APIs */
93
97
  /*--------------*/
98
+ /* showConsentDialog(callback) */
94
99
  /* getConsentDialogState() */
95
100
  /* setHasUserConsent(hasUserConsent) */
96
101
  /* hasUserConsent() */
@@ -112,6 +117,7 @@ export default {
112
117
  /* setConsentFlowEnabled(enabled) */
113
118
  /* setPrivacyPolicyUrl(urlString) */
114
119
  /* setTermsOfServiceUrl(urlString) */
120
+ /* setLocationCollectionEnabled(locationCollectionEnabled) */
115
121
 
116
122
  /*----------------*/
117
123
  /* EVENT TRACKING */