Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OnSuccessHandler and OnFailureHandler to logoutUser() function #770

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions swift-sdk/Internal/InternalIterableAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -550,15 +550,15 @@ 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 {
return
}

if config.autoPushRegistration {
disableDeviceForCurrentUser()
disableDeviceForCurrentUser(withOnSuccess: onSuccess, onFailure: onFailure)
}

_email = nil
Expand Down
9 changes: 9 additions & 0 deletions swift-sdk/IterableAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
/// ```
Expand Down