I am playing with Smooch SDK. My question is about how does JWT Work in Smooch iOS ?
Currently I have 1 app, and if I want to use Smooch based on the user id , (ex. 1 app has 50 users to chat with it), do we need to generate 50 JWT or 1 JWT only?
[Smooch login:self.smoochUserId jwt:@"WHAT IS THIS"];
Thank you
Basically in older versions of Smooch
there is no feature like a user can not access the same conversation from multiple devices.
ie., If one user logged in one device and when second user logged in same device then
To overcome this problem Smooch
introduces new method which you noted above with JWT (JSON web token). You can read more about that Here.
do we need to generate 50 JWT or 1 JWT only?
You need to generate JWT server side for each user based on their userId (from your database).
If you are decided to go like this you need to create that JWT token with logged in userid and assign that token to Smooch
via
[Smooch login:@"user-id" jwt:@"jwt" completionHandler:^(NSError * _Nullable error, NSDictionary * _Nullable userInfo) {
// Your code after login is complete
}];
This is bit hard to do. There is another way to do it.
Find the sample node.js code from the link1 which I have submitted and give it to your backend server. And ask them to create for each user so that you can get that JWT token with the user model(Which you will get after success login).
Add that directly to Smooch
.
Note: If you don't care about user existing chat details you can use Smooch
without adding jwt token like this
[Smooch initWithSettings:[SKTSettings settingsWithAppId:@"Your App token(Get it from Smooch dashboard)"] completionHandler:^(NSError * _Nullable error, NSDictionary * _Nullable userInfo) {}
[[SKTUser currentUser] addProperties:@{@"Company":[[NSUserDefaults standardUserDefaults] valueForKey:@"company"],@"UserId":[[NSUserDefaults standardUserDefaults] valueForKey:@"empid"]}];
[Smooch show];