react-native-applovin-max 3.0.2 → 3.2.1
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.
- package/LICENSE +1 -1
- package/android/build.gradle +3 -3
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdView.java +7 -1
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewManager.java +24 -0
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXModule.java +401 -116
- package/ios/AppLovinMAX.h +1 -1
- package/ios/AppLovinMAX.m +313 -37
- package/ios/AppLovinMAX.xcworkspace/xcuserdata/thomasso.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/AppLovinMAXAdViewManager.m +35 -0
- package/ios/Podfile +1 -1
- package/ios/Podfile.lock +4 -4
- package/package.json +1 -1
- package/react-native-applovin-max.podspec +2 -2
- package/src/AppLovinMAXAdView.js +24 -0
- package/src/TargetingData.js +70 -0
- package/src/UserSegment.js +12 -0
- package/src/index.js +58 -1
|
@@ -15,26 +15,34 @@ import android.view.OrientationEventListener;
|
|
|
15
15
|
import android.view.View;
|
|
16
16
|
import android.view.ViewGroup;
|
|
17
17
|
import android.view.ViewParent;
|
|
18
|
+
import android.view.WindowManager;
|
|
18
19
|
import android.widget.LinearLayout;
|
|
19
20
|
import android.widget.RelativeLayout;
|
|
20
21
|
|
|
21
22
|
import com.applovin.mediation.MaxAd;
|
|
22
23
|
import com.applovin.mediation.MaxAdFormat;
|
|
23
24
|
import com.applovin.mediation.MaxAdListener;
|
|
25
|
+
import com.applovin.mediation.MaxAdRevenueListener;
|
|
24
26
|
import com.applovin.mediation.MaxAdViewAdListener;
|
|
27
|
+
import com.applovin.mediation.MaxAdWaterfallInfo;
|
|
25
28
|
import com.applovin.mediation.MaxError;
|
|
26
29
|
import com.applovin.mediation.MaxErrorCode;
|
|
30
|
+
import com.applovin.mediation.MaxMediatedNetworkInfo;
|
|
31
|
+
import com.applovin.mediation.MaxNetworkResponseInfo;
|
|
27
32
|
import com.applovin.mediation.MaxReward;
|
|
28
33
|
import com.applovin.mediation.MaxRewardedAdListener;
|
|
29
34
|
import com.applovin.mediation.ads.MaxAdView;
|
|
30
35
|
import com.applovin.mediation.ads.MaxInterstitialAd;
|
|
31
36
|
import com.applovin.mediation.ads.MaxRewardedAd;
|
|
37
|
+
import com.applovin.sdk.AppLovinAdContentRating;
|
|
38
|
+
import com.applovin.sdk.AppLovinGender;
|
|
32
39
|
import com.applovin.sdk.AppLovinMediationProvider;
|
|
33
40
|
import com.applovin.sdk.AppLovinPrivacySettings;
|
|
34
41
|
import com.applovin.sdk.AppLovinSdk;
|
|
35
42
|
import com.applovin.sdk.AppLovinSdkConfiguration;
|
|
36
43
|
import com.applovin.sdk.AppLovinSdkSettings;
|
|
37
44
|
import com.applovin.sdk.AppLovinSdkUtils;
|
|
45
|
+
import com.applovin.sdk.AppLovinUserService;
|
|
38
46
|
import com.facebook.react.bridge.Arguments;
|
|
39
47
|
import com.facebook.react.bridge.Callback;
|
|
40
48
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
@@ -42,6 +50,7 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
|
42
50
|
import com.facebook.react.bridge.ReactMethod;
|
|
43
51
|
import com.facebook.react.bridge.ReadableArray;
|
|
44
52
|
import com.facebook.react.bridge.ReadableMap;
|
|
53
|
+
import com.facebook.react.bridge.WritableArray;
|
|
45
54
|
import com.facebook.react.bridge.WritableMap;
|
|
46
55
|
|
|
47
56
|
import java.util.ArrayList;
|
|
@@ -63,7 +72,7 @@ import static com.facebook.react.modules.core.DeviceEventManagerModule.RCTDevice
|
|
|
63
72
|
*/
|
|
64
73
|
public class AppLovinMAXModule
|
|
65
74
|
extends ReactContextBaseJavaModule
|
|
66
|
-
implements MaxAdListener, MaxAdViewAdListener, MaxRewardedAdListener
|
|
75
|
+
implements MaxAdListener, MaxAdViewAdListener, MaxRewardedAdListener, MaxAdRevenueListener
|
|
67
76
|
{
|
|
68
77
|
private static final String SDK_TAG = "AppLovinSdk";
|
|
69
78
|
private static final String TAG = "AppLovinMAXModule";
|
|
@@ -79,6 +88,9 @@ public class AppLovinMAXModule
|
|
|
79
88
|
private boolean isSdkInitialized;
|
|
80
89
|
private AppLovinSdkConfiguration sdkConfiguration;
|
|
81
90
|
|
|
91
|
+
private WindowManager windowManager;
|
|
92
|
+
private int lastRotation;
|
|
93
|
+
|
|
82
94
|
// Store these values if pub attempts to set it before initializing
|
|
83
95
|
private String userIdToSet;
|
|
84
96
|
private List<String> testDeviceAdvertisingIdsToSet;
|
|
@@ -95,7 +107,6 @@ public class AppLovinMAXModule
|
|
|
95
107
|
private final Map<String, String> mAdViewPositions = new HashMap<>( 2 );
|
|
96
108
|
private final Map<String, Point> mAdViewOffsets = new HashMap<>( 2 );
|
|
97
109
|
private final Map<String, Integer> mAdViewWidths = new HashMap<>( 2 );
|
|
98
|
-
private final Map<String, MaxAdFormat> mVerticalAdViewFormats = new HashMap<>( 2 );
|
|
99
110
|
private final List<String> mAdUnitIdsToShowAfterCreate = new ArrayList<>( 2 );
|
|
100
111
|
private final Set<String> mDisabledAdaptiveBannerAdUnitIds = new HashSet<>( 2 );
|
|
101
112
|
|
|
@@ -252,15 +263,24 @@ public class AppLovinMAXModule
|
|
|
252
263
|
sdkConfiguration = configuration;
|
|
253
264
|
isSdkInitialized = true;
|
|
254
265
|
|
|
255
|
-
|
|
266
|
+
windowManager = (WindowManager) context.getSystemService( Context.WINDOW_SERVICE );
|
|
267
|
+
|
|
268
|
+
lastRotation = windowManager.getDefaultDisplay().getRotation();
|
|
269
|
+
|
|
270
|
+
// Enable orientation change listener, so that the ad view positions can be updated when the device is rotated.
|
|
256
271
|
new OrientationEventListener( context )
|
|
257
272
|
{
|
|
258
273
|
@Override
|
|
259
274
|
public void onOrientationChanged(final int orientation)
|
|
260
275
|
{
|
|
261
|
-
|
|
276
|
+
int newRotation = windowManager.getDefaultDisplay().getRotation();
|
|
277
|
+
if ( newRotation != lastRotation )
|
|
262
278
|
{
|
|
263
|
-
|
|
279
|
+
lastRotation = newRotation;
|
|
280
|
+
for ( final Map.Entry<String, MaxAdFormat> adUnitFormats : mAdViewAdFormats.entrySet() )
|
|
281
|
+
{
|
|
282
|
+
positionAdView( adUnitFormats.getKey(), adUnitFormats.getValue() );
|
|
283
|
+
}
|
|
264
284
|
}
|
|
265
285
|
}
|
|
266
286
|
}.enable();
|
|
@@ -287,13 +307,32 @@ public class AppLovinMAXModule
|
|
|
287
307
|
{
|
|
288
308
|
if ( sdk == null )
|
|
289
309
|
{
|
|
290
|
-
|
|
310
|
+
logUninitializedAccessError( "showMediationDebugger" );
|
|
291
311
|
return;
|
|
292
312
|
}
|
|
293
313
|
|
|
294
314
|
sdk.showMediationDebugger();
|
|
295
315
|
}
|
|
296
316
|
|
|
317
|
+
@ReactMethod()
|
|
318
|
+
public void showConsentDialog(final Callback callback)
|
|
319
|
+
{
|
|
320
|
+
if ( sdk == null )
|
|
321
|
+
{
|
|
322
|
+
logUninitializedAccessError( "showConsentDialog" );
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
sdk.getUserService().showConsentDialog( maybeGetCurrentActivity(), new AppLovinUserService.OnConsentDialogDismissListener()
|
|
327
|
+
{
|
|
328
|
+
@Override
|
|
329
|
+
public void onDismiss()
|
|
330
|
+
{
|
|
331
|
+
callback.invoke();
|
|
332
|
+
}
|
|
333
|
+
} );
|
|
334
|
+
}
|
|
335
|
+
|
|
297
336
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
298
337
|
public int getConsentDialogState()
|
|
299
338
|
{
|
|
@@ -427,6 +466,180 @@ public class AppLovinMAXModule
|
|
|
427
466
|
@ReactMethod()
|
|
428
467
|
public void setTermsOfServiceUrl(final String urlString) {}
|
|
429
468
|
|
|
469
|
+
// Data Passing
|
|
470
|
+
|
|
471
|
+
@ReactMethod()
|
|
472
|
+
public void setUserSegment(final String name)
|
|
473
|
+
{
|
|
474
|
+
if ( sdk == null )
|
|
475
|
+
{
|
|
476
|
+
logUninitializedAccessError( "setUserSegment" );
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
sdk.getUserSegment().setName( name );
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
@ReactMethod()
|
|
484
|
+
public void setTargetingDataYearOfBirth(final int yearOfBirth)
|
|
485
|
+
{
|
|
486
|
+
if ( sdk == null )
|
|
487
|
+
{
|
|
488
|
+
logUninitializedAccessError( "setTargetingDataYearOfBirth" );
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
sdk.getTargetingData().setYearOfBirth( yearOfBirth <= 0 ? null : yearOfBirth );
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
@ReactMethod()
|
|
496
|
+
public void setTargetingDataGender(final String gender)
|
|
497
|
+
{
|
|
498
|
+
if ( sdk == null )
|
|
499
|
+
{
|
|
500
|
+
logUninitializedAccessError( "setTargetingDataGender" );
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
AppLovinGender alGender = AppLovinGender.UNKNOWN;
|
|
505
|
+
|
|
506
|
+
if ( "F".equals( gender ) )
|
|
507
|
+
{
|
|
508
|
+
alGender = AppLovinGender.FEMALE;
|
|
509
|
+
}
|
|
510
|
+
else if ( "M".equals( gender ) )
|
|
511
|
+
{
|
|
512
|
+
alGender = AppLovinGender.MALE;
|
|
513
|
+
}
|
|
514
|
+
else if ( "O".equals( gender ) )
|
|
515
|
+
{
|
|
516
|
+
alGender = AppLovinGender.OTHER;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
sdk.getTargetingData().setGender( alGender );
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
@ReactMethod()
|
|
523
|
+
public void setTargetingDataMaximumAdContentRating(final int maximumAdContentRating)
|
|
524
|
+
{
|
|
525
|
+
if ( sdk == null )
|
|
526
|
+
{
|
|
527
|
+
logUninitializedAccessError( "setTargetingDataMaximumAdContentRating" );
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
AppLovinAdContentRating rating = AppLovinAdContentRating.NONE;
|
|
532
|
+
|
|
533
|
+
if ( maximumAdContentRating == 1 )
|
|
534
|
+
{
|
|
535
|
+
rating = AppLovinAdContentRating.ALL_AUDIENCES;
|
|
536
|
+
}
|
|
537
|
+
else if ( maximumAdContentRating == 2 )
|
|
538
|
+
{
|
|
539
|
+
rating = AppLovinAdContentRating.EVERYONE_OVER_TWELVE;
|
|
540
|
+
}
|
|
541
|
+
else if ( maximumAdContentRating == 3 )
|
|
542
|
+
{
|
|
543
|
+
rating = AppLovinAdContentRating.MATURE_AUDIENCES;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
sdk.getTargetingData().setMaximumAdContentRating( rating );
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
@ReactMethod()
|
|
550
|
+
public void setTargetingDataEmail(final String email)
|
|
551
|
+
{
|
|
552
|
+
if ( sdk == null )
|
|
553
|
+
{
|
|
554
|
+
logUninitializedAccessError( "setTargetingDataEmail" );
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
sdk.getTargetingData().setEmail( email );
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
@ReactMethod()
|
|
562
|
+
public void setTargetingDataPhoneNumber(final String phoneNumber)
|
|
563
|
+
{
|
|
564
|
+
if ( sdk == null )
|
|
565
|
+
{
|
|
566
|
+
logUninitializedAccessError( "setTargetingDataPhoneNumber" );
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
sdk.getTargetingData().setPhoneNumber( phoneNumber );
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
@ReactMethod()
|
|
574
|
+
public void setTargetingDataKeywords(final ReadableArray rawKeywords)
|
|
575
|
+
{
|
|
576
|
+
if ( sdk == null )
|
|
577
|
+
{
|
|
578
|
+
logUninitializedAccessError( "setTargetingDataKeywords" );
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
List<String> keywords = null;
|
|
583
|
+
|
|
584
|
+
if ( rawKeywords != null )
|
|
585
|
+
{
|
|
586
|
+
keywords = new ArrayList<>( rawKeywords.size() );
|
|
587
|
+
for ( Object rawKeyword : rawKeywords.toArrayList() )
|
|
588
|
+
{
|
|
589
|
+
keywords.add( (String) rawKeyword );
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
sdk.getTargetingData().setKeywords( keywords );
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
@ReactMethod()
|
|
597
|
+
public void setTargetingDataInterests(final ReadableArray rawInterests)
|
|
598
|
+
{
|
|
599
|
+
if ( sdk == null )
|
|
600
|
+
{
|
|
601
|
+
logUninitializedAccessError( "setTargetingDataInterests" );
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
List<String> interests = null;
|
|
606
|
+
|
|
607
|
+
if ( rawInterests != null )
|
|
608
|
+
{
|
|
609
|
+
interests = new ArrayList<>( rawInterests.size() );
|
|
610
|
+
for ( Object rawInterest : rawInterests.toArrayList() )
|
|
611
|
+
{
|
|
612
|
+
interests.add( (String) rawInterest );
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
sdk.getTargetingData().setInterests( interests );
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
@ReactMethod()
|
|
620
|
+
public void clearAllTargetingData()
|
|
621
|
+
{
|
|
622
|
+
if ( sdk == null )
|
|
623
|
+
{
|
|
624
|
+
logUninitializedAccessError( "clearAllTargetingData" );
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
sdk.getTargetingData().clearAll();
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
@ReactMethod()
|
|
632
|
+
public void setLocationCollectionEnabled(final boolean locationCollectionEnabled)
|
|
633
|
+
{
|
|
634
|
+
if ( sdk == null )
|
|
635
|
+
{
|
|
636
|
+
logUninitializedAccessError( "setLocationCollectionEnabled" );
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
sdk.getSettings().setLocationCollectionEnabled( locationCollectionEnabled );
|
|
641
|
+
}
|
|
642
|
+
|
|
430
643
|
// EVENT TRACKING
|
|
431
644
|
|
|
432
645
|
@ReactMethod()
|
|
@@ -472,6 +685,12 @@ public class AppLovinMAXModule
|
|
|
472
685
|
setAdViewPlacement( adUnitId, getDeviceSpecificBannerAdViewAdFormat(), placement );
|
|
473
686
|
}
|
|
474
687
|
|
|
688
|
+
@ReactMethod()
|
|
689
|
+
public void setBannerCustomData(final String adUnitId, final String customData)
|
|
690
|
+
{
|
|
691
|
+
setAdViewCustomData( adUnitId, getDeviceSpecificBannerAdViewAdFormat(), customData );
|
|
692
|
+
}
|
|
693
|
+
|
|
475
694
|
@ReactMethod()
|
|
476
695
|
public void setBannerWidth(final String adUnitId, final int widthDp)
|
|
477
696
|
{
|
|
@@ -534,6 +753,12 @@ public class AppLovinMAXModule
|
|
|
534
753
|
setAdViewPlacement( adUnitId, MaxAdFormat.MREC, placement );
|
|
535
754
|
}
|
|
536
755
|
|
|
756
|
+
@ReactMethod()
|
|
757
|
+
public void setMRecCustomData(final String adUnitId, final String customData)
|
|
758
|
+
{
|
|
759
|
+
setAdViewCustomData( adUnitId, MaxAdFormat.MREC, customData );
|
|
760
|
+
}
|
|
761
|
+
|
|
537
762
|
@ReactMethod()
|
|
538
763
|
public void updateMRecPosition(final String adUnitId, final String mrecPosition)
|
|
539
764
|
{
|
|
@@ -581,16 +806,10 @@ public class AppLovinMAXModule
|
|
|
581
806
|
}
|
|
582
807
|
|
|
583
808
|
@ReactMethod()
|
|
584
|
-
public void showInterstitial(final String adUnitId)
|
|
585
|
-
{
|
|
586
|
-
showInterstitialWithPlacement( adUnitId, null );
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
@ReactMethod()
|
|
590
|
-
public void showInterstitialWithPlacement(final String adUnitId, final String placement)
|
|
809
|
+
public void showInterstitial(final String adUnitId, final String placement, final String customData)
|
|
591
810
|
{
|
|
592
811
|
MaxInterstitialAd interstitial = retrieveInterstitial( adUnitId );
|
|
593
|
-
interstitial.showAd( placement );
|
|
812
|
+
interstitial.showAd( placement, customData );
|
|
594
813
|
}
|
|
595
814
|
|
|
596
815
|
@ReactMethod()
|
|
@@ -623,16 +842,10 @@ public class AppLovinMAXModule
|
|
|
623
842
|
}
|
|
624
843
|
|
|
625
844
|
@ReactMethod()
|
|
626
|
-
public void showRewardedAd(final String adUnitId)
|
|
627
|
-
{
|
|
628
|
-
showRewardedAdWithPlacement( adUnitId, null );
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
@ReactMethod()
|
|
632
|
-
public void showRewardedAdWithPlacement(final String adUnitId, final String placement)
|
|
845
|
+
public void showRewardedAd(final String adUnitId, final String placement, final String customData)
|
|
633
846
|
{
|
|
634
847
|
MaxRewardedAd rewardedAd = retrieveRewardedAd( adUnitId );
|
|
635
|
-
rewardedAd.showAd( placement );
|
|
848
|
+
rewardedAd.showAd( placement, customData );
|
|
636
849
|
}
|
|
637
850
|
|
|
638
851
|
@ReactMethod()
|
|
@@ -732,6 +945,7 @@ public class AppLovinMAXModule
|
|
|
732
945
|
params.putInt( "code", error.getCode() );
|
|
733
946
|
params.putString( "message", error.getMessage() );
|
|
734
947
|
params.putString( "adLoadFailureInfo", error.getAdLoadFailureInfo() );
|
|
948
|
+
params.putMap( "waterfall", createAdWaterfallInfo( error.getWaterfall() ) );
|
|
735
949
|
}
|
|
736
950
|
else
|
|
737
951
|
{
|
|
@@ -861,6 +1075,41 @@ public class AppLovinMAXModule
|
|
|
861
1075
|
sendReactNativeEvent( ( MaxAdFormat.MREC == adFormat ) ? "OnMRecAdCollapsedEvent" : "OnBannerAdCollapsedEvent", getAdInfo( ad ) );
|
|
862
1076
|
}
|
|
863
1077
|
|
|
1078
|
+
@Override
|
|
1079
|
+
public void onAdRevenuePaid(final MaxAd ad)
|
|
1080
|
+
{
|
|
1081
|
+
final MaxAdFormat adFormat = ad.getFormat();
|
|
1082
|
+
final String name;
|
|
1083
|
+
if ( MaxAdFormat.BANNER == adFormat || MaxAdFormat.LEADER == adFormat )
|
|
1084
|
+
{
|
|
1085
|
+
name = "OnBannerAdRevenuePaid";
|
|
1086
|
+
}
|
|
1087
|
+
else if ( MaxAdFormat.MREC == adFormat )
|
|
1088
|
+
{
|
|
1089
|
+
name = "OnMRecAdRevenuePaid";
|
|
1090
|
+
}
|
|
1091
|
+
else if ( MaxAdFormat.INTERSTITIAL == adFormat )
|
|
1092
|
+
{
|
|
1093
|
+
name = "OnInterstitialAdRevenuePaid";
|
|
1094
|
+
}
|
|
1095
|
+
else if ( MaxAdFormat.REWARDED == adFormat )
|
|
1096
|
+
{
|
|
1097
|
+
name = "OnRewardedAdRevenuePaid";
|
|
1098
|
+
}
|
|
1099
|
+
else
|
|
1100
|
+
{
|
|
1101
|
+
logInvalidAdFormat( adFormat );
|
|
1102
|
+
return;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
WritableMap adInfo = getAdInfo( ad );
|
|
1106
|
+
adInfo.putString( "networkPlacement", ad.getNetworkPlacement() );
|
|
1107
|
+
adInfo.putString( "revenuePrecision", ad.getRevenuePrecision() );
|
|
1108
|
+
adInfo.putString( "countryCode", sdkConfiguration.getCountryCode() );
|
|
1109
|
+
|
|
1110
|
+
sendReactNativeEvent( name, adInfo );
|
|
1111
|
+
}
|
|
1112
|
+
|
|
864
1113
|
@Override
|
|
865
1114
|
public void onRewardedVideoCompleted(final MaxAd ad)
|
|
866
1115
|
{
|
|
@@ -960,6 +1209,27 @@ public class AppLovinMAXModule
|
|
|
960
1209
|
} );
|
|
961
1210
|
}
|
|
962
1211
|
|
|
1212
|
+
private void setAdViewCustomData(final String adUnitId, final MaxAdFormat adFormat, final String customData)
|
|
1213
|
+
{
|
|
1214
|
+
getReactApplicationContext().runOnUiQueueThread( new Runnable()
|
|
1215
|
+
{
|
|
1216
|
+
@Override
|
|
1217
|
+
public void run()
|
|
1218
|
+
{
|
|
1219
|
+
d( "Setting custom data \"" + customData + "\" for " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
|
|
1220
|
+
|
|
1221
|
+
final MaxAdView adView = retrieveAdView( adUnitId, adFormat, "", DEFAULT_AD_VIEW_OFFSET );
|
|
1222
|
+
if ( adView == null )
|
|
1223
|
+
{
|
|
1224
|
+
e( adFormat.getLabel() + " does not exist" );
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
adView.setCustomData( customData );
|
|
1229
|
+
}
|
|
1230
|
+
} );
|
|
1231
|
+
}
|
|
1232
|
+
|
|
963
1233
|
private void setAdViewWidth(final String adUnitId, final int widthDp, final MaxAdFormat adFormat)
|
|
964
1234
|
{
|
|
965
1235
|
getReactApplicationContext().runOnUiQueueThread( new Runnable()
|
|
@@ -1076,6 +1346,7 @@ public class AppLovinMAXModule
|
|
|
1076
1346
|
}
|
|
1077
1347
|
|
|
1078
1348
|
adView.setListener( null );
|
|
1349
|
+
adView.setRevenueListener( null );
|
|
1079
1350
|
adView.destroy();
|
|
1080
1351
|
|
|
1081
1352
|
mAdViews.remove( adUnitId );
|
|
@@ -1083,7 +1354,6 @@ public class AppLovinMAXModule
|
|
|
1083
1354
|
mAdViewPositions.remove( adUnitId );
|
|
1084
1355
|
mAdViewOffsets.remove( adUnitId );
|
|
1085
1356
|
mAdViewWidths.remove( adUnitId );
|
|
1086
|
-
mVerticalAdViewFormats.remove( adUnitId );
|
|
1087
1357
|
}
|
|
1088
1358
|
} );
|
|
1089
1359
|
}
|
|
@@ -1164,34 +1434,6 @@ public class AppLovinMAXModule
|
|
|
1164
1434
|
} );
|
|
1165
1435
|
}
|
|
1166
1436
|
|
|
1167
|
-
private void logInvalidAdFormat(MaxAdFormat adFormat)
|
|
1168
|
-
{
|
|
1169
|
-
logStackTrace( new IllegalStateException( "invalid ad format: " + adFormat ) );
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
private void logStackTrace(Exception e)
|
|
1173
|
-
{
|
|
1174
|
-
e( Log.getStackTraceString( e ) );
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
public static void d(final String message)
|
|
1178
|
-
{
|
|
1179
|
-
final String fullMessage = "[" + TAG + "] " + message;
|
|
1180
|
-
Log.d( SDK_TAG, fullMessage );
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
public static void w(final String message)
|
|
1184
|
-
{
|
|
1185
|
-
final String fullMessage = "[" + TAG + "] " + message;
|
|
1186
|
-
Log.w( SDK_TAG, fullMessage );
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
public static void e(final String message)
|
|
1190
|
-
{
|
|
1191
|
-
final String fullMessage = "[" + TAG + "] " + message;
|
|
1192
|
-
Log.e( SDK_TAG, fullMessage );
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
1437
|
@Nullable
|
|
1196
1438
|
private MaxInterstitialAd retrieveInterstitial(String adUnitId)
|
|
1197
1439
|
{
|
|
@@ -1203,6 +1445,7 @@ public class AppLovinMAXModule
|
|
|
1203
1445
|
{
|
|
1204
1446
|
result = new MaxInterstitialAd( adUnitId, sdk, currentActivity );
|
|
1205
1447
|
result.setListener( this );
|
|
1448
|
+
result.setRevenueListener( this );
|
|
1206
1449
|
|
|
1207
1450
|
mInterstitials.put( adUnitId, result );
|
|
1208
1451
|
}
|
|
@@ -1221,6 +1464,7 @@ public class AppLovinMAXModule
|
|
|
1221
1464
|
{
|
|
1222
1465
|
result = MaxRewardedAd.getInstance( adUnitId, sdk, currentActivity );
|
|
1223
1466
|
result.setListener( this );
|
|
1467
|
+
result.setRevenueListener( this );
|
|
1224
1468
|
|
|
1225
1469
|
mRewardedAds.put( adUnitId, result );
|
|
1226
1470
|
}
|
|
@@ -1240,6 +1484,7 @@ public class AppLovinMAXModule
|
|
|
1240
1484
|
{
|
|
1241
1485
|
result = new MaxAdView( adUnitId, adFormat, sdk, maybeGetCurrentActivity() );
|
|
1242
1486
|
result.setListener( this );
|
|
1487
|
+
result.setRevenueListener( this );
|
|
1243
1488
|
|
|
1244
1489
|
mAdViews.put( adUnitId, result );
|
|
1245
1490
|
mAdViewPositions.put( adUnitId, adViewPosition );
|
|
@@ -1326,8 +1571,6 @@ public class AppLovinMAXModule
|
|
|
1326
1571
|
adView.setTranslationX( 0 );
|
|
1327
1572
|
params.setMargins( 0, 0, 0, 0 );
|
|
1328
1573
|
|
|
1329
|
-
mVerticalAdViewFormats.remove( adUnitId );
|
|
1330
|
-
|
|
1331
1574
|
if ( "centered".equalsIgnoreCase( adViewPosition ) )
|
|
1332
1575
|
{
|
|
1333
1576
|
gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL;
|
|
@@ -1366,66 +1609,6 @@ public class AppLovinMAXModule
|
|
|
1366
1609
|
{
|
|
1367
1610
|
params.width = RelativeLayout.LayoutParams.MATCH_PARENT;
|
|
1368
1611
|
}
|
|
1369
|
-
|
|
1370
|
-
// Check if the publisher wants the ad view to be vertical and update the position accordingly ('CenterLeft' or 'CenterRight').
|
|
1371
|
-
final boolean containsLeft = adViewPosition.contains( "left" );
|
|
1372
|
-
final boolean containsRight = adViewPosition.contains( "right" );
|
|
1373
|
-
if ( containsLeft || containsRight )
|
|
1374
|
-
{
|
|
1375
|
-
// First, center the ad view in the view.
|
|
1376
|
-
gravity |= Gravity.CENTER_VERTICAL;
|
|
1377
|
-
|
|
1378
|
-
// For banners, set the width to the height of the screen to span the ad across the screen after it is rotated.
|
|
1379
|
-
// Android by default clips a view bounds if it goes over the size of the screen. We can overcome it by setting negative margins to match our required size.
|
|
1380
|
-
if ( MaxAdFormat.MREC == adFormat )
|
|
1381
|
-
{
|
|
1382
|
-
gravity |= adViewPosition.contains( "left" ) ? Gravity.LEFT : Gravity.RIGHT;
|
|
1383
|
-
}
|
|
1384
|
-
else
|
|
1385
|
-
{
|
|
1386
|
-
/* Align the center of the view such that when rotated it snaps into place.
|
|
1387
|
-
*
|
|
1388
|
-
* +---+---+-------+
|
|
1389
|
-
* | | |
|
|
1390
|
-
* | | |
|
|
1391
|
-
* | | |
|
|
1392
|
-
* | | |
|
|
1393
|
-
* | | |
|
|
1394
|
-
* | | |
|
|
1395
|
-
* +-------------+---+-----------+--+
|
|
1396
|
-
* | | + | + | |
|
|
1397
|
-
* +-------------+---+-----------+--+
|
|
1398
|
-
* | | |
|
|
1399
|
-
* | ^ | ^ |
|
|
1400
|
-
* | +-----+ |
|
|
1401
|
-
* Translation |
|
|
1402
|
-
* | | |
|
|
1403
|
-
* | | |
|
|
1404
|
-
* +---+-----------+
|
|
1405
|
-
*/
|
|
1406
|
-
|
|
1407
|
-
final int windowWidth = windowRect.width();
|
|
1408
|
-
final int windowHeight = windowRect.height();
|
|
1409
|
-
final int longSide = Math.max( windowWidth, windowHeight );
|
|
1410
|
-
final int shortSide = Math.min( windowWidth, windowHeight );
|
|
1411
|
-
final int margin = ( longSide - shortSide ) / 2;
|
|
1412
|
-
params.setMargins( -margin, 0, -margin, 0 );
|
|
1413
|
-
|
|
1414
|
-
// The view is now at the center of the screen and so is it's pivot point. Move its center such that when rotated, it snaps into the vertical position we need.
|
|
1415
|
-
final int translationRaw = ( windowWidth / 2 ) - ( heightPx / 2 );
|
|
1416
|
-
final int translationX = containsLeft ? -translationRaw : translationRaw;
|
|
1417
|
-
adView.setTranslationX( translationX );
|
|
1418
|
-
|
|
1419
|
-
// We have the view's center in the correct position. Now rotate it to snap into place.
|
|
1420
|
-
adView.setRotation( 270 );
|
|
1421
|
-
|
|
1422
|
-
// Store the ad view with format, so that it can be updated when the orientation changes.
|
|
1423
|
-
mVerticalAdViewFormats.put( adUnitId, adFormat );
|
|
1424
|
-
}
|
|
1425
|
-
|
|
1426
|
-
// Hack alert: For the rotation and translation to be applied correctly, need to set the background color (Unity only, similar to what we do in Cross Promo).
|
|
1427
|
-
relativeLayout.setBackgroundColor( Color.TRANSPARENT );
|
|
1428
|
-
}
|
|
1429
1612
|
}
|
|
1430
1613
|
else
|
|
1431
1614
|
{
|
|
@@ -1448,6 +1631,39 @@ public class AppLovinMAXModule
|
|
|
1448
1631
|
|
|
1449
1632
|
// Utility Methods
|
|
1450
1633
|
|
|
1634
|
+
private void logInvalidAdFormat(MaxAdFormat adFormat)
|
|
1635
|
+
{
|
|
1636
|
+
logStackTrace( new IllegalStateException( "invalid ad format: " + adFormat ) );
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
private void logStackTrace(Exception e)
|
|
1640
|
+
{
|
|
1641
|
+
e( Log.getStackTraceString( e ) );
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
private static void logUninitializedAccessError(final String callingMethod)
|
|
1645
|
+
{
|
|
1646
|
+
e( "ERROR: Failed to execute " + callingMethod + "() - please ensure the AppLovin MAX React Native module has been initialized by calling 'AppLovinMAX.initialize(...);'!" );
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
public static void d(final String message)
|
|
1650
|
+
{
|
|
1651
|
+
final String fullMessage = "[" + TAG + "] " + message;
|
|
1652
|
+
Log.d( SDK_TAG, fullMessage );
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
public static void w(final String message)
|
|
1656
|
+
{
|
|
1657
|
+
final String fullMessage = "[" + TAG + "] " + message;
|
|
1658
|
+
Log.w( SDK_TAG, fullMessage );
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
public static void e(final String message)
|
|
1662
|
+
{
|
|
1663
|
+
final String fullMessage = "[" + TAG + "] " + message;
|
|
1664
|
+
Log.e( SDK_TAG, fullMessage );
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1451
1667
|
private MaxAdFormat getDeviceSpecificBannerAdViewAdFormat()
|
|
1452
1668
|
{
|
|
1453
1669
|
return getDeviceSpecificBannerAdViewAdFormat( getReactApplicationContext() );
|
|
@@ -1490,6 +1706,13 @@ public class AppLovinMAXModule
|
|
|
1490
1706
|
}
|
|
1491
1707
|
}
|
|
1492
1708
|
|
|
1709
|
+
private static Point getOffsetPixels(final float xDp, final float yDp, final Context context)
|
|
1710
|
+
{
|
|
1711
|
+
return new Point( AppLovinSdkUtils.dpToPx( context, (int) xDp ), AppLovinSdkUtils.dpToPx( context, (int) yDp ) );
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
// AD INFO
|
|
1715
|
+
|
|
1493
1716
|
private WritableMap getAdInfo(final MaxAd ad)
|
|
1494
1717
|
{
|
|
1495
1718
|
WritableMap adInfo = Arguments.createMap();
|
|
@@ -1498,13 +1721,74 @@ public class AppLovinMAXModule
|
|
|
1498
1721
|
adInfo.putString( "networkName", ad.getNetworkName() );
|
|
1499
1722
|
adInfo.putString( "placement", !TextUtils.isEmpty( ad.getPlacement() ) ? ad.getPlacement() : "" );
|
|
1500
1723
|
adInfo.putDouble( "revenue", ad.getRevenue() );
|
|
1724
|
+
adInfo.putMap( "waterfall", createAdWaterfallInfo( ad.getWaterfall() ) );
|
|
1725
|
+
adInfo.putString( "dspName", !TextUtils.isEmpty( ad.getDspName() ) ? ad.getDspName() : "" );
|
|
1501
1726
|
|
|
1502
1727
|
return adInfo;
|
|
1503
1728
|
}
|
|
1504
1729
|
|
|
1505
|
-
|
|
1730
|
+
// AD WATERFALL INFO
|
|
1731
|
+
|
|
1732
|
+
private WritableMap createAdWaterfallInfo(final MaxAdWaterfallInfo waterfallInfo)
|
|
1506
1733
|
{
|
|
1507
|
-
|
|
1734
|
+
WritableMap waterfallInfoObject = Arguments.createMap();
|
|
1735
|
+
if ( waterfallInfo == null ) return waterfallInfoObject;
|
|
1736
|
+
|
|
1737
|
+
waterfallInfoObject.putString( "name", waterfallInfo.getName() );
|
|
1738
|
+
waterfallInfoObject.putString( "testName", waterfallInfo.getTestName() );
|
|
1739
|
+
|
|
1740
|
+
WritableArray networkResponsesArray = Arguments.createArray();
|
|
1741
|
+
for ( MaxNetworkResponseInfo response : waterfallInfo.getNetworkResponses() )
|
|
1742
|
+
{
|
|
1743
|
+
networkResponsesArray.pushMap( createNetworkResponseInfo( response ) );
|
|
1744
|
+
}
|
|
1745
|
+
waterfallInfoObject.putArray( "networkResponses", networkResponsesArray );
|
|
1746
|
+
|
|
1747
|
+
waterfallInfoObject.putDouble( "latencyMillis", waterfallInfo.getLatencyMillis() );
|
|
1748
|
+
|
|
1749
|
+
return waterfallInfoObject;
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
private WritableMap createNetworkResponseInfo(final MaxNetworkResponseInfo response)
|
|
1753
|
+
{
|
|
1754
|
+
WritableMap networkResponseObject = Arguments.createMap();
|
|
1755
|
+
networkResponseObject.putInt( "adLoadState", response.getAdLoadState().ordinal() );
|
|
1756
|
+
|
|
1757
|
+
MaxMediatedNetworkInfo mediatedNetworkInfo = response.getMediatedNetwork();
|
|
1758
|
+
if ( mediatedNetworkInfo != null )
|
|
1759
|
+
{
|
|
1760
|
+
WritableMap networkInfoObject = Arguments.createMap();
|
|
1761
|
+
networkInfoObject.putString( "name", mediatedNetworkInfo.getName() );
|
|
1762
|
+
networkInfoObject.putString( "adapterClassName", mediatedNetworkInfo.getAdapterClassName() );
|
|
1763
|
+
networkInfoObject.putString( "adapterVersion", mediatedNetworkInfo.getAdapterVersion() );
|
|
1764
|
+
networkInfoObject.putString( "sdkVersion", mediatedNetworkInfo.getSdkVersion() );
|
|
1765
|
+
|
|
1766
|
+
networkResponseObject.putMap( "mediatedNetwork", networkInfoObject );
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
Bundle credentialBundle = response.getCredentials();
|
|
1770
|
+
WritableMap credentials = Arguments.createMap();
|
|
1771
|
+
for ( String key : credentialBundle.keySet() )
|
|
1772
|
+
{
|
|
1773
|
+
String value = credentialBundle.getString( key, "" );
|
|
1774
|
+
credentials.putString( key, value );
|
|
1775
|
+
}
|
|
1776
|
+
networkResponseObject.putMap( "credentials", credentials );
|
|
1777
|
+
|
|
1778
|
+
MaxError error = response.getError();
|
|
1779
|
+
if ( error != null )
|
|
1780
|
+
{
|
|
1781
|
+
WritableMap errorObject = Arguments.createMap();
|
|
1782
|
+
errorObject.putString( "message", error.getMessage() );
|
|
1783
|
+
errorObject.putString( "adLoadFailureInfo", error.getAdLoadFailureInfo() );
|
|
1784
|
+
errorObject.putInt( "code", error.getCode() );
|
|
1785
|
+
|
|
1786
|
+
networkResponseObject.putMap( "error", errorObject );
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
networkResponseObject.putDouble( "latencyMillis", response.getLatencyMillis() );
|
|
1790
|
+
|
|
1791
|
+
return networkResponseObject;
|
|
1508
1792
|
}
|
|
1509
1793
|
|
|
1510
1794
|
// React Native Bridge
|
|
@@ -1516,7 +1800,8 @@ public class AppLovinMAXModule
|
|
|
1516
1800
|
.emit( name, params );
|
|
1517
1801
|
}
|
|
1518
1802
|
|
|
1519
|
-
@Override
|
|
1803
|
+
@Override
|
|
1804
|
+
@Nullable
|
|
1520
1805
|
public Map<String, Object> getConstants()
|
|
1521
1806
|
{
|
|
1522
1807
|
return super.getConstants();
|