Skip to content

Commit 4edf655

Browse files
authored
Merge pull request #54 from zjc19891106/main
fix auto login user miss add contact Invitation
2 parents 36703f4 + a77a705 commit 4edf655

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Sources/EaseChatUIKit/Classes/Service/Client/ChatUIKitClient.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,22 @@ public let cache_update_notification = "ChatUIKitContextUpdateCache"
5252
/// Returns the initialization success or an error that includes the description of the cause of the failure.
5353
@objc(setupWithAppKey:option:)
5454
public func setup(appKey: String? = nil,option: ChatOptions? = nil) -> ChatError? {
55+
var error: ChatError?
5556
if let options = option {
5657
options.uiKitVersion = ChatUIKit_VERSION
57-
return ChatClient.shared().initializeSDK(with: options)
58+
error = ChatClient.shared().initializeSDK(with: options)
5859
} else {
5960
if let key = appKey {
6061
let options = ChatOptions(appkey: key)
6162
options.uiKitVersion = ChatUIKit_VERSION
62-
return ChatClient.shared().initializeSDK(with: options)
63+
error = ChatClient.shared().initializeSDK(with: options)
6364
}
64-
return ChatError(description: "App key can't be nil", code: .invalidAppkey)
65+
error = ChatError(description: "App key can't be nil", code: .invalidAppkey)
6566
}
67+
if ChatUIKitClient.shared.option.option_UI.enableContact {
68+
ChatClient.shared().contactManager?.add(self, delegateQueue: nil)
69+
}
70+
return error
6671
}
6772

6873
/// Login user.
@@ -71,9 +76,6 @@ public let cache_update_notification = "ChatUIKitContextUpdateCache"
7176
/// - token: The user chat token.
7277
@objc(loginWithUser:token:completion:)
7378
public func login(user: ChatUserProfileProtocol,token: String,completion: @escaping (ChatError?) -> Void) {
74-
if ChatUIKitClient.shared.option.option_UI.enableContact {
75-
ChatClient.shared().contactManager?.add(self, delegateQueue: nil)
76-
}
7779
ChatUIKitContext.shared?.currentUser = user
7880
ChatUIKitContext.shared?.chatCache?[user.id] = user
7981
ChatUIKitContext.shared?.userCache?[user.id] = user

0 commit comments

Comments
 (0)