Created
August 21, 2018 00:17
-
-
Save ChiAnTai/613334af21145633ccf90ba6f9b3a1bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RCT_EXPORT_METHOD(sendEcommerceCheckoutStep:(NSString *)trackerId step:(nonnull NSNumber *)step products:(NSArray *)products) | |
{ | |
id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:trackerId]; | |
GAIDictionaryBuilder *builder = [GAIDictionaryBuilder createEventWithCategory:@"Ecommerce" | |
action:@"Checkout" | |
label:nil | |
value:nil]; | |
GAIEcommerceProductAction *action = [[GAIEcommerceProductAction alloc] init]; | |
[action setAction:kGAIPACheckout]; | |
[action setCheckoutStep:step]; | |
for(NSDictionary* reactProduct in products) { | |
GAIEcommerceProduct *product = [[GAIEcommerceProduct alloc] init]; | |
[product setId:reactProduct[@"item_id"]]; | |
[product setName:reactProduct[@"name"]]; | |
[product setPrice:reactProduct[@"price"]]; | |
[product setQuantity:reactProduct[@"qty"]]; | |
[builder addProduct:product]; | |
} | |
[builder setProductAction:action]; | |
[tracker send:[builder build]]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment