Skip to content

Commit bba3736

Browse files
Execute pending notification response.
1 parent 2b477fe commit bba3736

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

swift-sdk/Internal/IterableAPIInternal.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ final class IterableAPIInternal: NSObject, PushTrackerProtocol, AuthProvider {
357357

358358
private var config: IterableConfig
359359

360+
static var pendingNotificationResponse: NotificationResponseProtocol?
361+
360362
private let dateProvider: DateProviderProtocol
361363
private let inAppDisplayer: InAppDisplayerProtocol
362364
private var notificationStateProvider: NotificationStateProviderProtocol
@@ -514,6 +516,8 @@ final class IterableAPIInternal: NSObject, PushTrackerProtocol, AuthProvider {
514516

515517
handle(launchOptions: launchOptions)
516518

519+
handlePendingNotifications()
520+
517521
requestProcessor.start()
518522

519523
return inAppManager.start()
@@ -536,6 +540,15 @@ final class IterableAPIInternal: NSObject, PushTrackerProtocol, AuthProvider {
536540
}
537541
}
538542

543+
private func handlePendingNotifications() {
544+
if let pendingNotificationResponse = Self.pendingNotificationResponse {
545+
if #available(iOS 10.0, *) {
546+
IterableAppIntegration.implementation?.userNotificationCenter(nil, didReceive: pendingNotificationResponse, withCompletionHandler: nil)
547+
}
548+
Self.pendingNotificationResponse = nil
549+
}
550+
}
551+
539552
private func checkForDeferredDeepLink() {
540553
guard config.checkForDeferredDeeplink else {
541554
return

swift-sdk/Internal/IterableAppIntegrationInternal.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ struct SystemNotificationStateProvider: NotificationStateProviderProtocol {
4747
}
4848
}
4949

50-
@available(iOS 10.0, *)
5150
public protocol NotificationResponseProtocol {
5251
var userInfo: [AnyHashable: Any] { get }
5352

swift-sdk/IterableAppIntegration.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ import UserNotifications
4545
withCompletionHandler completionHandler: (() -> Void)?) {
4646
ITBInfo()
4747

48-
implementation?.userNotificationCenter(center,
49-
didReceive: UserNotificationResponse(response: response),
50-
withCompletionHandler: completionHandler)
48+
if let implementation = implementation {
49+
implementation.userNotificationCenter(center,
50+
didReceive: UserNotificationResponse(response: response),
51+
withCompletionHandler: completionHandler)
52+
} else {
53+
IterableAPIInternal.pendingNotificationResponse = UserNotificationResponse(response: response)
54+
}
5155
}
5256

5357
// MARK: Private

0 commit comments

Comments
 (0)