Skip to content

Commit 3d18f8b

Browse files
fix: Address firstInstall Edge Case (#312)
* fix: Address firstInstall Edge Case
1 parent 9470b18 commit 3d18f8b

File tree

1 file changed

+3
-38
lines changed

1 file changed

+3
-38
lines changed

mParticle-Apple-SDK/Utils/MPStateMachine.m

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -385,43 +385,7 @@ - (NSString *)deviceTokenType {
385385
}
386386

387387
- (NSNumber *)firstSeenInstallation {
388-
if (_firstSeenInstallation != nil) {
389-
return _firstSeenInstallation;
390-
}
391-
392-
MPIUserDefaults *userDefaults = [MPIUserDefaults standardUserDefaults];
393-
NSNumber *firstSeenInstallation = userDefaults[kMPAppFirstSeenInstallationKey];
394-
if (firstSeenInstallation != nil) {
395-
_firstSeenInstallation = firstSeenInstallation;
396-
} else {
397-
[self willChangeValueForKey:@"firstSeenInstallation"];
398-
_firstSeenInstallation = @YES;
399-
[self didChangeValueForKey:@"firstSeenInstallation"];
400-
401-
dispatch_async(dispatch_get_main_queue(), ^{
402-
userDefaults[kMPAppFirstSeenInstallationKey] = self->_firstSeenInstallation;
403-
});
404-
}
405-
406-
return _firstSeenInstallation;
407-
}
408-
409-
- (void)setFirstSeenInstallation:(NSNumber *)firstSeenInstallation {
410-
if (_firstSeenInstallation != nil) {
411-
return;
412-
}
413-
414-
MPIUserDefaults *userDefaults = [MPIUserDefaults standardUserDefaults];
415-
NSNumber *fsi = userDefaults[kMPAppFirstSeenInstallationKey];
416-
if (fsi == nil) {
417-
[self willChangeValueForKey:@"firstSeenInstallation"];
418-
_firstSeenInstallation = firstSeenInstallation;
419-
[self didChangeValueForKey:@"firstSeenInstallation"];
420-
421-
dispatch_async(dispatch_get_main_queue(), ^{
422-
userDefaults[kMPAppFirstSeenInstallationKey] = self->_firstSeenInstallation;
423-
});
424-
}
388+
return (_firstSeenInstallation == nil) ? @NO : _firstSeenInstallation;
425389
}
426390

427391
- (MPInstallationType)installationType {
@@ -440,6 +404,7 @@ - (MPInstallationType)installationType {
440404
}
441405
} else {
442406
_installationType = MPInstallationTypeKnownInstall;
407+
_firstSeenInstallation = @YES;
443408
}
444409

445410
[self didChangeValueForKey:@"installationType"];
@@ -452,7 +417,7 @@ - (void)setInstallationType:(MPInstallationType)installationType {
452417
_installationType = installationType;
453418
[self didChangeValueForKey:@"installationType"];
454419

455-
self.firstSeenInstallation = installationType != MPInstallationTypeKnownUpgrade ? @YES : @NO;
420+
_firstSeenInstallation = @(installationType == MPInstallationTypeKnownInstall);
456421
}
457422

458423
#if TARGET_OS_IOS == 1

0 commit comments

Comments
 (0)