Skip to content

Commit b15d372

Browse files
committed
implementation of updateEmail with token
1 parent 8c19600 commit b15d372

File tree

5 files changed

+14
-1
lines changed

5 files changed

+14
-1
lines changed

swift-sdk/Internal/AuthManager.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ class AuthManager: IterableAuthManagerProtocol {
5353
}
5454
}
5555

56+
func setNewAuthTokenDirectly(_ newToken: String) {
57+
ITBInfo()
58+
59+
onAuthTokenReceived(retrievedAuthToken: newToken, onSuccess: nil)
60+
}
61+
5662
func logoutUser() {
5763
ITBInfo()
5864

swift-sdk/Internal/InternalIterableAPI.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
204204
if self.email != nil {
205205
self.setEmail(newEmail)
206206
}
207+
208+
if let token = token {
209+
self.authManager.setNewAuthTokenDirectly(token)
210+
}
211+
207212
onSuccess?(json)
208213
}.onError { error in
209214
onFailure?(error.reason, error.data)

swift-sdk/IterableAPI.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public final class IterableAPI: NSObject {
309309
///
310310
/// - Parameters:
311311
/// - newEmail: The new email of this user
312-
/// - token: The new authentication token for this user
312+
/// - token: The new authentication token for this user, if left out, the SDK will not update the token in any way
313313
/// - onSuccess: `OnSuccessHandler` to invoke if update is successful
314314
/// - onFailure: `OnFailureHandler` to invoke if update fails
315315
///

swift-sdk/IterableAuthManagerProtocol.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ import Foundation
88
func getAuthToken() -> String?
99
func resetFailedAuthCount()
1010
func requestNewAuthToken(hasFailedPriorAuth: Bool, onSuccess: ((String?) -> Void)?)
11+
func setNewAuthTokenDirectly(_ newToken: String)
1112
func logoutUser()
1213
}

tests/unit-tests/AuthTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ class AuthTests: XCTestCase {
246246
XCTAssertEqual(API.email, updatedEmail)
247247
XCTAssertNil(API.userId)
248248
XCTAssertEqual(API.auth.authToken, updatedToken)
249+
249250
condition1.fulfill()
250251
} onFailure: { reason, data in
251252
XCTFail()

0 commit comments

Comments
 (0)