Skip to content

Commit a77a705

Browse files
committed
Update ChatUIKitClient.swift
1 parent 7a0d473 commit a77a705

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,20 +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-
if ChatUIKitClient.shared.option.option_UI.enableContact {
56-
ChatClient.shared().contactManager?.add(self, delegateQueue: nil)
57-
}
55+
var error: ChatError?
5856
if let options = option {
5957
options.uiKitVersion = ChatUIKit_VERSION
60-
return ChatClient.shared().initializeSDK(with: options)
58+
error = ChatClient.shared().initializeSDK(with: options)
6159
} else {
6260
if let key = appKey {
6361
let options = ChatOptions(appkey: key)
6462
options.uiKitVersion = ChatUIKit_VERSION
65-
return ChatClient.shared().initializeSDK(with: options)
63+
error = ChatClient.shared().initializeSDK(with: options)
6664
}
67-
return ChatError(description: "App key can't be nil", code: .invalidAppkey)
65+
error = ChatError(description: "App key can't be nil", code: .invalidAppkey)
66+
}
67+
if ChatUIKitClient.shared.option.option_UI.enableContact {
68+
ChatClient.shared().contactManager?.add(self, delegateQueue: nil)
6869
}
70+
return error
6971
}
7072

7173
/// Login user.

0 commit comments

Comments
 (0)