After updating to version 2.2 when I try to use the TextToolBar I continue to get the "❌ The current user not found" error.
Here is my setup code:
Client.config = .init(apiKey: "ajbbcwn5bxms", appId: "64415")
Client.shared.setupUser(token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidXNlci1vbmUifQ.AW1xE4VpjzKTpcj3dEX3eLVeXUAoHtaqCEeqDCHYiuo") { result in
// Do all your requests from here. Reload feeds and etc.
if let currentUser = try? result.get() {
let ContainerViewController = self.storyboard?.instantiateViewController(identifier: "tab") as! UITabBarController
ContainerViewController.tabBar.isTranslucent = false
ContainerViewController.tabBar.barTintColor = #colorLiteral(red: 0.08281194419, green: 0.0896929279, blue: 0.1466576457, alpha: 1)
self.view.window?.rootViewController = ContainerViewController
self.view.window?.makeKeyAndVisible()
} else if let error = result.error {
print("Authorization error:", error)
}
}
This happened even though my logs are saying:
👤 User id: user-one
🀄️ Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidXNlci1vbmUifQ.AW1xE4VpjzKTpcj3dEX3eLVeXUAoHtaqCEeqDCHYiuo
👤 The current user was setupped with id: user-one
The problem is that User.current
returns a Client.shared.user as? User
.
Stream Feeds has GetStream.User
and Activity Feed Components has own GetStreamActivityFeed.User
with additional properties.
You need to setup user in this way:
Client.config = .init(apiKey: "ajbbcwn5bxms", appId: "64415")
let token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidXNlci1vbmUifQ.AW1xE4VpjzKTpcj3dEX3eLVeXUAoHtaqCEeqDCHYiuo"
guard let currentUserId = token.userId else {
print("Bad token:", token)
return
}
let user = GetStreamActivityFeed.User(name: "John Doe", id: currentUserId)
Client.shared.setupUser(user, token: token) { result in
if let currentUser = try? result.get() {
let ContainerViewController = self.storyboard?.instantiateViewController(identifier: "tab") as! UITabBarController
ContainerViewController.tabBar.isTranslucent = false
ContainerViewController.tabBar.barTintColor = #colorLiteral(red: 0.08281194419, green: 0.0896929279, blue: 0.1466576457, alpha: 1)
self.view.window?.rootViewController = ContainerViewController
self.view.window?.makeKeyAndVisible()
} else if let error = result.error {
print("Authorization error:", error)
}
}