Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@
3CF11E3D2C6D6155002856F5 /* UserExecutorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CF11E3C2C6D6155002856F5 /* UserExecutorTests.swift */; };
354E0C59BA9B18437C36215B /* UserExecutorRetryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C310B6C569E96C204F8CD68 /* UserExecutorRetryTests.swift */; };
B5481A0100000000000000AA /* ExecutorRetryBackoffTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5481A0100000000000000A9 /* ExecutorRetryBackoffTests.swift */; };
B5537A0100000000000000AA /* RequestFailureLogLevelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5537A0100000000000000A9 /* RequestFailureLogLevelTests.swift */; };
3CF11E402C6E6DE2002856F5 /* MockNewRecordsState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CF11E3F2C6E6DE2002856F5 /* MockNewRecordsState.swift */; };
3CF1A5632C669EA40056B3AA /* OSNewRecordsState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CF1A5622C669EA40056B3AA /* OSNewRecordsState.swift */; };
B5481A0100000000000000A4 /* OSRequestRetryBackoff.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5481A0100000000000000A3 /* OSRequestRetryBackoff.swift */; };
Expand Down Expand Up @@ -1570,6 +1571,7 @@
3CF11E3C2C6D6155002856F5 /* UserExecutorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserExecutorTests.swift; sourceTree = "<group>"; };
6C310B6C569E96C204F8CD68 /* UserExecutorRetryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserExecutorRetryTests.swift; sourceTree = "<group>"; };
B5481A0100000000000000A9 /* ExecutorRetryBackoffTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExecutorRetryBackoffTests.swift; sourceTree = "<group>"; };
B5537A0100000000000000A9 /* RequestFailureLogLevelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestFailureLogLevelTests.swift; sourceTree = "<group>"; };
3CF11E3F2C6E6DE2002856F5 /* MockNewRecordsState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockNewRecordsState.swift; sourceTree = "<group>"; };
3CF1A5622C669EA40056B3AA /* OSNewRecordsState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSNewRecordsState.swift; sourceTree = "<group>"; };
B5481A0100000000000000A3 /* OSRequestRetryBackoff.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSRequestRetryBackoff.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2643,6 +2645,7 @@
3CF11E3C2C6D6155002856F5 /* UserExecutorTests.swift */,
6C310B6C569E96C204F8CD68 /* UserExecutorRetryTests.swift */,
B5481A0100000000000000A9 /* ExecutorRetryBackoffTests.swift */,
B5537A0100000000000000A9 /* RequestFailureLogLevelTests.swift */,
3CA93BC3300AEFFA000724B3 /* SubscriptionUpdateRaceTests.swift */,
C95B2AD05FFF9FC12C9D5878 /* ExecutorReadYourWriteTests.swift */,
3C5181A1B2C3D4E5F6A7B801 /* SubscriptionCreateResponseTests.swift */,
Expand Down Expand Up @@ -4832,6 +4835,7 @@
3CF11E3D2C6D6155002856F5 /* UserExecutorTests.swift in Sources */,
354E0C59BA9B18437C36215B /* UserExecutorRetryTests.swift in Sources */,
B5481A0100000000000000AA /* ExecutorRetryBackoffTests.swift in Sources */,
B5537A0100000000000000AA /* RequestFailureLogLevelTests.swift in Sources */,
3C67F77A2BEB2B710085A0F0 /* SwitchUserIntegrationTests.swift in Sources */,
3CC063EE2B6D7FE8002BB07F /* OneSignalUserTests.swift in Sources */,
A5426001A1B2C3D4E5F60006 /* InputGuardUserTests.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ - (OneSignalClientError *)privacyConsentErrorWithRequestType:(NSString *)type {
- (void)executeRequest:(OneSignalRequest *)request onSuccess:(OSResultSuccessBlock)successBlock onFailure:(OSClientFailureBlock)failureBlock {
// If privacy consent is required but not yet given, any non-GET request should be blocked.
if (request.method != GET && [OSPrivacyConsentController shouldLogMissingPrivacyConsentErrorWithMethodName:nil]) {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"Attempted to perform an HTTP request (%@) before the user provided privacy consent."];
OneSignalClientError *consentError = [self privacyConsentErrorWithRequestType:NSStringFromClass(request.class)];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:consentError.message];
if (failureBlock) {
failureBlock([self privacyConsentErrorWithRequestType:NSStringFromClass(request.class)]);
failureBlock(consentError);
}

return;
Expand Down Expand Up @@ -224,6 +225,9 @@ - (void)handleJSONNSURLResponse:(NSURLResponse*)response data:(NSData*)data erro

[OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:[NSString stringWithFormat:@"network response (%@) with URL %@: %@", NSStringFromClass([request class]), request.urlRequest.URL.absoluteString, innerJson]];
if (jsonError) {
if (statusCode >= 200 && statusCode < 300) {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"Response to %@ with status %ld is not valid JSON: %@", NSStringFromClass([request class]), (long)statusCode, jsonError]];
}
if (failureBlock != nil)
failureBlock([[OneSignalClientError alloc] initWithCode:statusCode message:@"Error parsing JSON" responseHeaders:headers response:nil underlyingError:jsonError]);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ + (void)setRequiresPrivacyConsent:(BOOL)required {
return;

if ([self requiresUserPrivacyConsent] && !required) {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"Cannot change setConsentRequired() from TRUE to FALSE"];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"Cannot change setConsentRequired() from TRUE to FALSE"];
return;
}
[OneSignalUserDefaults.initShared saveBoolForKey:OSUD_REQUIRES_USER_PRIVACY_CONSENT withValue:required];
Expand Down
22 changes: 11 additions & 11 deletions iOS_SDK/OneSignalSDK/OneSignalCore/Source/OSStubInAppMessages.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,48 +36,48 @@ @implementation OSStubInAppMessages
}

+ (void)addClickListener:(NSObject<OSInAppMessageClickListener> * _Nullable)listener {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
}

+ (void)addLifecycleListener:(NSObject<OSInAppMessageLifecycleListener> * _Nullable)listener {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
}

+ (void)addTrigger:(NSString * _Nonnull)key withValue:(NSString * _Nonnull)value {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
}

+ (void)addTriggers:(NSDictionary<NSString *,NSString *> * _Nonnull)triggers {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
}

+ (void)clearTriggers {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
}

+ (BOOL)paused {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
return true;
}

+ (void)paused:(BOOL)pause {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
}

+ (void)removeClickListener:(NSObject<OSInAppMessageClickListener> * _Nullable)listener {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
}

+ (void)removeLifecycleListener:(NSObject<OSInAppMessageLifecycleListener> * _Nullable)listener {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
}

+ (void)removeTrigger:(NSString * _Nonnull)key {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
}

+ (void)removeTriggers:(NSArray<NSString *> * _Nonnull)keys {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."];
}

@end
6 changes: 3 additions & 3 deletions iOS_SDK/OneSignalSDK/OneSignalCore/Source/OSStubLocation.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ @implementation OSStubLocation
}

+ (BOOL)isShared {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalLocation not found. In order to use OneSignal's location features the OneSignalLocation module must be added."];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalLocation not found. In order to use OneSignal's location features the OneSignalLocation module must be added."];
return false;
}

+ (void)requestPermission {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalLocation not found. In order to use OneSignal's location features the OneSignalLocation module must be added."];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalLocation not found. In order to use OneSignal's location features the OneSignalLocation module must be added."];
}

+ (void)setShared:(BOOL)enable {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalLocation not found. In order to use OneSignal's location features the OneSignalLocation module must be added."];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalLocation not found. In order to use OneSignal's location features the OneSignalLocation module must be added."];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ @implementation DirectDownloadDelegate
-(void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data {
NSError *fileHandleError;
if (![outputHandle writeData:data error:&fileHandleError]) {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"OneSignal Error encountered while downloading attachment: %@", fileHandleError]];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:[NSString stringWithFormat:@"OneSignal Error encountered while downloading attachment: %@", fileHandleError]];
}
}

Expand Down Expand Up @@ -271,7 +271,7 @@ + (NSString *)downloadMediaAndSaveInBundle:(NSString *)urlString {
let mimeType = [NSURLSession downloadItemAtURL:url toFile:filePath error:&error];

if (error) {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"Encountered an error while attempting to download file with URL: %@", error]];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:[NSString stringWithFormat:@"Encountered an error while attempting to download file with URL: %@", error]];
return nil;
}

Expand All @@ -286,7 +286,7 @@ + (NSString *)downloadMediaAndSaveInBundle:(NSString *)urlString {
[[NSFileManager defaultManager] moveItemAtPath:filePath toPath:newPath error:&error];

if (error) {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"Encountered an error while attempting to download file with URL: %@", error]];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:[NSString stringWithFormat:@"Encountered an error while attempting to download file with URL: %@", error]];
return nil;
}

Expand All @@ -304,7 +304,7 @@ + (NSString *)downloadMediaAndSaveInBundle:(NSString *)urlString {
[standardUserDefaults saveObjectForKey:OSUD_TEMP_CACHED_NOTIFICATION_MEDIA withValue:appendedCache];
return name;
} @catch (NSException *exception) {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"OneSignal encountered an exception while downloading file (%@), exception: %@", url, exception.description]];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:[NSString stringWithFormat:@"OneSignal encountered an exception while downloading file (%@), exception: %@", url, exception.description]];

return nil;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ + (void)onNotificationReceived:(NSString *)receivedNotificationId withBlockingTa
dispatch_semaphore_signal(semaphore);
}
} failureBlock:^(NSError *error) {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"OneSignal onNotificationReceived sendReceiveReceipt Failed for playerId: %@ error: %@", playerId, error]];
// The error is nil when no receipt was attempted, such as when receipts are disabled.
if (error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also swallows HTTP failures. The controller forwards error.underlyingError, and OneSignalClient leaves that nil for status responses, so a 4xx/5xx arrives as failure(nil) and logs nothing. Disabled receipts use the same nil.

Pass the OneSignalClientError through (or a skip callback for disabled/missing appId). WARN on real attempt failures; stay quiet only when nothing was sent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTTP failures still log. OneSignalClientError fills underlyingError with an NSError carrying the status code when there is no transport error (OneSignalClientError.m, in the initializer). So a 4xx or 5xx reaches this block with an error and logs WARN. Only the two failure(nil) calls, for a missing app ID and for disabled receipts, stay quiet.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTTP failures still reach here with a synthesized underlyingError. Agreed.

failure(nil) also covers a missing appId in the receipts controller (shared App Group / defaults), not only disabled receipts. That setup mistake used to surface as ERROR and is now quiet above DEBUG. WARN in the controller for !appId, or pass a distinguishable error so this guard can separate skip from misconfig.

[OneSignalLog onesignalLog:ONE_S_LL_WARN message:[NSString stringWithFormat:@"OneSignal onNotificationReceived sendReceiveReceipt Failed for playerId: %@ error: %@", playerId, error]];
}
if (semaphore) {
dispatch_semaphore_signal(semaphore);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ - (void)resetRedisplayMessagesBySession {

- (void)deleteInactiveMessage:(OSInAppMessageInternal *)message {
let deleteMessage = [NSString stringWithFormat:@"Deleting inactive in-app message from cache: %@", message.messageId];
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:deleteMessage];
[OneSignalLog onesignalLog:ONE_S_LL_DEBUG message:deleteMessage];
NSMutableArray *newMessagesArray = [NSMutableArray arrayWithArray:self.messages];
[newMessagesArray removeObject: message];
self.messages = newMessagesArray;
Expand Down Expand Up @@ -872,7 +872,7 @@ - (void)messageViewPageImpressionRequest:(OSInAppMessageInternal *)message withP
}
onFailure:^(OneSignalClientError *error) {
NSString *errorMessage = [NSString stringWithFormat:@"In App Message with message id: %@ and page id: %@, failed POST page impression update with error: %@", message.messageId, pageId, error.message];
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:errorMessage];
[OneSignalLog onesignalLog:ONE_S_LL_INFO message:errorMessage];
if (message) {
[self.viewedPageIDs removeObject:messagePrefixedPageId];
}
Expand Down Expand Up @@ -912,7 +912,7 @@ - (void)messageViewImpressionRequest:(OSInAppMessageInternal *)message {
}
onFailure:^(OneSignalClientError *error) {
NSString *errorMessage = [NSString stringWithFormat:@"In App Message with id: %@, failed POST impression update with error: %@", message.messageId, error.message];
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:errorMessage];
[OneSignalLog onesignalLog:ONE_S_LL_INFO message:errorMessage];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the page-impression and click POSTs below. These are not retried automatically; clearing the local set only helps if the message shows or the user clicks again. WARN to match content-load, or call out the INFO choice in the PR body.


// If the post failed, remove the messageId from the impressionedInAppMessages set
[self.impressionedInAppMessages removeObject:message.messageId];
Expand Down Expand Up @@ -1333,7 +1333,7 @@ - (void)sendClickRESTCall:(OSInAppMessageInternal *)message withAction:(OSInAppM
}
onFailure:^(OneSignalClientError *error) {
NSString *errorMessage = [NSString stringWithFormat:@"In App Message with id: %@, failed POST click update for click id: %@, with error: %@", message.messageId, action.clickId, error.message];
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:errorMessage];
[OneSignalLog onesignalLog:ONE_S_LL_INFO message:errorMessage];

// Remove clickId from local clickedClickIds since click was not tracked
[self.clickedClickIds removeObject:action.clickId];
Expand All @@ -1359,7 +1359,7 @@ - (void)sendOutcomes:(NSArray<OSInAppMessageOutcome *>*)outcomes forMessageId:(N

- (void)sendClickActionOutcomes:(NSArray<OSInAppMessageOutcome *> *)outcomes {
if (![OSOutcomes sharedController]) {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"Make sure OneSignal init is called first"];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"Make sure OneSignal init is called first"];
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ - (void)handlePrompt:(void (^)(PromptActionResult result))completionHandler {
[invocation setArgument: &completionHandler atIndex: 3];
[invocation invoke];
} else {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalLocation not found. In order to use OneSignal's location features the OneSignalLocation module must be added."];
[OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalLocation not found. In order to use OneSignal's location features the OneSignalLocation module must be added."];
}
}

Expand Down
Loading
Loading