diff --git a/mParticle-Apple-SDK/Network/MPNetworkCommunication.m b/mParticle-Apple-SDK/Network/MPNetworkCommunication.m index e004fbbc7..93503c3a4 100644 --- a/mParticle-Apple-SDK/Network/MPNetworkCommunication.m +++ b/mParticle-Apple-SDK/Network/MPNetworkCommunication.m @@ -394,7 +394,9 @@ - (NSNumber *)maxAgeForCache:(nonnull NSString *)cache { } - (void)checkResponseCodeToDisableEventLogging:(NSInteger)responseCode { - if (responseCode == HTTPStatusCodeBadRequest || responseCode == HTTPStatusCodeUnauthorized || responseCode == HTTPStatusCodeForbidden) { + NSNumber *currentStatus = [MParticle sharedInstance].stateMachine.attAuthorizationStatus; + + if (responseCode == HTTPStatusCodeBadRequest || responseCode == HTTPStatusCodeUnauthorized || responseCode == HTTPStatusCodeForbidden || currentStatus.integerValue == MPATTAuthorizationStatusDenied) { [MPStateMachine setCanWriteMessagesToDB:NO]; MPILogError(@"API Key appears to be invalid based on server response, disabling event logging to prevent excessive local database growth"); } else { diff --git a/mParticle-Apple-SDK/mParticle.m b/mParticle-Apple-SDK/mParticle.m index 4e4e7dc00..025d0059b 100644 --- a/mParticle-Apple-SDK/mParticle.m +++ b/mParticle-Apple-SDK/mParticle.m @@ -1047,6 +1047,13 @@ - (void)setATTStatus:(MPATTAuthorizationStatus)status withATTStatusTimestampMill if (attStatusTimestampMillis != nil) { [MParticle sharedInstance].stateMachine.attAuthorizationTimestamp = attStatusTimestampMillis; } + + if (status == MPATTAuthorizationStatusDenied) { + [MPStateMachine setCanWriteMessagesToDB:NO]; + MPILogError(@"ATT Status is denied, disabling event logging to prevent excessive local database growth"); + } else { + [MPStateMachine setCanWriteMessagesToDB:YES]; + } } }