Skip to content

Commit b599eef

Browse files
authored
feat: Add marketing cloud ID override (#20)
1 parent f76783e commit b599eef

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

mParticle-Adobe/MPKitAdobe.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@
2020
@property (nonatomic, unsafe_unretained, readonly) BOOL started;
2121
@property (nonatomic, strong, nullable) MPKitAPI *kitApi;
2222

23+
+ (void)overrideMarketingCloudId:(NSString * _Nullable)mid;
24+
2325
@end

mParticle-Adobe/MPKitAdobe.m

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ @interface MPKitAdobe ()
2828

2929
@implementation MPKitAdobe
3030

31+
static NSString *_midOverride = nil;
32+
3133
+ (NSNumber *)kitCode {
3234
return @124;
3335
}
@@ -39,6 +41,9 @@ + (void)load {
3941
[MParticle registerExtension:kitRegister];
4042
}
4143

44+
+ (void)overrideMarketingCloudId:(NSString *)mid {
45+
_midOverride = mid;
46+
}
4247

4348
#pragma mark MPKitInstanceProtocol methods
4449

@@ -119,12 +124,15 @@ - (NSString *)pushToken {
119124
}
120125

121126
- (void)sendNetworkRequest {
122-
NSString *marketingCloudId = [self marketingCloudIdFromIntegrationAttributes];
127+
NSString *marketingCloudId = _midOverride;
123128
if (!marketingCloudId) {
124-
marketingCloudId = [_adobe marketingCloudIdFromUserDefaults];
125-
if (marketingCloudId.length) {
126-
[[MParticle sharedInstance] setIntegrationAttributes:@{marketingCloudIdIntegrationAttributeKey: marketingCloudId} forKit:[[self class] kitCode]];
127-
_hasSetMCID = YES;
129+
marketingCloudId = [self marketingCloudIdFromIntegrationAttributes];
130+
if (!marketingCloudId) {
131+
marketingCloudId = [_adobe marketingCloudIdFromUserDefaults];
132+
if (marketingCloudId.length) {
133+
[[MParticle sharedInstance] setIntegrationAttributes:@{marketingCloudIdIntegrationAttributeKey: marketingCloudId} forKit:[[self class] kitCode]];
134+
_hasSetMCID = YES;
135+
}
128136
}
129137
}
130138

@@ -140,7 +148,7 @@ - (void)sendNetworkRequest {
140148

141149
NSMutableDictionary *integrationAttributes = [NSMutableDictionary dictionary];
142150
if (marketingCloudId.length) {
143-
[integrationAttributes setObject:marketingCloudId forKey:marketingCloudIdIntegrationAttributeKey];
151+
[integrationAttributes setObject:(_midOverride ?: marketingCloudId) forKey:marketingCloudIdIntegrationAttributeKey];
144152
}
145153
if (locationHint.length) {
146154
[integrationAttributes setObject:locationHint forKey:locationHintIntegrationAttributeKey];

0 commit comments

Comments
 (0)