diff --git a/Examples/DeveloperCocoapodsExample/Podfile.lock b/Examples/DeveloperCocoapodsExample/Podfile.lock index 4960780af..d06cc1694 100644 --- a/Examples/DeveloperCocoapodsExample/Podfile.lock +++ b/Examples/DeveloperCocoapodsExample/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - Appcues (3.1.8) + - Appcues (3.1.9) - AppcuesNotificationService (0.1.0) DEPENDENCIES: @@ -13,7 +13,7 @@ EXTERNAL SOURCES: :path: "../../AppcuesNotificationService.podspec" SPEC CHECKSUMS: - Appcues: e5c348611d6f77f075898b1eff6ca2a53e47d7b0 + Appcues: 58ee609e4cff59090b20e8b251bc4ad2a5cc8cf0 AppcuesNotificationService: f7f11e9b156c50106b64b11f55eb0e02586198bd PODFILE CHECKSUM: 24c643e3c9c013c74f5d561608aa37768cb0c43e diff --git a/Sources/AppcuesKit/Data/Networking/NetworkClient.swift b/Sources/AppcuesKit/Data/Networking/NetworkClient.swift index 5dff3584b..672d8cc77 100644 --- a/Sources/AppcuesKit/Data/Networking/NetworkClient.swift +++ b/Sources/AppcuesKit/Data/Networking/NetworkClient.swift @@ -173,11 +173,12 @@ internal class NetworkClient: Networking { _ urlRequest: URLRequest, completion: @escaping (_ result: Result) -> Void ) { - let dataTask = config.urlSession.dataTask(with: urlRequest) { [weak self] _, response, error in + let dataTask = config.urlSession.dataTask(with: urlRequest) { [weak self] data, response, error in let url = (response?.url ?? urlRequest.url)?.absoluteString ?? "" let statusCode = (response as? HTTPURLResponse)?.statusCode ?? -1 + let logData = String(data: error?.data ?? data ?? Data.empty, encoding: .utf8) ?? "" - self?.config.logger.debug("RESPONSE: %{public}d %{public}@", statusCode, url) + self?.config.logger.debug("RESPONSE: %{public}d %{public}@\n%{private}@", statusCode, url, logData) if let error = error { completion(.failure(error)) diff --git a/Sources/AppcuesKit/Presentation/DeepLinkHandler.swift b/Sources/AppcuesKit/Presentation/DeepLinkHandler.swift index 3e5ff6c4e..80f4dc86e 100644 --- a/Sources/AppcuesKit/Presentation/DeepLinkHandler.swift +++ b/Sources/AppcuesKit/Presentation/DeepLinkHandler.swift @@ -126,7 +126,7 @@ internal class DeepLinkHandler: DeepLinkHandling { published: false, queryItems: queryItems, trigger: .preview, - completion: previewCompletion + completion: experiencePreviewCompletion ) case let .show(experienceID, queryItems): container?.resolve(ContentLoading.self).load( @@ -141,7 +141,7 @@ internal class DeepLinkHandler: DeepLinkHandling { id: id, published: false, queryItems: queryItems, - completion: nil + completion: pushPreviewCompletion ) case let .pushContent(id): container?.resolve(ContentLoading.self).loadPush( @@ -159,7 +159,7 @@ internal class DeepLinkHandler: DeepLinkHandling { } } - private func previewCompletion(_ result: Result) { + private func experiencePreviewCompletion(_ result: Result) { guard case let .failure(error) = result else { return } @@ -183,6 +183,25 @@ internal class DeepLinkHandler: DeepLinkHandling { container?.resolve(UIDebugging.self).showToast(toast) } + private func pushPreviewCompletion(_ result: Result) { + guard case let .failure(error) = result else { + return + } + + let message: String + switch error { + case NetworkingError.nonSuccessfulStatusCode(404): + message = "Push notification not found." + case is NetworkingError: + message = "Error loading push notification preview." + default: + message = "Push notification preview failed." + } + + let toast = DebugToast(message: .custom(text: message), style: .failure) + container?.resolve(UIDebugging.self).showToast(toast) + } + @objc private func sceneDidActivate() { actionsToHandle.forEach(handle(action:))