User Token

JWT creation will be identical for both Android and iOS.

User Token (JWT) is necessary to initialize the Chat feature, and it must be generated on the server side.

The Chat init looks as follow:

TalkShopLibe.Chat(JWT, isGuest, showKey) 

Please see the Chat section for more information regarding chat

The JWT can be generated for registered or guest. It required a payload, shared secret and encryption HS256

Registered User

Example Payload:

{
"iss":"sdk_123",
"exp":1709165076281, 
"jti":"tWhBAwSTmXU6zyQK15Euyy==", 
"user":{
      "id":"123",
      "name":"Andrea S"
      }
}

Definition:

iis : sdk key

exp: expiration date. Unix timestamp, must be in the future. Use this url to generate one manually https://www.unixtimestamp.com/

jti: SecureRandom.base64 // A unique value for each .

user : user Object with required information

id: UID of user, for ex: "123"

name: user name, such as "Andrea S"

profile_url: optional

email: optional. It is required if id is not present

Generate JWT using the shared secret provided by TSL

Example JWT:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzZGtfMmVhMjFkZTE5Y2M4YmM1ZTg2NDBjN2IyMjdmZWYyZjMiLCJleHAiOjE3MDkxNjUwNzYyODEsImp0aSI6InRXaEJBd1NUbVhVNnp5UUsxNUV1eXk9PSIsInVzZXIiOnsiaWQiOiIxMjMiLCJuYW1lIjoiQW5kcmVhIFMifX0.dvXsF7OZl4RpSObxjr5cEX7VBZteGBlZuGfGFw7LZdY

For testing, use https://jwt.io/ to generate one manually. or JWT.encode(payload, <api_key secret>, 'HS256')

Guest User

Same as registered but without the user object

Example Payload:

{
"iss":"sdk_123",
"exp":1709165076281, 
"jti":"tWhBAwSTmXU6zyQK15Euyy=="
"user":{
      "name":"Guest 1"
      }
}

🚧

token is required for Chat() and it's valid for 1 hour.