Closed marcnpopa closed 3 years ago
Agent comment from Ryan Kavanaugh in Zendesk ticket #8026:
Hi,
Thanks for reaching out. We will review this and be in touch as soon as possible.
Best, Ryan
Hello @marcnpopa How do you generate the user token? Are you using any other Stream clients with the same token?
Hi @b-onc we just solved the issue on our backend side!
Hi,
What did you do?
We integrated stream-swift using SPM, and our iOS app runs well using the tutorial test credentials (appKey, appId, token, user)
Now we are trying to generate the token on our server side: "$client->users()->add('1068811', ['name' => 'Marc Team']);" (PHP)
On the iOS client side we initialize the Stream Client: "Client.config = .init(apiKey: "xxxxxx", appId: "xxxxxx", logsEnabled: true)"
Using the token retrieved from the server we try the setup: "Client.shared.setupUser(User(..), token: streamToken).."
What did you expect to happen?
"Client.shared.setupUser" should return "success"
What happened instead?
we get the error: "Client.shared.create failed with : Client setup: The current user id is empty"
Debugging inside the GetStream package, seems like when retrieving the
user_id
from the token it comes as an Integer and it fails because it expects a String:" /// A user id from the Token. public var userId: String? { return payload?["user_id"] as? String // -> this returns nill } "
when, using a breakpoint on the previous line ^, and capturing this in the console: " payload?[“user_id”] as? Int // returns the correct user_id "
GetStream Environment
GetStream version: 2.2.3 Xcode version: 12.2 Swift version: 5 Platform(s) running GetStream: iOS **macOS version running Xcode: Catalina 10.15.7
Additional context
When requesting a user from the server side we get a correct user id as a String: " [ "created_at" => "2020-12-11T18:34:36.883063Z" "updated_at" => "2020-12-11T18:34:36.883063Z" "id" => "1068811" "data" => array:1 [ "name" => "Marc Team" ] "duration" => "3.97ms" ] "
Thank you
gz#8026