Skip to content

Commit fa20222

Browse files
Only set new email on updateEmail if it was using email.
1 parent 2280294 commit fa20222

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
@@ -177,7 +177,7 @@ class IterableAPITests: XCTestCase {
177177
let body = networkSession.getRequestBody()
178178
TestUtils.validateElementPresent(withName: AnyHashable.ITBL_KEY_NEW_EMAIL, andValue: newEmail, inDictionary: body)
179179
TestUtils.validateElementPresent(withName: AnyHashable.ITBL_KEY_CURRENT_USER_ID, andValue: currentUserId, inDictionary: body)
180-
XCTAssertEqual(IterableAPI.email, newEmail)
180+
XCTAssertEqual(IterableAPI.userId, currentUserId)
181181
expectation.fulfill()
182182
},
183183
onFailure: {(reason, _) in

swift-sdk/Internal/IterableAPIInternal.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,10 @@ final class IterableAPIInternal : NSObject, PushTrackerProtocol {
235235
if let request = createPostRequest(forPath: .ITBL_PATH_UPDATE_EMAIL, withBody: args) {
236236
sendRequest(request,
237237
onSuccess: { data in
238-
self.email = newEmail
238+
if let _ = self.email {
239+
// we change the email only if we were using email before
240+
self.email = newEmail
241+
}
239242
onSuccess?(data)
240243
},
241244
onFailure: onFailure)

0 commit comments

Comments
 (0)