diff --git a/mParticle-Apple-SDK/Utils/MPStateMachine.m b/mParticle-Apple-SDK/Utils/MPStateMachine.m index 1c35b8c0..adb58fa4 100644 --- a/mParticle-Apple-SDK/Utils/MPStateMachine.m +++ b/mParticle-Apple-SDK/Utils/MPStateMachine.m @@ -385,43 +385,7 @@ - (NSString *)deviceTokenType { } - (NSNumber *)firstSeenInstallation { - if (_firstSeenInstallation != nil) { - return _firstSeenInstallation; - } - - MPIUserDefaults *userDefaults = [MPIUserDefaults standardUserDefaults]; - NSNumber *firstSeenInstallation = userDefaults[kMPAppFirstSeenInstallationKey]; - if (firstSeenInstallation != nil) { - _firstSeenInstallation = firstSeenInstallation; - } else { - [self willChangeValueForKey:@"firstSeenInstallation"]; - _firstSeenInstallation = @YES; - [self didChangeValueForKey:@"firstSeenInstallation"]; - - dispatch_async(dispatch_get_main_queue(), ^{ - userDefaults[kMPAppFirstSeenInstallationKey] = self->_firstSeenInstallation; - }); - } - - return _firstSeenInstallation; -} - -- (void)setFirstSeenInstallation:(NSNumber *)firstSeenInstallation { - if (_firstSeenInstallation != nil) { - return; - } - - MPIUserDefaults *userDefaults = [MPIUserDefaults standardUserDefaults]; - NSNumber *fsi = userDefaults[kMPAppFirstSeenInstallationKey]; - if (fsi == nil) { - [self willChangeValueForKey:@"firstSeenInstallation"]; - _firstSeenInstallation = firstSeenInstallation; - [self didChangeValueForKey:@"firstSeenInstallation"]; - - dispatch_async(dispatch_get_main_queue(), ^{ - userDefaults[kMPAppFirstSeenInstallationKey] = self->_firstSeenInstallation; - }); - } + return (_firstSeenInstallation == nil) ? @NO : _firstSeenInstallation; } - (MPInstallationType)installationType { @@ -440,6 +404,7 @@ - (MPInstallationType)installationType { } } else { _installationType = MPInstallationTypeKnownInstall; + _firstSeenInstallation = @YES; } [self didChangeValueForKey:@"installationType"]; @@ -452,7 +417,7 @@ - (void)setInstallationType:(MPInstallationType)installationType { _installationType = installationType; [self didChangeValueForKey:@"installationType"]; - self.firstSeenInstallation = installationType != MPInstallationTypeKnownUpgrade ? @YES : @NO; + _firstSeenInstallation = @(installationType == MPInstallationTypeKnownInstall); } #if TARGET_OS_IOS == 1