Skip to content

Commit e811279

Browse files
addressed Denis comments
1 parent e0b8198 commit e811279

1 file changed

Lines changed: 60 additions & 136 deletions

File tree

mParticle-Rokt/MPKitRokt.m

Lines changed: 60 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
NSString * const MPKitRoktErrorMessageKey = @"mParticle-Rokt Error";
88
NSString * const kMPPlacementAttributesMapping = @"placementAttributesMapping";
99
NSString * const kMPHashedEmailUserIdentityType = @"hashedEmailUserIdentityType";
10+
NSInteger const kMPRoktKitCode = 181;
11+
1012
static __weak MPKitRokt *roktKit = nil;
1113

1214
@interface MPKitRokt () <MPKitProtocol>
@@ -21,7 +23,7 @@ @implementation MPKitRokt
2123
mParticle will supply a unique kit code for you. Please contact our team
2224
*/
2325
+ (NSNumber *)kitCode {
24-
return @181; // Replace with the actual kit code assigned by mParticle
26+
return @(kMPRoktKitCode); // Replace with the actual kit code assigned by mParticle
2527
}
2628

2729
+ (void)load {
@@ -252,7 +254,7 @@ - (RoktFrameworkType)mapMPWrapperSdkToRoktFrameworkType:(MPWrapperSdk)wrapperSdk
252254
NSArray<NSDictionary *> *kitConfigs = [MParticle sharedInstance].kitContainer_PRIVATE.originalConfig.copy;
253255
NSDictionary *roktKitConfig;
254256
for (NSDictionary *kitConfig in kitConfigs) {
255-
if (kitConfig[@"id"] != nil && [kitConfig[@"id"] integerValue] == 181) {
257+
if (kitConfig[@"id"] != nil && [kitConfig[@"id"] integerValue] == kMPRoktKitCode) {
256258
roktKitConfig = kitConfig;
257259
}
258260
}
@@ -367,150 +369,72 @@ + (NSString *)stringForIdentityType:(MPIdentity)identityType {
367369
if (hashedEmailIdentity.unsignedIntValue == identityType) {
368370
return @"emailsha256";
369371
}
370-
371-
switch (identityType) {
372-
case MPIdentityCustomerId:
373-
return @"customerid";
374-
375-
case MPIdentityEmail:
376-
return @"email";
377-
378-
case MPIdentityFacebook:
379-
return @"facebook";
380-
381-
case MPIdentityFacebookCustomAudienceId:
382-
return @"facebookcustomaudienceid";
383-
384-
case MPIdentityGoogle:
385-
return @"google";
386-
387-
case MPIdentityMicrosoft:
388-
return @"microsoft";
389-
390-
case MPIdentityOther:
391-
return @"other";
392-
393-
case MPIdentityTwitter:
394-
return @"twitter";
395-
396-
case MPIdentityYahoo:
397-
return @"yahoo";
398-
399-
case MPIdentityOther2:
400-
return @"other2";
401-
402-
case MPIdentityOther3:
403-
return @"other3";
404-
405-
case MPIdentityOther4:
406-
return @"other4";
407-
408-
case MPIdentityOther5:
409-
return @"other5";
410-
411-
case MPIdentityOther6:
412-
return @"other6";
413-
414-
case MPIdentityOther7:
415-
return @"other7";
416-
417-
case MPIdentityOther8:
418-
return @"other8";
419-
420-
case MPIdentityOther9:
421-
return @"other9";
422-
423-
case MPIdentityOther10:
424-
return @"other10";
425-
426-
case MPIdentityMobileNumber:
427-
return @"mobile_number";
428-
429-
case MPIdentityPhoneNumber2:
430-
return @"phone_number_2";
431-
432-
case MPIdentityPhoneNumber3:
433-
return @"phone_number_3";
434-
435-
case MPIdentityIOSAdvertiserId:
436-
return @"ios_idfa";
437-
438-
case MPIdentityIOSVendorId:
439-
return @"ios_idfv";
440-
441-
case MPIdentityPushToken:
442-
return @"push_token";
443-
444-
case MPIdentityDeviceApplicationStamp:
445-
return @"device_application_stamp";
446-
447-
default:
448-
return nil;
449-
}
372+
373+
NSDictionary<NSNumber *, NSString *> *identityStrings = @{@(MPIdentityCustomerId): @"customerid",
374+
@(MPIdentityEmail): @"email",
375+
@(MPIdentityFacebook): @"facebook",
376+
@(MPIdentityFacebookCustomAudienceId): @"facebookcustomaudienceid",
377+
@(MPIdentityGoogle): @"google",
378+
@(MPIdentityMicrosoft): @"microsoft",
379+
@(MPIdentityOther): @"other",
380+
@(MPIdentityTwitter): @"twitter",
381+
@(MPIdentityYahoo): @"yahoo",
382+
@(MPIdentityOther2): @"other2",
383+
@(MPIdentityOther3): @"other3",
384+
@(MPIdentityOther4): @"other4",
385+
@(MPIdentityOther5): @"other5",
386+
@(MPIdentityOther6): @"other6",
387+
@(MPIdentityOther7): @"other7",
388+
@(MPIdentityOther8): @"other8",
389+
@(MPIdentityOther9): @"other9",
390+
@(MPIdentityOther10): @"other10",
391+
@(MPIdentityMobileNumber): @"mobile_number",
392+
@(MPIdentityPhoneNumber2): @"phone_number_2",
393+
@(MPIdentityPhoneNumber3): @"phone_number_3",
394+
@(MPIdentityIOSAdvertiserId): @"ios_idfa",
395+
@(MPIdentityIOSVendorId): @"ios_idfv",
396+
@(MPIdentityPushToken): @"push_token",
397+
@(MPIdentityDeviceApplicationStamp): @"device_application_stamp"};
398+
399+
return identityStrings[@(identityType)];
450400
}
451401

452402
+ (NSNumber *)identityTypeForString:(NSString *)identityString {
453-
if ([identityString isEqualToString:@"customerid"]){
454-
return @(MPIdentityCustomerId);
455-
} else if ([identityString isEqualToString:@"email"]){
456-
return @(MPIdentityEmail);
457-
} else if ([identityString isEqualToString:@"facebook"]){
458-
return @(MPIdentityFacebook);
459-
} else if ([identityString isEqualToString:@"facebookcustomaudienceid"]){
460-
return @(MPIdentityFacebookCustomAudienceId);
461-
} else if ([identityString isEqualToString:@"google"]){
462-
return @(MPIdentityGoogle);
463-
} else if ([identityString isEqualToString:@"microsoft"]){
464-
return @(MPIdentityMicrosoft);
465-
} else if ([identityString isEqualToString:@"other"]){
466-
return @(MPIdentityOther);
467-
} else if ([identityString isEqualToString:@"twitter"]){
468-
return @(MPIdentityTwitter);
469-
} else if ([identityString isEqualToString:@"yahoo"]){
470-
return @(MPIdentityYahoo);
471-
} else if ([identityString isEqualToString:@"other2"]){
472-
return @(MPIdentityOther2);
473-
} else if ([identityString isEqualToString:@"other3"]){
474-
return @(MPIdentityOther3);
475-
} else if ([identityString isEqualToString:@"other4"]){
476-
return @(MPIdentityOther4);
477-
} else if ([identityString isEqualToString:@"other5"]){
478-
return @(MPIdentityOther5);
479-
} else if ([identityString isEqualToString:@"other6"]){
480-
return @(MPIdentityOther6);
481-
} else if ([identityString isEqualToString:@"other7"]){
482-
return @(MPIdentityOther7);
483-
} else if ([identityString isEqualToString:@"other8"]){
484-
return @(MPIdentityOther8);
485-
} else if ([identityString isEqualToString:@"other9"]){
486-
return @(MPIdentityOther9);
487-
} else if ([identityString isEqualToString:@"other10"]){
488-
return @(MPIdentityOther10);
489-
} else if ([identityString isEqualToString:@"mobile_number"]){
490-
return @(MPIdentityMobileNumber);
491-
} else if ([identityString isEqualToString:@"phone_number_2"]){
492-
return @(MPIdentityPhoneNumber2);
493-
} else if ([identityString isEqualToString:@"phone_number_3"]){
494-
return @(MPIdentityPhoneNumber3);
495-
} else if ([identityString isEqualToString:@"ios_idfa"]){
496-
return @(MPIdentityIOSAdvertiserId);
497-
} else if ([identityString isEqualToString:@"ios_idfv"]){
498-
return @(MPIdentityIOSVendorId);
499-
} else if ([identityString isEqualToString:@"push_token"]){
500-
return @(MPIdentityPushToken);
501-
} else if ([identityString isEqualToString:@"device_application_stamp"]){
502-
return @(MPIdentityDeviceApplicationStamp);
503-
} else {
504-
return nil;
505-
}
403+
NSDictionary<NSString *, NSNumber *> *identityNumbers = @{@"customerid": @(MPIdentityCustomerId),
404+
@"email": @(MPIdentityEmail),
405+
@"facebook": @(MPIdentityFacebook),
406+
@"facebookcustomaudienceid": @(MPIdentityFacebookCustomAudienceId),
407+
@"google": @(MPIdentityGoogle),
408+
@"microsoft": @(MPIdentityMicrosoft),
409+
@"other": @(MPIdentityOther),
410+
@"twitter": @(MPIdentityTwitter),
411+
@"yahoo": @(MPIdentityYahoo),
412+
@"other2": @(MPIdentityOther2),
413+
@"other3": @(MPIdentityOther3),
414+
@"other4": @(MPIdentityOther4),
415+
@"other5": @(MPIdentityOther5),
416+
@"other6": @(MPIdentityOther6),
417+
@"other7": @(MPIdentityOther7),
418+
@"other8": @(MPIdentityOther8),
419+
@"other9": @(MPIdentityOther9),
420+
@"other10": @(MPIdentityOther10),
421+
@"mobile_number": @(MPIdentityMobileNumber),
422+
@"phone_number_2": @(MPIdentityPhoneNumber2),
423+
@"phone_number_3": @(MPIdentityPhoneNumber3),
424+
@"ios_idfa": @(MPIdentityIOSAdvertiserId),
425+
@"ios_idfv": @(MPIdentityIOSVendorId),
426+
@"push_token": @(MPIdentityPushToken),
427+
@"device_application_stamp": @(MPIdentityDeviceApplicationStamp)};
428+
429+
return identityNumbers[identityString];
506430
}
507431

508432
+ (NSNumber *)getRoktHashedEmailUserIdentityType {
509433
// Get the kit configuration
510434
NSArray<NSDictionary *> *kitConfigs = [MParticle sharedInstance].kitContainer_PRIVATE.originalConfig.copy;
511435
NSDictionary *roktKitConfig;
512436
for (NSDictionary *kitConfig in kitConfigs) {
513-
if (kitConfig[@"id"] != nil && [kitConfig[@"id"] integerValue] == 181) {
437+
if (kitConfig[@"id"] != nil && [kitConfig[@"id"] integerValue] == kMPRoktKitCode) {
514438
roktKitConfig = kitConfig;
515439
}
516440
}

0 commit comments

Comments
 (0)