react-native-mparticle 3.1.3 → 3.1.4
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.
|
@@ -19,6 +19,13 @@
|
|
|
19
19
|
- (void)setUserId:(NSNumber *)userId;
|
|
20
20
|
@end
|
|
21
21
|
|
|
22
|
+
// Forward declare so New Arch `logCommerceEvent` can use the same JS→native
|
|
23
|
+
// mappings as `RCTConvert (MPCommerceEvent)` (defined later in this file).
|
|
24
|
+
@interface RCTConvert (MPCommerceEvent)
|
|
25
|
+
+ (MPCommerceEventAction)MPCommerceEventAction:(id)json;
|
|
26
|
+
+ (MPPromotionAction)MPPromotionAction:(id)json;
|
|
27
|
+
@end
|
|
28
|
+
|
|
22
29
|
@implementation RNMParticle
|
|
23
30
|
|
|
24
31
|
RCT_EXTERN void RCTRegisterModule(Class);
|
|
@@ -447,11 +454,14 @@ RCT_EXPORT_METHOD(getSession:(RCTResponseSenderBlock)completion)
|
|
|
447
454
|
MPCommerceEvent *mpCommerceEvent = [[MPCommerceEvent alloc] init];
|
|
448
455
|
|
|
449
456
|
if (commerceEvent.productActionType().has_value()) {
|
|
450
|
-
mpCommerceEvent.action = (
|
|
457
|
+
mpCommerceEvent.action = [RCTConvert MPCommerceEventAction:@(commerceEvent.productActionType().value())];
|
|
451
458
|
}
|
|
452
459
|
|
|
453
460
|
if (commerceEvent.promotionActionType().has_value()) {
|
|
454
|
-
|
|
461
|
+
MPPromotionAction promotionAction =
|
|
462
|
+
[RCTConvert MPPromotionAction:@(commerceEvent.promotionActionType().value())];
|
|
463
|
+
mpCommerceEvent.promotionContainer =
|
|
464
|
+
[[MPPromotionContainer alloc] initWithAction:promotionAction promotion:nil];
|
|
455
465
|
}
|
|
456
466
|
|
|
457
467
|
if (commerceEvent.products().has_value()) {
|
|
@@ -778,7 +788,7 @@ RCT_EXPORT_METHOD(setCCPAConsentState:(MPCCPAConsent *)consent)
|
|
|
778
788
|
MPCommerceEvent *commerceEvent = [[MPCommerceEvent alloc] init];
|
|
779
789
|
|
|
780
790
|
if (dict[@"productActionType"] && dict[@"productActionType"] != [NSNull null]) {
|
|
781
|
-
commerceEvent.action =
|
|
791
|
+
commerceEvent.action = [RCTConvert MPCommerceEventAction:dict[@"productActionType"]];
|
|
782
792
|
}
|
|
783
793
|
|
|
784
794
|
if (dict[@"products"] && dict[@"products"] != [NSNull null]) {
|
|
@@ -920,6 +930,7 @@ typedef NS_ENUM(NSUInteger, MPReactCommerceEventAction) {
|
|
|
920
930
|
+ (MPTransactionAttributes *)MPTransactionAttributes:(id)json;
|
|
921
931
|
+ (MPProduct *)MPProduct:(id)json;
|
|
922
932
|
+ (MPCommerceEventAction)MPCommerceEventAction:(id)json;
|
|
933
|
+
+ (MPPromotionAction)MPPromotionAction:(id)json;
|
|
923
934
|
+ (MPIdentityApiRequest *)MPIdentityApiRequest:(id)json;
|
|
924
935
|
+ (MPIdentityApiResult *)MPIdentityApiResult:(id)json;
|
|
925
936
|
+ (MPAliasRequest *)MPAliasRequest:(id)json;
|
|
@@ -989,7 +1000,7 @@ typedef NS_ENUM(NSUInteger, MPReactCommerceEventAction) {
|
|
|
989
1000
|
}
|
|
990
1001
|
|
|
991
1002
|
+ (MPPromotionContainer *)MPPromotionContainer:(id)json {
|
|
992
|
-
MPPromotionAction promotionAction =
|
|
1003
|
+
MPPromotionAction promotionAction = [RCTConvert MPPromotionAction:json[@"promotionActionType"]];
|
|
993
1004
|
MPPromotionContainer *promotionContainer = [[MPPromotionContainer alloc] initWithAction:promotionAction promotion:nil];
|
|
994
1005
|
NSArray *jsonPromotions = json[@"promotions"];
|
|
995
1006
|
[jsonPromotions enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
@@ -1039,6 +1050,20 @@ typedef NS_ENUM(NSUInteger, MPReactCommerceEventAction) {
|
|
|
1039
1050
|
return product;
|
|
1040
1051
|
}
|
|
1041
1052
|
|
|
1053
|
+
+ (MPPromotionAction)MPPromotionAction:(NSNumber *)json {
|
|
1054
|
+
// JS `PromotionActionType`: View = 0, Click = 1 (js/index.tsx).
|
|
1055
|
+
// Apple `MPPromotionAction`: Click = 0, View = 1 (MPPromotion.h).
|
|
1056
|
+
switch ([json intValue]) {
|
|
1057
|
+
case 0:
|
|
1058
|
+
return MPPromotionActionView;
|
|
1059
|
+
case 1:
|
|
1060
|
+
return MPPromotionActionClick;
|
|
1061
|
+
default:
|
|
1062
|
+
// Match Android `convertPromotionActionType`: non-zero → Click
|
|
1063
|
+
return MPPromotionActionClick;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1042
1067
|
+ (MPCommerceEventAction)MPCommerceEventAction:(NSNumber *)json {
|
|
1043
1068
|
int actionInt = [json intValue];
|
|
1044
1069
|
MPCommerceEventAction action;
|
package/package.json
CHANGED