|
1 | 1 | #import "MPKitRokt.h" |
2 | 2 | #import <Rokt_Widget/Rokt_Widget-Swift.h> |
3 | | -#import <mParticle_Rokt/mParticle_Rokt-Swift.h> |
4 | 3 |
|
5 | 4 | NSString * const kMPRemoteConfigKitHashesKey = @"hs"; |
6 | 5 | NSString * const kMPRemoteConfigUserAttributeFilter = @"ua"; |
@@ -457,7 +456,7 @@ - (MPKitExecStatus *)purchaseFinalized:(NSString *)placementId catalogItemId:(NS |
457 | 456 |
|
458 | 457 | - (MPKitExecStatus *)events:(NSString *)identifier onEvent:(void (^)(MPRoktEvent * _Nonnull))onEvent { |
459 | 458 | [Rokt eventsWithViewName:identifier onEvent:^(RoktEvent * _Nonnull event) { |
460 | | - MPRoktEvent *mpEvent = [MPRoktEventMapper mapEvent:event]; |
| 459 | + MPRoktEvent *mpEvent = [MPKitRokt mapEvent:event]; |
461 | 460 | if (mpEvent) { |
462 | 461 | onEvent(mpEvent); |
463 | 462 | } |
@@ -742,4 +741,104 @@ - (MPKitExecStatus *)setOptOut:(BOOL)optOut { |
742 | 741 | return [self execStatus:MPKitReturnCodeSuccess]; |
743 | 742 | } |
744 | 743 |
|
| 744 | ++ (MPRoktEvent * _Nullable)mapEvent:(RoktEvent *)event { |
| 745 | + if (!event) { |
| 746 | + return nil; |
| 747 | + } |
| 748 | + |
| 749 | + // Check for RoktEvent.InitComplete |
| 750 | + if ([event isKindOfClass:[InitComplete class]]) { |
| 751 | + InitComplete *initComplete = (InitComplete *)event; |
| 752 | + return [[MPRoktInitComplete alloc] initWithSuccess:initComplete.success]; |
| 753 | + } |
| 754 | + |
| 755 | + // Check for RoktEvent.ShowLoadingIndicator |
| 756 | + if ([event isKindOfClass:[ShowLoadingIndicator class]]) { |
| 757 | + return [[MPRoktShowLoadingIndicator alloc] init]; |
| 758 | + } |
| 759 | + |
| 760 | + // Check for RoktEvent.HideLoadingIndicator |
| 761 | + if ([event isKindOfClass:[HideLoadingIndicator class]]) { |
| 762 | + return [[MPRoktHideLoadingIndicator alloc] init]; |
| 763 | + |
| 764 | + } |
| 765 | + |
| 766 | + // Check for RoktEvent.PlacementInteractive |
| 767 | + if ([event isKindOfClass:[PlacementInteractive class]]) { |
| 768 | + PlacementInteractive *placementInteractive = (PlacementInteractive *)event; |
| 769 | + return [[MPRoktPlacementInteractive alloc] initWithPlacementId:placementInteractive.placementId]; |
| 770 | + } |
| 771 | + |
| 772 | + // Check for RoktEvent.PlacementReady |
| 773 | + if ([event isKindOfClass:[PlacementReady class]]) { |
| 774 | + PlacementReady *placementReady = (PlacementReady *)event; |
| 775 | + return [[MPRoktPlacementReady alloc] initWithPlacementId:placementReady.placementId]; |
| 776 | + } |
| 777 | + |
| 778 | + // Check for RoktEvent.OfferEngagement |
| 779 | + if ([event isKindOfClass:[OfferEngagement class]]) { |
| 780 | + OfferEngagement *offerEngagement = (OfferEngagement *)event; |
| 781 | + return [[MPRoktOfferEngagement alloc] initWithPlacementId:offerEngagement.placementId]; |
| 782 | + } |
| 783 | + |
| 784 | + // Check for RoktEvent.OpenUrl |
| 785 | + if ([event isKindOfClass:[OpenUrl class]]) { |
| 786 | + OpenUrl *openUrl = (OpenUrl *)event; |
| 787 | + return [[MPRoktOpenUrl alloc] initWithPlacementId:openUrl.placementId url:openUrl.url]; |
| 788 | + } |
| 789 | + |
| 790 | + // Check for RoktEvent.PositiveEngagement |
| 791 | + if ([event isKindOfClass:[PositiveEngagement class]]) { |
| 792 | + PositiveEngagement *positiveEngagement = (PositiveEngagement *)event; |
| 793 | + return [[MPRoktPositiveEngagement alloc] initWithPlacementId:positiveEngagement.placementId]; |
| 794 | + } |
| 795 | + |
| 796 | + // Check for RoktEvent.PlacementClosed |
| 797 | + if ([event isKindOfClass:[PlacementClosed class]]) { |
| 798 | + PlacementClosed *placementClosed = (PlacementClosed *)event; |
| 799 | + return [[MPRoktPlacementClosed alloc] initWithPlacementId:placementClosed.placementId]; |
| 800 | + } |
| 801 | + |
| 802 | + // Check for RoktEvent.PlacementCompleted |
| 803 | + if ([event isKindOfClass:[PlacementCompleted class]]) { |
| 804 | + PlacementCompleted *placementCompleted = (PlacementCompleted *)event; |
| 805 | + return [[MPRoktPlacementCompleted alloc] initWithPlacementId:placementCompleted.placementId]; |
| 806 | + } |
| 807 | + |
| 808 | + // Check for RoktEvent.PlacementFailure |
| 809 | + if ([event isKindOfClass:[PlacementFailure class]]) { |
| 810 | + PlacementFailure *placementFailure = (PlacementFailure *)event; |
| 811 | + return [[MPRoktPlacementFailure alloc] initWithPlacementId:placementFailure.placementId]; |
| 812 | + } |
| 813 | + |
| 814 | + // Check for RoktEvent.FirstPositiveEngagement |
| 815 | + if ([event isKindOfClass:[FirstPositiveEngagement class]]) { |
| 816 | + FirstPositiveEngagement *firstPositiveEngagement = (FirstPositiveEngagement *)event; |
| 817 | + return [[MPRoktFirstPositiveEngagement alloc] initWithPlacementId:firstPositiveEngagement.placementId]; |
| 818 | + } |
| 819 | + |
| 820 | + // Check for RoktEvent.CartItemInstantPurchase |
| 821 | + if ([event isKindOfClass:[CartItemInstantPurchase class]]) { |
| 822 | + CartItemInstantPurchase *cartItemInstantPurchase = (CartItemInstantPurchase *)event; |
| 823 | + |
| 824 | + // Handle nil coalescing for name field |
| 825 | + NSString *name = cartItemInstantPurchase.name ?: @""; |
| 826 | + |
| 827 | + return [[MPRoktCartItemInstantPurchase alloc] initWithPlacementId:cartItemInstantPurchase.placementId |
| 828 | + name:name |
| 829 | + cartItemId:cartItemInstantPurchase.cartItemId |
| 830 | + catalogItemId:cartItemInstantPurchase.catalogItemId |
| 831 | + currency:cartItemInstantPurchase.currency |
| 832 | + description:cartItemInstantPurchase.description |
| 833 | + linkedProductId:cartItemInstantPurchase.linkedProductId |
| 834 | + providerData:cartItemInstantPurchase.providerData |
| 835 | + quantity:cartItemInstantPurchase.quantity |
| 836 | + totalPrice:cartItemInstantPurchase.totalPrice |
| 837 | + unitPrice:cartItemInstantPurchase.unitPrice]; |
| 838 | + } |
| 839 | + |
| 840 | + // Default case - return nil if no matching event type found |
| 841 | + return nil; |
| 842 | +} |
| 843 | + |
745 | 844 | @end |
0 commit comments