Login Issue

Hello,

We are trying to login in Sendbird Call SDK using below method:
SendBirdCall.authenticate(with: authParams)

In that, we are using the mobile number in “userId” parameters. So, it will be “+911234554321”.

But when we are logged in, then it is giving below error:
Invalid value: “user_id must not have leading or trailing whitespaces”

Is there anything we need to do with such user-id to login?

I’ll have to have our iOS Engineering team take a look. Might I suggest that you URLEncode your usernames from the get go? This would prevent a lot of the issues you’re running into using phone numbers (including the +) as usernames.

Hello @Tyler

Thanks for your reply. As per your feedback, I have tried with below:


var SELF_USER_ID =
SELF_USER_ID = String(describing: SELF_USER_ID.cString(using: String.Encoding.utf8))

But this is not working and it is creating a new user on dashboard.

I have also tried with URLEncode as below:
SELF_USER_ID = SELF_USER_ID.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)!

Then same issue is occuring.
Invalid value: “user_id must not have leading or trailing whitespaces”

Please let me know for same.

Hi @Ibrahim_Malada,

Yes, sorry. I was not saying that encoding it on connection would resolve the problem. I was recommending you encode it from the get go. Meaning you encode the + when a user registers. That way you can always reference the user with the encoded name.

Hi @Tyler

Not getting you exactly. Can you share some example, as I have checked with the default demo, and there nothing related to encode.

Thank you.

This would be something you’d need to implement. Because you’re using unique characters as part of your username, it would be best if you added a method to encode those usernames whenever a user registers. Then anywhere that you would need to pass in that username, you would simply encode it so that it never has a problem with unique characters.

Hello @Tyler

In that case, it’s creating user with encoded characters. So, currently I have removed the “+” from the userid and proceed further.

Hi @Ibrahim_Malada,

Creating the user would be the expected behavior then. Removing the + all together also works. There are a couple of ways to handle this and ultimately it depends on your workflow and implementation. I’m glad you were able to come up with a solution.