Skip to content

The session is not recovers in the android SDK #188

@reygie25

Description

@reygie25

The scenario here is when the web sdk started a session.

Web SDK

To send or initiate a first-time message to a contact or workers (which we call), using the Web SDK, we open the chatbox to generate a session_id which is needed to send the message. Here's our example code:

{
  // 1. Initialize Crisp
  Crisp.configure(website_id, { autoload: false });
  Crisp.setTokenId(user_id); // Example: 6678c287a61b0b0015a1e816
  Crisp.user.setEmail(email);
  Crisp.user.setNickname(name);
  
  // 2. Event listener for session loaded
  Crisp.session.onLoaded((sessionId) => {
    console.log("Session Loaded!", sessionId); // We used this sessionId to send message. Example: session_76f9db48-4b51-463e-8a9c-0a56e3854c21
  });
  Crisp.load();

  // 3. Open chatbox to generate session id and close it after 500ms
  Crisp.chat.show();
  Crisp.chat.open();
  setTimeout(() => {
    Crisp.chat.close();
    Crisp.chat.hide();
  }, 500);
}

ANDROID SDK

  1. Open the crisp chat view with token ID 6678c287a61b0b0015a1e816, below is the code we called before the crisp chatview opens.
Crisp.setTokenID(context, profile.getUserId());
Crisp.setSessionString("user_id", profile.getUserId());
String topic = profile.getUserId() + "-android";
Crisp.setSessionString("topic", topic);
Crisp.setUserNickname(profile.getFullName());
Crisp.setUserEmail(profile.getEmail());
Crisp.setUserAvatar(profile.getProfileImageUrl()); 
startActivity(new Intent(context, im.crisp.client.ChatActivity.class));
  1. The session will not recover and created a new session: session_6dbd6617-aa65-45eb-858a-7002647bbc43
  2. The Android app is expecting to recover the session ID: session_76f9db48-4b51-463e-8a9c-0a56e3854c21

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions