Skip to content

Commit cdb60af

Browse files
committed
allow writing in auth token
1 parent a0dcf3d commit cdb60af

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

swift-sdk/Internal/InternalIterableAPI.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
104104
func setEmail(_ email: String?, authToken: String? = nil) {
105105
ITBInfo()
106106

107+
if _email == email && email != nil && authToken != nil {
108+
checkAndUpdateAuthToken(authToken)
109+
return
110+
}
111+
107112
if _email == email {
108113
return
109114
}
@@ -121,6 +126,11 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
121126
func setUserId(_ userId: String?, authToken: String? = nil) {
122127
ITBInfo()
123128

129+
if _userId == userId && userId != nil && authToken != nil {
130+
checkAndUpdateAuthToken(authToken)
131+
return
132+
}
133+
124134
if _userId == userId {
125135
return
126136
}
@@ -537,6 +547,12 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
537547
}
538548
}
539549

550+
private func checkAndUpdateAuthToken(_ authToken: String? = nil) {
551+
if config.authDelegate != nil && authToken != authManager.getAuthToken() {
552+
onLogin(authToken)
553+
}
554+
}
555+
540556
init(apiKey: String,
541557
launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil,
542558
config: IterableConfig = IterableConfig(),

0 commit comments

Comments
 (0)