From c8642166a59ac6108bb4396839ec88c5a5284def Mon Sep 17 00:00:00 2001 From: VishwaGhodasara Date: Mon, 20 May 2024 14:59:34 +0530 Subject: [PATCH 1/2] Add OnSuccessHandler and OnFailureHandler to logoutUser() function --- swift-sdk/Internal/InternalIterableAPI.swift | 8 ++++---- swift-sdk/IterableAPI.swift | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/swift-sdk/Internal/InternalIterableAPI.swift b/swift-sdk/Internal/InternalIterableAPI.swift index dcaa68a75..7c79c62e7 100644 --- a/swift-sdk/Internal/InternalIterableAPI.swift +++ b/swift-sdk/Internal/InternalIterableAPI.swift @@ -170,8 +170,8 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider { onLogin(authToken) } - func logoutUser() { - logoutPreviousUser() + func logoutUser(withOnSuccess onSuccess: OnSuccessHandler? = nil, onFailure: OnFailureHandler? = nil) { + logoutPreviousUser(withOnSuccess: onSuccess, onFailure: onFailure) } // MARK: - API Request Calls @@ -550,7 +550,7 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider { IterableUtil.isNotNullOrEmpty(string: _email) || IterableUtil.isNotNullOrEmpty(string: _userId) } - private func logoutPreviousUser() { + private func logoutPreviousUser(withOnSuccess onSuccess: OnSuccessHandler? = nil, onFailure: OnFailureHandler? = nil) { ITBInfo() guard isEitherUserIdOrEmailSet() else { @@ -558,7 +558,7 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider { } if config.autoPushRegistration { - disableDeviceForCurrentUser() + disableDeviceForCurrentUser(withOnSuccess: onSuccess, onFailure: onFailure) } _email = nil diff --git a/swift-sdk/IterableAPI.swift b/swift-sdk/IterableAPI.swift index e0cd044f4..1b0715bf6 100644 --- a/swift-sdk/IterableAPI.swift +++ b/swift-sdk/IterableAPI.swift @@ -186,8 +186,8 @@ import UIKit /// - Remark: This will empty out user specific authentication data and reset the in-app manager. /// If `autoPushRegistration` is `true` (which is the default value), this will also /// disable the current push token. - public static func logoutUser() { - implementation?.logoutUser() + public static func logoutUser(withOnSuccess onSuccess: OnSuccessHandler? = nil, onFailure: OnFailureHandler? = nil) { + implementation?.logoutUser(withOnSuccess: onSuccess, onFailure: onFailure) } /// The instance that manages getting and showing in-app messages From 045c9c009d20ee3d15d06174657eca3e6e3a414f Mon Sep 17 00:00:00 2001 From: Hardik Mashru Date: Tue, 21 May 2024 12:21:28 +0530 Subject: [PATCH 2/2] Update IterableAPI.swift --- swift-sdk/IterableAPI.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/swift-sdk/IterableAPI.swift b/swift-sdk/IterableAPI.swift index 1b0715bf6..24dcfdfd0 100644 --- a/swift-sdk/IterableAPI.swift +++ b/swift-sdk/IterableAPI.swift @@ -186,6 +186,15 @@ import UIKit /// - Remark: This will empty out user specific authentication data and reset the in-app manager. /// If `autoPushRegistration` is `true` (which is the default value), this will also /// disable the current push token. + public static func logoutUser() { + implementation?.logoutUser() + } + + /// Logs out the current user from the SDK instance, with custom completion blocks + /// + /// - Remark: This will empty out user specific authentication data and reset the in-app manager. + /// If `autoPushRegistration` is `true` (which is the default value), this will also + /// disable the current push token. public static func logoutUser(withOnSuccess onSuccess: OnSuccessHandler? = nil, onFailure: OnFailureHandler? = nil) { implementation?.logoutUser(withOnSuccess: onSuccess, onFailure: onFailure) }