diff --git a/SessionMessagingKit/Sending & Receiving/Notifications/PushNotificationAPI.swift b/SessionMessagingKit/Sending & Receiving/Notifications/PushNotificationAPI.swift index 71ce28c64..642b767c4 100644 --- a/SessionMessagingKit/Sending & Receiving/Notifications/PushNotificationAPI.swift +++ b/SessionMessagingKit/Sending & Receiving/Notifications/PushNotificationAPI.swift @@ -428,7 +428,10 @@ public enum PushNotificationAPI { ), let notification: BencodeResponse = try? BencodeDecoder(using: dependencies) .decode(BencodeResponse.self, from: decryptedData) - else { return (nil, .invalid, .failure) } + else { + SNLog("Failed to decrypt or decode notification") + return (nil, .invalid, .failure) + } // If the metadata says that the message was too large then we should show the generic // notification (this is a valid case) @@ -438,7 +441,10 @@ public enum PushNotificationAPI { guard let notificationData: Data = notification.data, notification.info.dataLength == notificationData.count - else { return (nil, notification.info, .failureNoContent) } + else { + SNLog("Get notification data failed") + return (nil, notification.info, .failureNoContent) + } // Success, we have the notification content return (notificationData, notification.info, .success) diff --git a/SessionUtilitiesKit/Utilities/BencodeResponse.swift b/SessionUtilitiesKit/Utilities/BencodeResponse.swift index d3ec8e4b9..b2b2b784e 100644 --- a/SessionUtilitiesKit/Utilities/BencodeResponse.swift +++ b/SessionUtilitiesKit/Utilities/BencodeResponse.swift @@ -15,13 +15,16 @@ extension BencodeResponse: Decodable { info = try { /// First try to decode it directly if let info: T = try? container.decode(T.self) { + SNLog("Successfully decoded info directly") return info } /// If that failed then we need to reset the container and try decode it as a JSON string container = try decoder.unkeyedContainer() let infoString: String = try container.decode(String.self) + SNLog("Successfully decoded info to JSON string") let infoData: Data = try infoString.data(using: .ascii) ?? { throw NetworkError.parsingFailed }() + SNLog("Successfully decoded info to JSON data") return try JSONDecoder(using: decoder.dependencies).decode(T.self, from: infoData) }()