diff --git a/swift-sdk/Internal/InternalIterableAPI.swift b/swift-sdk/Internal/InternalIterableAPI.swift index 1b165fdad..b3d5e29e2 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 07ad96b40..17021efb4 100644 --- a/swift-sdk/IterableAPI.swift +++ b/swift-sdk/IterableAPI.swift @@ -190,6 +190,15 @@ import UIKit 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) + } + /// The instance that manages getting and showing in-app messages /// /// ```