Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions ios/RNKommunicateChat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ class RNKommunicateChat : RCTEventEmitter, KMPreChatFormViewControllerDelegate,
}
kmUser.platform = 7 // 7 is for React Native
Kommunicate.setup(applicationId: kmUser.applicationId)
Kommunicate.registerUser(kmUser, completion: {
response, error in
guard error == nil else{
callback(["Error", error as Any])
Kommunicate.registerUser(kmUser, completion: { response, error in
guard let response = response else {
callback(["Error", error?.localizedDescription ?? "Failed to login the user"])
return
}
callback(["Success", response as Any])
// callback(["Success", response as Any])
callback(["Success", response.toDictionary() as NSDictionary])
})
}

Expand All @@ -108,11 +108,13 @@ class RNKommunicateChat : RCTEventEmitter, KMPreChatFormViewControllerDelegate,
kmUser.platform = 7 // 7 is for React Native
Kommunicate.registerUser(kmUser, completion: {
response, error in
guard error == nil else{
callback(["Error", error as Any])
guard let response = response else{
callback(["Error", error?.localizedDescription ?? "Failed to login the user"])
return
}
callback(["Success", response as Any])

// callback(["Success", response.toDictionary() as NSDictionary])
})
}

Expand Down Expand Up @@ -773,3 +775,22 @@ extension ALChannel {
return dict
}
}

extension ALRegistrationResponse {
func toDictionary() -> [String:Any] {
var dict : [String: Any] = [:]
dict["message"] = self.message ?? ""
dict["deviceKey"] = self.deviceKey ?? ""
dict["userKey"] = self.userKey ?? ""
dict["brokerURL"] = self.brokerURL ?? ""
dict["imageLink"] = self.imageLink ?? ""
dict["statusMessage"] = self.statusMessage ?? ""
dict["encryptionKey"] = self.encryptionKey ?? ""
dict["pricingPackage"] = self.pricingPackage
dict["displayName"] = self.displayName ?? ""
dict["roleType"] = self.roleType
dict["userEncryptionKey"] = self.userEncryptionKey ?? ""
dict["authToken"] = self.authToken
return dict
}
}