Skip to content

Commit ef88dda

Browse files
Only set new email on updateEmail if it was using email.
1 parent 236d92c commit ef88dda

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Tests/swift-sdk-swift-tests/IterableAPITests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ class IterableAPITests: XCTestCase {
205205
let body = networkSession.getRequestBody()
206206
TestUtils.validateElementPresent(withName: AnyHashable.ITBL_KEY_NEW_EMAIL, andValue: newEmail, inDictionary: body)
207207
TestUtils.validateElementPresent(withName: AnyHashable.ITBL_KEY_CURRENT_USER_ID, andValue: currentUserId, inDictionary: body)
208-
XCTAssertEqual(IterableAPI.email, newEmail)
208+
XCTAssertEqual(IterableAPI.userId, currentUserId)
209209
expectation.fulfill()
210210
},
211211
onFailure: {(reason, _) in

swift-sdk/Internal/IterableAPIInternal.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@ final class IterableAPIInternal : NSObject, PushTrackerProtocol {
225225
if let request = createPostRequest(forPath: .ITBL_PATH_UPDATE_EMAIL, withBody: args) {
226226
sendRequest(request,
227227
onSuccess: { data in
228-
self.email = newEmail
228+
if let _ = self.email {
229+
// we change the email only if we were using email before
230+
self.email = newEmail
231+
}
229232
onSuccess?(data)
230233
},
231234
onFailure: onFailure)

0 commit comments

Comments
 (0)