@@ -62,7 +62,7 @@ + (void)load {
6262RCT_EXPORT_METHOD (removeGDPRConsentStateWithPurpose:(NSString *)purpose)
6363{
6464 MParticleUser *user = [MParticle sharedInstance ].identity .currentUser ;
65-
65+
6666 MPConsentState *consentState = user.consentState ? user.consentState : [[MPConsentState alloc ] init ];
6767 [consentState removeGDPRConsentStateWithPurpose: purpose];
6868 user.consentState = consentState;
@@ -146,18 +146,18 @@ + (void)load {
146146 if (error) {
147147 reactError = [[NSMutableDictionary alloc ] initWithCapacity: 4 ];
148148 MPIdentityHTTPErrorResponse *response = error.userInfo [mParticleIdentityErrorKey];
149-
149+
150150 if ([response isKindOfClass: [NSString class ]]) {
151151 [reactError setObject: response forKey: @" message" ];
152152 } else {
153153 if ([NSNumber numberWithLong: response.httpCode] != nil ) {
154154 [reactError setObject: [NSNumber numberWithLong: response.httpCode] forKey: @" httpCode" ];
155155 }
156-
156+
157157 if ([NSNumber numberWithInt: response.code] != nil ) {
158158 [reactError setObject: [NSNumber numberWithInt: response.code] forKey: @" responseCode" ];
159159 }
160-
160+
161161 if (response.message != nil ) {
162162 [reactError setObject: response.message forKey: @" message" ];
163163 }
@@ -180,18 +180,18 @@ + (void)load {
180180 if (error) {
181181 reactError = [[NSMutableDictionary alloc ] initWithCapacity: 4 ];
182182 MPIdentityHTTPErrorResponse *response = error.userInfo [mParticleIdentityErrorKey];
183-
183+
184184 if ([response isKindOfClass: [NSString class ]]) {
185185 [reactError setObject: response forKey: @" message" ];
186186 } else {
187187 if ([NSNumber numberWithLong: response.httpCode] != nil ) {
188188 [reactError setObject: [NSNumber numberWithLong: response.httpCode] forKey: @" httpCode" ];
189189 }
190-
190+
191191 if ([NSNumber numberWithInt: response.code] != nil ) {
192192 [reactError setObject: [NSNumber numberWithInt: response.code] forKey: @" responseCode" ];
193193 }
194-
194+
195195 if (response.message != nil ) {
196196 [reactError setObject: response.message forKey: @" message" ];
197197 }
@@ -200,7 +200,7 @@ + (void)load {
200200 completion (@[reactError, apiResult.user.userId.stringValue, apiResult.previousUser.userId.stringValue]);
201201 } else {
202202 completion (@[reactError, @0 ]);
203- }
203+ }
204204 } else {
205205 completion (@[[NSNull null ], apiResult.user.userId.stringValue, apiResult.previousUser.userId.stringValue]);
206206 }
@@ -214,18 +214,18 @@ + (void)load {
214214 if (error) {
215215 reactError = [[NSMutableDictionary alloc ] initWithCapacity: 4 ];
216216 MPIdentityHTTPErrorResponse *response = error.userInfo [mParticleIdentityErrorKey];
217-
217+
218218 if ([response isKindOfClass: [NSString class ]]) {
219219 [reactError setObject: response forKey: @" message" ];
220220 } else {
221221 if ([NSNumber numberWithLong: response.httpCode] != nil ) {
222222 [reactError setObject: [NSNumber numberWithLong: response.httpCode] forKey: @" httpCode" ];
223223 }
224-
224+
225225 if ([NSNumber numberWithInt: response.code] != nil ) {
226226 [reactError setObject: [NSNumber numberWithInt: response.code] forKey: @" responseCode" ];
227227 }
228-
228+
229229 if (response.message != nil ) {
230230 [reactError setObject: response.message forKey: @" message" ];
231231 }
@@ -248,18 +248,18 @@ + (void)load {
248248 if (error) {
249249 reactError = [[NSMutableDictionary alloc ] initWithCapacity: 4 ];
250250 MPIdentityHTTPErrorResponse *response = error.userInfo [mParticleIdentityErrorKey];
251-
251+
252252 if ([response isKindOfClass: [NSString class ]]) {
253253 [reactError setObject: response forKey: @" message" ];
254254 } else {
255255 if ([NSNumber numberWithLong: response.httpCode] != nil ) {
256256 [reactError setObject: [NSNumber numberWithLong: response.httpCode] forKey: @" httpCode" ];
257257 }
258-
258+
259259 if ([NSNumber numberWithInt: response.code] != nil ) {
260260 [reactError setObject: [NSNumber numberWithInt: response.code] forKey: @" responseCode" ];
261261 }
262-
262+
263263 if (response.message != nil ) {
264264 [reactError setObject: response.message forKey: @" message" ];
265265 }
@@ -307,6 +307,12 @@ + (void)load {
307307 completion (@[[NSNull null ], [selectedUser lastSeen ]]);
308308}
309309
310+ RCT_EXPORT_METHOD (getSession:(RCTResponseSenderBlock)completion)
311+ {
312+ NSString *sessionID = [MParticle sharedInstance ].currentSession .UUID ;
313+ completion (@[sessionID]);
314+ }
315+
310316@end
311317
312318typedef NS_ENUM (NSUInteger , MPReactCommerceEventAction) {
@@ -345,9 +351,9 @@ + (MPCommerceEvent *)MPCommerceEvent:(id)json {
345351 BOOL isProductAction = json[@" productActionType" ] != nil ;
346352 BOOL isPromotion = json[@" promotionActionType" ] != nil ;
347353 BOOL isImpression = json[@" impressions" ] != nil ;
348-
354+
349355 NSAssert (isProductAction || isPromotion || isImpression, @" Invalid commerce event" );
350-
356+
351357 MPCommerceEvent *commerceEvent = nil ;
352358 if (isProductAction) {
353359 MPCommerceEventAction action = [RCTConvert MPCommerceEventAction: json[@" productActionType" ]];
@@ -360,7 +366,7 @@ + (MPCommerceEvent *)MPCommerceEvent:(id)json {
360366 else {
361367 commerceEvent = [[MPCommerceEvent alloc ] initWithImpressionName: nil product: nil ];
362368 }
363-
369+
364370 commerceEvent.checkoutOptions = json[@" checkoutOptions" ];
365371 commerceEvent.currency = json[@" currency" ];
366372 commerceEvent.productListName = json[@" productActionListName" ];
@@ -370,15 +376,15 @@ + (MPCommerceEvent *)MPCommerceEvent:(id)json {
370376 commerceEvent.action = [RCTConvert MPCommerceEventAction: json[@" productActionType" ]];
371377 commerceEvent.checkoutStep = [json[@" checkoutStep" ] intValue ];
372378 commerceEvent.nonInteractive = [json[@" nonInteractive" ] boolValue ];
373-
379+
374380 NSMutableArray *products = [NSMutableArray array ];
375381 NSArray *jsonProducts = json[@" products" ];
376382 [jsonProducts enumerateObjectsUsingBlock: ^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
377383 MPProduct *product = [RCTConvert MPProduct: obj];
378384 [products addObject: product];
379385 }];
380386 [commerceEvent addProducts: products];
381-
387+
382388 NSArray *jsonImpressions = json[@" impressions" ];
383389 [jsonImpressions enumerateObjectsUsingBlock: ^(NSDictionary *jsonImpression, NSUInteger idx, BOOL * _Nonnull stop) {
384390 NSString *listName = jsonImpression[@" impressionListName" ];
@@ -388,7 +394,7 @@ + (MPCommerceEvent *)MPCommerceEvent:(id)json {
388394 [commerceEvent addImpression: product listName: listName];
389395 }];
390396 }];
391-
397+
392398 return commerceEvent;
393399}
394400
@@ -400,7 +406,7 @@ + (MPPromotionContainer *)MPPromotionContainer:(id)json {
400406 MPPromotion *promotion = [RCTConvert MPPromotion: obj];
401407 [promotionContainer addPromotion: promotion];
402408 }];
403-
409+
404410 return promotionContainer;
405411}
406412
@@ -450,43 +456,43 @@ + (MPCommerceEventAction)MPCommerceEventAction:(NSNumber *)json {
450456 case MPReactCommerceEventActionAddToCart:
451457 action = MPCommerceEventActionAddToCart;
452458 break ;
453-
459+
454460 case MPReactCommerceEventActionRemoveFromCart:
455461 action = MPCommerceEventActionRemoveFromCart;
456462 break ;
457-
463+
458464 case MPReactCommerceEventActionCheckout:
459465 action = MPCommerceEventActionCheckout;
460466 break ;
461-
467+
462468 case MPReactCommerceEventActionCheckoutOptions:
463469 action = MPCommerceEventActionCheckoutOptions;
464470 break ;
465-
471+
466472 case MPReactCommerceEventActionClick:
467473 action = MPCommerceEventActionClick;
468474 break ;
469-
475+
470476 case MPReactCommerceEventActionViewDetail:
471477 action = MPCommerceEventActionViewDetail;
472478 break ;
473-
479+
474480 case MPReactCommerceEventActionPurchase:
475481 action = MPCommerceEventActionPurchase;
476482 break ;
477-
483+
478484 case MPReactCommerceEventActionRefund:
479485 action = MPCommerceEventActionRefund;
480486 break ;
481-
487+
482488 case MPReactCommerceEventActionAddToWishList:
483489 action = MPCommerceEventActionAddToWishList;
484490 break ;
485-
491+
486492 case MPReactCommerceEventActionRemoveFromWishlist:
487493 action = MPCommerceEventActionRemoveFromWishlist;
488494 break ;
489-
495+
490496 default :
491497 action = MPCommerceEventActionAddToCart;
492498 NSAssert (NO , @" Invalid commerce event action" );
@@ -515,7 +521,7 @@ + (MPIdentityApiResult *)MPIdentityApiResult:(id)json {
515521 MPIdentityApiResult *result = [[MPIdentityApiResult alloc ] init ];
516522 id obj = json[@" user" ];
517523 result.user = [RCTConvert MParticleUser: obj];
518-
524+
519525 return result;
520526}
521527
@@ -540,43 +546,40 @@ + (MPAliasRequest *)MPAliasRequest:(id)json {
540546+ (MParticleUser *)MParticleUser : (id )json {
541547 MParticleUser *user = [[MParticleUser alloc ] init ];
542548 user.userId = json[@" userId" ];
543-
549+
544550 return user;
545551}
546552
547553+ (MPEvent *)MPEvent : (id )json {
548554 MPEvent *event = [[MPEvent alloc ] init ];
549-
555+
550556 event.category = json[@" category" ];
551557 event.duration = json[@" duration" ];
552558 event.endTime = json[@" endTime" ];
553559 event.info = json[@" info" ];
554560 event.name = json[@" name" ];
555561 event.startTime = json[@" startTime" ];
556562 event.type = [json[@" type" ] intValue ];
557-
563+
558564 NSDictionary *jsonFlags = json[@" customFlags" ];
559565 for (NSString *key in jsonFlags) {
560566 NSString *value = jsonFlags[key];
561567 [event addCustomFlag: value withKey: key];
562568 }
563-
569+
564570 return event;
565571}
566572
567573+ (MPGDPRConsent *)MPGDPRConsent : (id )json {
568574 MPGDPRConsent *mpConsent = [[MPGDPRConsent alloc ] init ];
569-
575+
570576 mpConsent.consented = [RCTConvert BOOL: json[@" consented" ]];
571577 mpConsent.document = json[@" document" ];
572578 mpConsent.timestamp = [RCTConvert NSDate: json[@" timestamp" ]];
573579 mpConsent.location = json[@" location" ];
574580 mpConsent.hardwareId = json[@" hardwareId" ];
575-
581+
576582 return mpConsent;
577583}
578584
579585@end
580-
581-
582-
0 commit comments