From 736013132a9c1650bda4d5f79fed511f90021446 Mon Sep 17 00:00:00 2001 From: Sumeru Chatterjee Date: Tue, 18 Nov 2025 17:04:23 +0000 Subject: [PATCH 1/2] Fix. --- swift-sdk/Internal/DeepLinkManager.swift | 19 +++++++++++++++---- .../Internal/Network/NetworkSession.swift | 2 ++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/swift-sdk/Internal/DeepLinkManager.swift b/swift-sdk/Internal/DeepLinkManager.swift index 42c914a54..2f5e9cb79 100644 --- a/swift-sdk/Internal/DeepLinkManager.swift +++ b/swift-sdk/Internal/DeepLinkManager.swift @@ -69,17 +69,28 @@ class DeepLinkManager: NSObject { if isIterableDeepLink(appLinkURL.absoluteString) { redirectUrlSession.makeDataRequest(with: appLinkURL) { [unowned self] _, _, error in - if let error = error { - ITBError("error: \(error.localizedDescription)") - fulfill.resolve(with: (nil, nil)) - } else { + // Check if we successfully captured redirect data FIRST + // The delegate callback happens before the error, so deepLinkLocation + // may be set even if we get NSURLErrorTimedOut (-1001) or + // NSURLErrorCancelled (-999) from cancelling the redirect + if self.deepLinkLocation != nil { + // We successfully intercepted the redirect if let deepLinkCampaignId = self.deepLinkCampaignId, let deepLinkTemplateId = self.deepLinkTemplateId, let deepLinkMessageId = self.deepLinkMessageId { fulfill.resolve(with: (self.deepLinkLocation, IterableAttributionInfo(campaignId: deepLinkCampaignId, templateId: deepLinkTemplateId, messageId: deepLinkMessageId))) } else { + // We have location but missing attribution cookies + // This is still a success case - user can navigate to the deep link fulfill.resolve(with: (self.deepLinkLocation, nil)) } + } else if let error = error { + // Only treat as error if we didn't capture the redirect location + ITBError("error: \(error.localizedDescription)") + fulfill.resolve(with: (nil, nil)) + } else { + // No redirect, no error - shouldn't happen but handle gracefully + fulfill.resolve(with: (nil, nil)) } } } else { diff --git a/swift-sdk/Internal/Network/NetworkSession.swift b/swift-sdk/Internal/Network/NetworkSession.swift index f891a7826..9ec0ddff3 100644 --- a/swift-sdk/Internal/Network/NetworkSession.swift +++ b/swift-sdk/Internal/Network/NetworkSession.swift @@ -114,11 +114,13 @@ extension RedirectNetworkSession: URLSessionDelegate, URLSessionTaskDelegate { guard let headerFields = response.allHeaderFields as? [String: String] else { delegate?.onRedirect(deepLinkLocation: deepLinkLocation, campaignId: campaignId, templateId: templateId, messageId: messageId) + completionHandler(nil) return } guard let url = response.url else { delegate?.onRedirect(deepLinkLocation: deepLinkLocation, campaignId: campaignId, templateId: templateId, messageId: messageId) + completionHandler(nil) return } From 462e30186e8b7ccb1b4d39ab7ecf787c557c9a80 Mon Sep 17 00:00:00 2001 From: Sumeru Chatterjee Date: Tue, 18 Nov 2025 17:31:12 +0000 Subject: [PATCH 2/2] Add agent to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f1bd0f34c..dc3711cf9 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,5 @@ CI.swift *.mdb .build/arm64-apple-macosx/debug/IterableSDK.build/output-file-map.json .build + +agent/ \ No newline at end of file