Skip to content

Commit 2a8ebda

Browse files
feat: Java enum for MPCommerceEventActionType was base 1
1 parent 7816556 commit 2a8ebda

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

ios/RNMParticle/RNMParticle.mm

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ @interface MParticleUser ()
1919
- (void)setUserId:(NSNumber *)userId;
2020
@end
2121

22+
// Forward declare so New Arch `logCommerceEvent` can use the same JS→native
23+
// product action mapping as `RCTConvert MPCommerceEvent:` (defined later in this file).
24+
@interface RCTConvert (MPCommerceEvent)
25+
+ (MPCommerceEventAction)MPCommerceEventAction:(id)json;
26+
@end
27+
2228
@implementation RNMParticle
2329

2430
RCT_EXTERN void RCTRegisterModule(Class);
@@ -447,7 +453,7 @@ - (void)logCommerceEvent:(JS::NativeMParticle::CommerceEvent &)commerceEvent {
447453
MPCommerceEvent *mpCommerceEvent = [[MPCommerceEvent alloc] init];
448454

449455
if (commerceEvent.productActionType().has_value()) {
450-
mpCommerceEvent.action = (MPCommerceEventAction)commerceEvent.productActionType().value();
456+
mpCommerceEvent.action = [RCTConvert MPCommerceEventAction:@(commerceEvent.productActionType().value())];
451457
}
452458

453459
if (commerceEvent.promotionActionType().has_value()) {
@@ -778,7 +784,7 @@ + (MPCommerceEvent *)MPCommerceEvent:(NSDictionary *)dict {
778784
MPCommerceEvent *commerceEvent = [[MPCommerceEvent alloc] init];
779785

780786
if (dict[@"productActionType"] && dict[@"productActionType"] != [NSNull null]) {
781-
commerceEvent.action = (MPCommerceEventAction)[dict[@"productActionType"] integerValue];
787+
commerceEvent.action = [RCTConvert MPCommerceEventAction:dict[@"productActionType"]];
782788
}
783789

784790
if (dict[@"products"] && dict[@"products"] != [NSNull null]) {

0 commit comments

Comments
 (0)