react-native-applovin-max 3.3.1 → 4.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.
- package/android/build.gradle +3 -3
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdView.java +52 -1
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXModule.java +223 -79
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdView.java +416 -0
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdViewManager.java +148 -0
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXPackage.java +2 -1
- package/ios/AppLovinMAX.h +5 -0
- package/ios/AppLovinMAX.m +233 -57
- package/ios/AppLovinMAX.xcodeproj/project.pbxproj +14 -2
- package/ios/AppLovinMAX.xcworkspace/xcuserdata/thomasso.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/AppLovinMAXAdView.h +7 -0
- package/ios/AppLovinMAXAdView.m +50 -2
- package/ios/AppLovinMAXNativeAdView.h +27 -0
- package/ios/AppLovinMAXNativeAdView.m +343 -0
- package/ios/AppLovinMAXNativeAdViewManager.h +19 -0
- package/ios/AppLovinMAXNativeAdViewManager.m +60 -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 +1 -1
- package/src/NativeAdComponents.js +156 -0
- package/src/NativeAdView.js +118 -0
- package/src/NativeAdViewProvider.js +19 -0
- package/src/TargetingData.js +1 -1
- package/src/index.js +383 -55
package/ios/AppLovinMAX.m
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
//
|
|
8
8
|
|
|
9
9
|
#import "AppLovinMAX.h"
|
|
10
|
+
#import "AppLovinMAXNativeAdView.h"
|
|
10
11
|
|
|
11
12
|
#define ROOT_VIEW_CONTROLLER (UIApplication.sharedApplication.keyWindow.rootViewController)
|
|
12
13
|
|
|
@@ -47,9 +48,18 @@
|
|
|
47
48
|
@property (nonatomic, strong, nullable) NSURL *privacyPolicyURLToSet;
|
|
48
49
|
@property (nonatomic, strong, nullable) NSURL *termsOfServiceURLToSet;
|
|
49
50
|
|
|
51
|
+
@property (nonatomic, strong, nullable) NSNumber *targetingYearOfBirthToSet;
|
|
52
|
+
@property (nonatomic, copy, nullable) NSString *targetingGenderToSet;
|
|
53
|
+
@property (nonatomic, strong, nullable) NSNumber *targetingMaximumAdContentRatingToSet;
|
|
54
|
+
@property (nonatomic, copy, nullable) NSString *targetingEmailToSet;
|
|
55
|
+
@property (nonatomic, copy, nullable) NSString *targetingPhoneNumberToSet;
|
|
56
|
+
@property (nonatomic, strong, nullable) NSArray<NSString *> *targetingKeywordsToSet;
|
|
57
|
+
@property (nonatomic, strong, nullable) NSArray<NSString *> *targetingInterestsToSet;
|
|
58
|
+
|
|
50
59
|
// Fullscreen Ad Fields
|
|
51
60
|
@property (nonatomic, strong) NSMutableDictionary<NSString *, MAInterstitialAd *> *interstitials;
|
|
52
61
|
@property (nonatomic, strong) NSMutableDictionary<NSString *, MARewardedAd *> *rewardedAds;
|
|
62
|
+
@property (nonatomic, strong) NSMutableDictionary<NSString *, MAAppOpenAd *> *appOpenAds;
|
|
53
63
|
|
|
54
64
|
// Banner Fields
|
|
55
65
|
@property (nonatomic, strong) NSMutableDictionary<NSString *, MAAdView *> *adViews;
|
|
@@ -104,6 +114,7 @@ RCT_EXPORT_MODULE()
|
|
|
104
114
|
self.interstitials = [NSMutableDictionary dictionaryWithCapacity: 2];
|
|
105
115
|
self.rewardedAds = [NSMutableDictionary dictionaryWithCapacity: 2];
|
|
106
116
|
self.adViews = [NSMutableDictionary dictionaryWithCapacity: 2];
|
|
117
|
+
self.appOpenAds = [NSMutableDictionary dictionaryWithCapacity: 2];
|
|
107
118
|
self.adViewAdFormats = [NSMutableDictionary dictionaryWithCapacity: 2];
|
|
108
119
|
self.adViewPositions = [NSMutableDictionary dictionaryWithCapacity: 2];
|
|
109
120
|
self.adViewOffsets = [NSMutableDictionary dictionaryWithCapacity: 2];
|
|
@@ -204,11 +215,53 @@ RCT_EXPORT_METHOD(initialize:(NSString *)pluginVersion :(NSString *)sdkKey :(RCT
|
|
|
204
215
|
self.sdk.settings.locationCollectionEnabled = self.locationCollectionEnabledToSet.boolValue;
|
|
205
216
|
self.locationCollectionEnabledToSet = nil;
|
|
206
217
|
}
|
|
207
|
-
|
|
218
|
+
|
|
219
|
+
if ( self.targetingYearOfBirthToSet )
|
|
220
|
+
{
|
|
221
|
+
self.sdk.targetingData.yearOfBirth = self.targetingYearOfBirthToSet.intValue <= 0 ? nil : self.targetingYearOfBirthToSet;
|
|
222
|
+
self.targetingYearOfBirthToSet = nil;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if ( self.targetingGenderToSet )
|
|
226
|
+
{
|
|
227
|
+
self.sdk.targetingData.gender = [self toAppLovinGender: self.targetingGenderToSet];
|
|
228
|
+
self.targetingGenderToSet = nil;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if ( self.targetingMaximumAdContentRatingToSet )
|
|
232
|
+
{
|
|
233
|
+
self.sdk.targetingData.maximumAdContentRating = [self toAppLovinAdContentRating: self.targetingMaximumAdContentRatingToSet];
|
|
234
|
+
self.targetingMaximumAdContentRatingToSet = nil;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if ( self.targetingEmailToSet )
|
|
238
|
+
{
|
|
239
|
+
self.sdk.targetingData.email = self.targetingEmailToSet;
|
|
240
|
+
self.targetingEmailToSet = nil;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if ( self.targetingPhoneNumberToSet )
|
|
244
|
+
{
|
|
245
|
+
self.sdk.targetingData.phoneNumber = self.targetingPhoneNumberToSet;
|
|
246
|
+
self.targetingPhoneNumberToSet = nil;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if ( self.targetingKeywordsToSet )
|
|
250
|
+
{
|
|
251
|
+
self.sdk.targetingData.keywords = self.targetingKeywordsToSet;
|
|
252
|
+
self.targetingKeywordsToSet = nil;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if ( self.targetingInterestsToSet )
|
|
256
|
+
{
|
|
257
|
+
self.sdk.targetingData.interests = self.targetingInterestsToSet;
|
|
258
|
+
self.targetingInterestsToSet = nil;
|
|
259
|
+
}
|
|
260
|
+
|
|
208
261
|
[self setPendingExtraParametersIfNeeded: self.sdk.settings];
|
|
209
262
|
|
|
210
|
-
[self.sdk initializeSdkWithCompletionHandler:^(ALSdkConfiguration *configuration)
|
|
211
|
-
|
|
263
|
+
[self.sdk initializeSdkWithCompletionHandler:^(ALSdkConfiguration *configuration) {
|
|
264
|
+
|
|
212
265
|
[self log: @"SDK initialized"];
|
|
213
266
|
|
|
214
267
|
self.sdkConfiguration = configuration;
|
|
@@ -388,7 +441,7 @@ RCT_EXPORT_METHOD(setTargetingDataYearOfBirth:(nonnull NSNumber *)yearOfBirth)
|
|
|
388
441
|
{
|
|
389
442
|
if ( !self.sdk )
|
|
390
443
|
{
|
|
391
|
-
|
|
444
|
+
self.targetingYearOfBirthToSet = yearOfBirth;
|
|
392
445
|
return;
|
|
393
446
|
}
|
|
394
447
|
|
|
@@ -399,61 +452,29 @@ RCT_EXPORT_METHOD(setTargetingDataGender:(nullable NSString *)gender)
|
|
|
399
452
|
{
|
|
400
453
|
if ( !self.sdk )
|
|
401
454
|
{
|
|
402
|
-
|
|
455
|
+
self.targetingGenderToSet = gender;
|
|
403
456
|
return;
|
|
404
457
|
}
|
|
405
458
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
if ( [@"F" isEqualToString: gender] )
|
|
409
|
-
{
|
|
410
|
-
alGender = ALGenderFemale;
|
|
411
|
-
}
|
|
412
|
-
else if ( [@"M" isEqualToString: gender] )
|
|
413
|
-
{
|
|
414
|
-
alGender = ALGenderMale;
|
|
415
|
-
}
|
|
416
|
-
else if ( [@"O" isEqualToString: gender] )
|
|
417
|
-
{
|
|
418
|
-
alGender = ALGenderOther;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
self.sdk.targetingData.gender = alGender;
|
|
459
|
+
self.sdk.targetingData.gender = [self toAppLovinGender: gender];
|
|
422
460
|
}
|
|
423
461
|
|
|
424
462
|
RCT_EXPORT_METHOD(setTargetingDataMaximumAdContentRating:(nonnull NSNumber *)maximumAdContentRating)
|
|
425
463
|
{
|
|
426
464
|
if ( !self.sdk )
|
|
427
465
|
{
|
|
428
|
-
|
|
466
|
+
self.targetingMaximumAdContentRatingToSet = maximumAdContentRating;
|
|
429
467
|
return;
|
|
430
468
|
}
|
|
431
469
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
int intVal = maximumAdContentRating.intValue;
|
|
435
|
-
|
|
436
|
-
if ( intVal == 1 )
|
|
437
|
-
{
|
|
438
|
-
rating = ALAdContentRatingAllAudiences;
|
|
439
|
-
}
|
|
440
|
-
else if ( intVal == 2 )
|
|
441
|
-
{
|
|
442
|
-
rating = ALAdContentRatingEveryoneOverTwelve;
|
|
443
|
-
}
|
|
444
|
-
else if ( intVal == 3 )
|
|
445
|
-
{
|
|
446
|
-
rating = ALAdContentRatingMatureAudiences;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
self.sdk.targetingData.maximumAdContentRating = rating;
|
|
470
|
+
self.sdk.targetingData.maximumAdContentRating = [self toAppLovinAdContentRating: maximumAdContentRating];
|
|
450
471
|
}
|
|
451
472
|
|
|
452
473
|
RCT_EXPORT_METHOD(setTargetingDataEmail:(nullable NSString *)email)
|
|
453
474
|
{
|
|
454
475
|
if ( !self.sdk )
|
|
455
476
|
{
|
|
456
|
-
|
|
477
|
+
self.targetingEmailToSet = email;
|
|
457
478
|
return;
|
|
458
479
|
}
|
|
459
480
|
|
|
@@ -464,7 +485,7 @@ RCT_EXPORT_METHOD(setTargetingDataPhoneNumber:(nullable NSString *)phoneNumber)
|
|
|
464
485
|
{
|
|
465
486
|
if ( !self.sdk )
|
|
466
487
|
{
|
|
467
|
-
|
|
488
|
+
self.targetingPhoneNumberToSet = phoneNumber;
|
|
468
489
|
return;
|
|
469
490
|
}
|
|
470
491
|
|
|
@@ -475,7 +496,7 @@ RCT_EXPORT_METHOD(setTargetingDataKeywords:(nullable NSArray<NSString *> *)keywo
|
|
|
475
496
|
{
|
|
476
497
|
if ( !self.sdk )
|
|
477
498
|
{
|
|
478
|
-
|
|
499
|
+
self.targetingKeywordsToSet = keywords;
|
|
479
500
|
return;
|
|
480
501
|
}
|
|
481
502
|
|
|
@@ -486,7 +507,7 @@ RCT_EXPORT_METHOD(setTargetingDataInterests:(nullable NSArray<NSString *> *)inte
|
|
|
486
507
|
{
|
|
487
508
|
if ( !self.sdk )
|
|
488
509
|
{
|
|
489
|
-
|
|
510
|
+
self.targetingInterestsToSet = interests;
|
|
490
511
|
return;
|
|
491
512
|
}
|
|
492
513
|
|
|
@@ -497,7 +518,13 @@ RCT_EXPORT_METHOD(clearAllTargetingData)
|
|
|
497
518
|
{
|
|
498
519
|
if ( !self.sdk )
|
|
499
520
|
{
|
|
500
|
-
|
|
521
|
+
self.targetingYearOfBirthToSet = nil;
|
|
522
|
+
self.targetingGenderToSet = nil;
|
|
523
|
+
self.targetingMaximumAdContentRatingToSet = nil;
|
|
524
|
+
self.targetingEmailToSet = nil;
|
|
525
|
+
self.targetingPhoneNumberToSet = nil;
|
|
526
|
+
self.targetingKeywordsToSet = nil;
|
|
527
|
+
self.targetingInterestsToSet = nil;
|
|
501
528
|
return;
|
|
502
529
|
}
|
|
503
530
|
|
|
@@ -701,6 +728,32 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
701
728
|
[rewardedAd setExtraParameterForKey: key value: value];
|
|
702
729
|
}
|
|
703
730
|
|
|
731
|
+
#pragma mark - App Open Ad
|
|
732
|
+
|
|
733
|
+
RCT_EXPORT_METHOD(loadAppOpenAd:(NSString *)adUnitIdentifier)
|
|
734
|
+
{
|
|
735
|
+
MAAppOpenAd *appOpenAd = [self retrieveAppOpenAdForAdUnitIdentifier: adUnitIdentifier];
|
|
736
|
+
[appOpenAd loadAd];
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(isAppOpenAdReady:(NSString *)adUnitIdentifier)
|
|
740
|
+
{
|
|
741
|
+
MAAppOpenAd *appOpenAd = [self retrieveAppOpenAdForAdUnitIdentifier: adUnitIdentifier];
|
|
742
|
+
return @([appOpenAd isReady]);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
RCT_EXPORT_METHOD(showAppOpenAd:(NSString *)adUnitIdentifier placement:(nullable NSString *)placement customData:(nullable NSString *)customData)
|
|
746
|
+
{
|
|
747
|
+
MAAppOpenAd *appOpenAd = [self retrieveAppOpenAdForAdUnitIdentifier: adUnitIdentifier];
|
|
748
|
+
[appOpenAd showAdForPlacement: placement customData: customData];
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
RCT_EXPORT_METHOD(setAppOpenAdExtraParameter:(NSString *)adUnitIdentifier key:(NSString *)key value:(nullable NSString *)value)
|
|
752
|
+
{
|
|
753
|
+
MAAppOpenAd *appOpenAd = [self retrieveAppOpenAdForAdUnitIdentifier: adUnitIdentifier];
|
|
754
|
+
[appOpenAd setExtraParameterForKey: key value: value];
|
|
755
|
+
}
|
|
756
|
+
|
|
704
757
|
#pragma mark - Ad Callbacks
|
|
705
758
|
|
|
706
759
|
- (void)didLoadAd:(MAAd *)ad
|
|
@@ -731,6 +784,14 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
731
784
|
{
|
|
732
785
|
name = @"OnRewardedAdLoadedEvent";
|
|
733
786
|
}
|
|
787
|
+
else if ( MAAdFormat.native == adFormat )
|
|
788
|
+
{
|
|
789
|
+
name = @"OnNativeAdLoadedEvent";
|
|
790
|
+
}
|
|
791
|
+
else if ( MAAdFormat.appOpen == adFormat )
|
|
792
|
+
{
|
|
793
|
+
name = @"OnAppOpenAdLoadedEvent";
|
|
794
|
+
}
|
|
734
795
|
else
|
|
735
796
|
{
|
|
736
797
|
[self logInvalidAdFormat: adFormat];
|
|
@@ -740,6 +801,21 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
740
801
|
[self sendReactNativeEventWithName: name body: [self adInfoForAd: ad]];
|
|
741
802
|
}
|
|
742
803
|
|
|
804
|
+
- (void)sendReactNativeEventForAdLoadFailed:(NSString *)name forAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(nullable MAError *)error
|
|
805
|
+
{
|
|
806
|
+
NSDictionary *body = ( error ) ?
|
|
807
|
+
@{@"adUnitId": adUnitIdentifier,
|
|
808
|
+
@"code" : @(error.code),
|
|
809
|
+
@"message" : error.message,
|
|
810
|
+
@"adLoadFailureInfo" : error.adLoadFailureInfo ?: @"",
|
|
811
|
+
@"waterfall": [self createAdWaterfallInfo: error.waterfall]}
|
|
812
|
+
:
|
|
813
|
+
@{@"adUnitId": adUnitIdentifier,
|
|
814
|
+
@"code" : @(MAErrorCodeUnspecified)};
|
|
815
|
+
|
|
816
|
+
[self sendReactNativeEventWithName: name body: body];
|
|
817
|
+
}
|
|
818
|
+
|
|
743
819
|
- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error
|
|
744
820
|
{
|
|
745
821
|
if ( !adUnitIdentifier )
|
|
@@ -761,17 +837,17 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
761
837
|
{
|
|
762
838
|
name = @"OnRewardedAdLoadFailedEvent";
|
|
763
839
|
}
|
|
840
|
+
else if ( self.appOpenAds[adUnitIdentifier] )
|
|
841
|
+
{
|
|
842
|
+
name = @"OnAppOpenAdLoadFailedEvent";
|
|
843
|
+
}
|
|
764
844
|
else
|
|
765
845
|
{
|
|
766
846
|
[self log: @"invalid adUnitId from %@", [NSThread callStackSymbols]];
|
|
767
847
|
return;
|
|
768
848
|
}
|
|
769
849
|
|
|
770
|
-
[self
|
|
771
|
-
@"code" : @(error.code),
|
|
772
|
-
@"message" : error.message,
|
|
773
|
-
@"adLoadFailureInfo" : error.adLoadFailureInfo ?: @"",
|
|
774
|
-
@"waterfall": [self createAdWaterfallInfo: error.waterfall]}];
|
|
850
|
+
[self sendReactNativeEventForAdLoadFailed: name forAdUnitIdentifier: adUnitIdentifier withError: error];
|
|
775
851
|
}
|
|
776
852
|
|
|
777
853
|
- (void)didClickAd:(MAAd *)ad
|
|
@@ -794,6 +870,14 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
794
870
|
{
|
|
795
871
|
name = @"OnRewardedAdClickedEvent";
|
|
796
872
|
}
|
|
873
|
+
else if ( MAAdFormat.native == adFormat )
|
|
874
|
+
{
|
|
875
|
+
name = @"OnNativeAdClickedEvent";
|
|
876
|
+
}
|
|
877
|
+
else if ( MAAdFormat.appOpen == adFormat )
|
|
878
|
+
{
|
|
879
|
+
name = @"OnAppOpenAdClickedEvent";
|
|
880
|
+
}
|
|
797
881
|
else
|
|
798
882
|
{
|
|
799
883
|
[self logInvalidAdFormat: adFormat];
|
|
@@ -807,17 +891,21 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
807
891
|
{
|
|
808
892
|
// BMLs do not support [DISPLAY] events in Unity
|
|
809
893
|
MAAdFormat *adFormat = ad.format;
|
|
810
|
-
if ( adFormat != MAAdFormat.interstitial && adFormat != MAAdFormat.rewarded ) return;
|
|
894
|
+
if ( adFormat != MAAdFormat.interstitial && adFormat != MAAdFormat.rewarded && adFormat != MAAdFormat.appOpen ) return;
|
|
811
895
|
|
|
812
896
|
NSString *name;
|
|
813
897
|
if ( MAAdFormat.interstitial == adFormat )
|
|
814
898
|
{
|
|
815
899
|
name = @"OnInterstitialDisplayedEvent";
|
|
816
900
|
}
|
|
817
|
-
else
|
|
901
|
+
else if ( MAAdFormat.rewarded == adFormat )
|
|
818
902
|
{
|
|
819
903
|
name = @"OnRewardedAdDisplayedEvent";
|
|
820
904
|
}
|
|
905
|
+
else // APP OPEN
|
|
906
|
+
{
|
|
907
|
+
name = @"OnAppOpenAdDisplayedEvent";
|
|
908
|
+
}
|
|
821
909
|
|
|
822
910
|
[self sendReactNativeEventWithName: name body: [self adInfoForAd: ad]];
|
|
823
911
|
}
|
|
@@ -826,17 +914,21 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
826
914
|
{
|
|
827
915
|
// BMLs do not support [DISPLAY] events in Unity
|
|
828
916
|
MAAdFormat *adFormat = ad.format;
|
|
829
|
-
if ( adFormat != MAAdFormat.interstitial && adFormat != MAAdFormat.rewarded ) return;
|
|
917
|
+
if ( adFormat != MAAdFormat.interstitial && adFormat != MAAdFormat.rewarded && adFormat != MAAdFormat.appOpen ) return;
|
|
830
918
|
|
|
831
919
|
NSString *name;
|
|
832
920
|
if ( MAAdFormat.interstitial == adFormat )
|
|
833
921
|
{
|
|
834
922
|
name = @"OnInterstitialAdFailedToDisplayEvent";
|
|
835
923
|
}
|
|
836
|
-
else
|
|
924
|
+
else if ( MAAdFormat.rewarded == adFormat )
|
|
837
925
|
{
|
|
838
926
|
name = @"OnRewardedAdFailedToDisplayEvent";
|
|
839
927
|
}
|
|
928
|
+
else // APP OPEN
|
|
929
|
+
{
|
|
930
|
+
name = @"OnAppOpenAdFailedToDisplayEvent";
|
|
931
|
+
}
|
|
840
932
|
|
|
841
933
|
NSMutableDictionary *body = [@{@"code" : @(error.code),
|
|
842
934
|
@"message" : error.message} mutableCopy];
|
|
@@ -849,17 +941,21 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
849
941
|
{
|
|
850
942
|
// BMLs do not support [HIDDEN] events in Unity
|
|
851
943
|
MAAdFormat *adFormat = ad.format;
|
|
852
|
-
if ( adFormat != MAAdFormat.interstitial && adFormat != MAAdFormat.rewarded ) return;
|
|
944
|
+
if ( adFormat != MAAdFormat.interstitial && adFormat != MAAdFormat.rewarded && adFormat != MAAdFormat.appOpen ) return;
|
|
853
945
|
|
|
854
946
|
NSString *name;
|
|
855
947
|
if ( MAAdFormat.interstitial == adFormat )
|
|
856
948
|
{
|
|
857
949
|
name = @"OnInterstitialHiddenEvent";
|
|
858
950
|
}
|
|
859
|
-
else
|
|
951
|
+
else if ( MAAdFormat.rewarded == adFormat )
|
|
860
952
|
{
|
|
861
953
|
name = @"OnRewardedAdHiddenEvent";
|
|
862
954
|
}
|
|
955
|
+
else // APP OPEN
|
|
956
|
+
{
|
|
957
|
+
name = @"OnAppOpenAdHiddenEvent";
|
|
958
|
+
}
|
|
863
959
|
|
|
864
960
|
[self sendReactNativeEventWithName: name body: [self adInfoForAd: ad]];
|
|
865
961
|
}
|
|
@@ -910,6 +1006,14 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
910
1006
|
{
|
|
911
1007
|
name = @"OnRewardedAdRevenuePaid";
|
|
912
1008
|
}
|
|
1009
|
+
else if ( MAAdFormat.native == adFormat )
|
|
1010
|
+
{
|
|
1011
|
+
name = @"OnNativeAdRevenuePaid";
|
|
1012
|
+
}
|
|
1013
|
+
else if ( MAAdFormat.appOpen == adFormat )
|
|
1014
|
+
{
|
|
1015
|
+
name = @"OnAppOpenAdRevenuePaid";
|
|
1016
|
+
}
|
|
913
1017
|
else
|
|
914
1018
|
{
|
|
915
1019
|
[self logInvalidAdFormat: adFormat];
|
|
@@ -1205,6 +1309,21 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
1205
1309
|
return result;
|
|
1206
1310
|
}
|
|
1207
1311
|
|
|
1312
|
+
- (MAAppOpenAd *)retrieveAppOpenAdForAdUnitIdentifier:(NSString *)adUnitIdentifier
|
|
1313
|
+
{
|
|
1314
|
+
MAAppOpenAd *result = self.appOpenAds[adUnitIdentifier];
|
|
1315
|
+
if ( !result )
|
|
1316
|
+
{
|
|
1317
|
+
result = [[MAAppOpenAd alloc] initWithAdUnitIdentifier: adUnitIdentifier sdk: self.sdk];
|
|
1318
|
+
result.delegate = self;
|
|
1319
|
+
result.revenueDelegate = self;
|
|
1320
|
+
|
|
1321
|
+
self.appOpenAds[adUnitIdentifier] = result;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
return result;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1208
1327
|
- (MAAdView *)retrieveAdViewForAdUnitIdentifier:(NSString *)adUnitIdentifier adFormat:(MAAdFormat *)adFormat
|
|
1209
1328
|
{
|
|
1210
1329
|
return [self retrieveAdViewForAdUnitIdentifier: adUnitIdentifier adFormat: adFormat atPosition: nil withOffset: CGPointZero];
|
|
@@ -1460,6 +1579,50 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
1460
1579
|
NSLog(@"[%@] [%@] %@", SDK_TAG, TAG, message);
|
|
1461
1580
|
}
|
|
1462
1581
|
|
|
1582
|
+
- (ALGender)toAppLovinGender:(nullable NSString *)gender
|
|
1583
|
+
{
|
|
1584
|
+
if ( gender )
|
|
1585
|
+
{
|
|
1586
|
+
if ( [@"F" al_isEqualToStringIgnoringCase: gender] )
|
|
1587
|
+
{
|
|
1588
|
+
return ALGenderFemale;
|
|
1589
|
+
}
|
|
1590
|
+
else if ( [@"M" al_isEqualToStringIgnoringCase: gender] )
|
|
1591
|
+
{
|
|
1592
|
+
return ALGenderMale;
|
|
1593
|
+
}
|
|
1594
|
+
else if ( [@"O" al_isEqualToStringIgnoringCase: gender] )
|
|
1595
|
+
{
|
|
1596
|
+
return ALGenderOther;
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
return ALGenderUnknown;
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
- (ALAdContentRating)toAppLovinAdContentRating:(nullable NSNumber *)maximumAdContentRating
|
|
1604
|
+
{
|
|
1605
|
+
if ( maximumAdContentRating )
|
|
1606
|
+
{
|
|
1607
|
+
int intVal = maximumAdContentRating.intValue;
|
|
1608
|
+
|
|
1609
|
+
if ( intVal == 1 )
|
|
1610
|
+
{
|
|
1611
|
+
return ALAdContentRatingAllAudiences;
|
|
1612
|
+
}
|
|
1613
|
+
else if ( intVal == 2 )
|
|
1614
|
+
{
|
|
1615
|
+
return ALAdContentRatingEveryoneOverTwelve;
|
|
1616
|
+
}
|
|
1617
|
+
else if ( intVal == 3 )
|
|
1618
|
+
{
|
|
1619
|
+
return ALAdContentRatingMatureAudiences;
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
return ALAdContentRatingNone;
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1463
1626
|
#pragma mark - Ad Info
|
|
1464
1627
|
|
|
1465
1628
|
- (NSDictionary<NSString *, id> *)adInfoForAd:(MAAd *)ad
|
|
@@ -1574,7 +1737,20 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
1574
1737
|
@"OnRewardedAdFailedToDisplayEvent",
|
|
1575
1738
|
@"OnRewardedAdHiddenEvent",
|
|
1576
1739
|
@"OnRewardedAdReceivedRewardEvent",
|
|
1577
|
-
@"OnRewardedAdRevenuePaid"
|
|
1740
|
+
@"OnRewardedAdRevenuePaid",
|
|
1741
|
+
|
|
1742
|
+
@"OnAppOpenAdLoadedEvent",
|
|
1743
|
+
@"OnAppOpenAdLoadFailedEvent",
|
|
1744
|
+
@"OnAppOpenAdClickedEvent",
|
|
1745
|
+
@"OnAppOpenAdDisplayedEvent",
|
|
1746
|
+
@"OnAppOpenAdFailedToDisplayEvent",
|
|
1747
|
+
@"OnAppOpenAdHiddenEvent",
|
|
1748
|
+
@"OnAppOpenAdRevenuePaid",
|
|
1749
|
+
|
|
1750
|
+
@"OnNativeAdLoadedEvent",
|
|
1751
|
+
@"OnNativeAdLoadFailedEvent",
|
|
1752
|
+
@"OnNativeAdClickedEvent",
|
|
1753
|
+
@"OnNativeAdRevenuePaid"];
|
|
1578
1754
|
}
|
|
1579
1755
|
|
|
1580
1756
|
- (void)startObserving
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
1D2890F5251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D2890F4251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m */; };
|
|
11
11
|
1D3CC34128C18441003E5A07 /* AppLovinMAXAdView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3CC34028C18441003E5A07 /* AppLovinMAXAdView.m */; };
|
|
12
12
|
1DEA13CD24B9258700D42847 /* AppLovinMAX.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DEA13CC24B9258700D42847 /* AppLovinMAX.m */; };
|
|
13
|
+
7A47215228D8968100854002 /* AppLovinMAXNativeAdViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A47214F28D8968100854002 /* AppLovinMAXNativeAdViewManager.m */; };
|
|
14
|
+
7A47215728D8968800854002 /* AppLovinMAXNativeAdView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A47215328D8968800854002 /* AppLovinMAXNativeAdView.m */; };
|
|
13
15
|
DE4E5A3D46DDFAE766DFFE58 /* libPods-AppLovinMAX.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EF1B4EBC7187611714984C78 /* libPods-AppLovinMAX.a */; };
|
|
14
16
|
/* End PBXBuildFile section */
|
|
15
17
|
|
|
@@ -33,6 +35,10 @@
|
|
|
33
35
|
1D3CC33F28C18440003E5A07 /* AppLovinMAXAdView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppLovinMAXAdView.h; sourceTree = "<group>"; };
|
|
34
36
|
1D3CC34028C18441003E5A07 /* AppLovinMAXAdView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppLovinMAXAdView.m; sourceTree = "<group>"; };
|
|
35
37
|
1DEA13CC24B9258700D42847 /* AppLovinMAX.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppLovinMAX.m; sourceTree = "<group>"; };
|
|
38
|
+
7A47214F28D8968100854002 /* AppLovinMAXNativeAdViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppLovinMAXNativeAdViewManager.m; sourceTree = "<group>"; };
|
|
39
|
+
7A47215128D8968100854002 /* AppLovinMAXNativeAdViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppLovinMAXNativeAdViewManager.h; sourceTree = "<group>"; };
|
|
40
|
+
7A47215328D8968800854002 /* AppLovinMAXNativeAdView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppLovinMAXNativeAdView.m; sourceTree = "<group>"; };
|
|
41
|
+
7A47215428D8968800854002 /* AppLovinMAXNativeAdView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppLovinMAXNativeAdView.h; sourceTree = "<group>"; };
|
|
36
42
|
B3E7B5881CC2AC0600A0062D /* AppLovinMAX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppLovinMAX.h; sourceTree = "<group>"; };
|
|
37
43
|
EF1B4EBC7187611714984C78 /* libPods-AppLovinMAX.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AppLovinMAX.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
38
44
|
F80C453A02323F11AB9FD612 /* Pods-AppLovinMAX.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AppLovinMAX.release.xcconfig"; path = "Target Support Files/Pods-AppLovinMAX/Pods-AppLovinMAX.release.xcconfig"; sourceTree = "<group>"; };
|
|
@@ -75,9 +81,13 @@
|
|
|
75
81
|
1D3CC34028C18441003E5A07 /* AppLovinMAXAdView.m */,
|
|
76
82
|
1D2890F3251ABC83004F1CC4 /* AppLovinMAXAdViewManager.h */,
|
|
77
83
|
1D2890F4251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m */,
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
7A47215428D8968800854002 /* AppLovinMAXNativeAdView.h */,
|
|
85
|
+
7A47215328D8968800854002 /* AppLovinMAXNativeAdView.m */,
|
|
86
|
+
7A47215128D8968100854002 /* AppLovinMAXNativeAdViewManager.h */,
|
|
87
|
+
7A47214F28D8968100854002 /* AppLovinMAXNativeAdViewManager.m */,
|
|
80
88
|
1E696A0F28A9ED7C75EC4EC0 /* Frameworks */,
|
|
89
|
+
B20EE642686C6BAEB6C5B87A /* Pods */,
|
|
90
|
+
134814211AA4EA7D00B7C361 /* Products */,
|
|
81
91
|
);
|
|
82
92
|
sourceTree = "<group>";
|
|
83
93
|
};
|
|
@@ -173,7 +183,9 @@
|
|
|
173
183
|
isa = PBXSourcesBuildPhase;
|
|
174
184
|
buildActionMask = 2147483647;
|
|
175
185
|
files = (
|
|
186
|
+
7A47215228D8968100854002 /* AppLovinMAXNativeAdViewManager.m in Sources */,
|
|
176
187
|
1D2890F5251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m in Sources */,
|
|
188
|
+
7A47215728D8968800854002 /* AppLovinMAXNativeAdView.m in Sources */,
|
|
177
189
|
1D3CC34128C18441003E5A07 /* AppLovinMAXAdView.m in Sources */,
|
|
178
190
|
1DEA13CD24B9258700D42847 /* AppLovinMAX.m in Sources */,
|
|
179
191
|
);
|
package/ios/AppLovinMAX.xcworkspace/xcuserdata/thomasso.xcuserdatad/UserInterfaceState.xcuserstate
CHANGED
|
Binary file
|
package/ios/AppLovinMAXAdView.h
CHANGED
package/ios/AppLovinMAXAdView.m
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AppLovinMAXAdView.m
|
|
3
|
+
// AppLovin MAX React Native Module
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2022 AppLovin. All rights reserved.
|
|
6
|
+
//
|
|
7
|
+
|
|
1
8
|
#import <AppLovinSDK/AppLovinSDK.h>
|
|
2
9
|
#import "AppLovinMAX.h"
|
|
3
10
|
#import "AppLovinMAXAdView.h"
|
|
4
11
|
|
|
5
|
-
@interface AppLovinMAXAdView()
|
|
12
|
+
@interface AppLovinMAXAdView()<MAAdViewAdDelegate>
|
|
6
13
|
|
|
7
14
|
@property (nonatomic, strong, nullable) MAAdView *adView; // nil when unmounted
|
|
8
15
|
|
|
@@ -138,7 +145,7 @@
|
|
|
138
145
|
adFormat: adFormat
|
|
139
146
|
sdk: [AppLovinMAX shared].sdk];
|
|
140
147
|
self.adView.frame = (CGRect) { CGPointZero, self.frame.size };
|
|
141
|
-
self.adView.delegate =
|
|
148
|
+
self.adView.delegate = self;
|
|
142
149
|
self.adView.revenueDelegate = [AppLovinMAX shared];
|
|
143
150
|
self.adView.placement = self.placement;
|
|
144
151
|
self.adView.customData = self.customData;
|
|
@@ -187,4 +194,45 @@
|
|
|
187
194
|
}
|
|
188
195
|
}
|
|
189
196
|
|
|
197
|
+
#pragma mark - MAAdDelegate Protocol
|
|
198
|
+
|
|
199
|
+
- (void)didLoadAd:(MAAd *)ad
|
|
200
|
+
{
|
|
201
|
+
[[AppLovinMAX shared] didLoadAd: ad];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error
|
|
205
|
+
{
|
|
206
|
+
NSString *name = ( MAAdFormat.mrec == self.adFormat ) ? @"OnMRecAdLoadFailedEvent" : @"OnBannerAdLoadFailedEvent";
|
|
207
|
+
|
|
208
|
+
[[AppLovinMAX shared] sendReactNativeEventForAdLoadFailed: name forAdUnitIdentifier: adUnitIdentifier withError: error];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
- (void)didFailToDisplayAd:(MAAd *)ad withError:(MAError *)error
|
|
212
|
+
{
|
|
213
|
+
[[AppLovinMAX shared] didFailToDisplayAd: ad withError: error];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
- (void)didClickAd:(MAAd *)ad
|
|
217
|
+
{
|
|
218
|
+
[[AppLovinMAX shared] didClickAd: ad];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
#pragma mark - MAAdViewAdDelegate Protocol
|
|
222
|
+
|
|
223
|
+
- (void)didExpandAd:(MAAd *)ad
|
|
224
|
+
{
|
|
225
|
+
[[AppLovinMAX shared] didExpandAd: ad];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
- (void)didCollapseAd:(MAAd *)ad
|
|
229
|
+
{
|
|
230
|
+
[[AppLovinMAX shared] didCollapseAd: ad];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
#pragma mark - Deprecated Callbacks
|
|
234
|
+
|
|
235
|
+
- (void)didDisplayAd:(MAAd *)ad {}
|
|
236
|
+
- (void)didHideAd:(MAAd *)ad {}
|
|
237
|
+
|
|
190
238
|
@end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AppLovinMAXNativeAdView.h
|
|
3
|
+
// AppLovin MAX React Native Module
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2022 AppLovin. All rights reserved.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <React/RCTUIManager.h>
|
|
9
|
+
|
|
10
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Represents a container view for a native ad.
|
|
14
|
+
*/
|
|
15
|
+
@interface AppLovinMAXNativeAdView : UIView
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Loads a native ad, called by JavaScript via the View Manager.
|
|
19
|
+
*/
|
|
20
|
+
- (void)loadAd;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
- (instancetype)initWithBridge:(RCTBridge *)bridge;
|
|
24
|
+
|
|
25
|
+
@end
|
|
26
|
+
|
|
27
|
+
NS_ASSUME_NONNULL_END
|