Skip to content

Commit

Permalink
address outdated code
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonStalnaker committed Nov 8, 2024
1 parent 90a9e48 commit c46b857
Showing 1 changed file with 2 additions and 37 deletions.
39 changes: 2 additions & 37 deletions mParticle-Apple-SDK/Utils/MPStateMachine.m
Original file line number Diff line number Diff line change
Expand Up @@ -385,45 +385,9 @@ - (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;
});
}
}

- (MPInstallationType)installationType {
if (_installationType != MPInstallationTypeAutodetect) {
return _installationType;
Expand All @@ -440,6 +404,7 @@ - (MPInstallationType)installationType {
}
} else {
_installationType = MPInstallationTypeKnownInstall;
_firstSeenInstallation = @YES;
}

[self didChangeValueForKey:@"installationType"];
Expand All @@ -452,7 +417,7 @@ - (void)setInstallationType:(MPInstallationType)installationType {
_installationType = installationType;
[self didChangeValueForKey:@"installationType"];

self.firstSeenInstallation = (installationType != MPInstallationTypeKnownUpgrade && installationType != MPInstallationTypeKnownSameVersion) ? @YES : @NO;
_firstSeenInstallation = @(installationType == MPInstallationTypeKnownInstall);
}

#if TARGET_OS_IOS == 1
Expand Down

0 comments on commit c46b857

Please sign in to comment.