Skip to content

Commit 67768d8

Browse files
Merge pull request #55 from Iterable/feature/mob-94-current-user-id
[MOB-94] - Only set new email on updateEmail if it was using email.
2 parents 2280294 + e968d37 commit 67768d8

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ 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)
181+
XCTAssertNil(IterableAPI.email)
181182
expectation.fulfill()
182183
},
183184
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)