register method

void register({
  1. required CrispUser user,
})

Register a new user to start the chat This is useful to register a new user to start the chat.

Implementation

void register({required CrispUser user}) {
  if (user.verificationCode != null) {
    appendScript(
        "window.\$crisp.push([\"set\", \"user:email\", [\"${user.email}\", \"${user.verificationCode!}\"]])");
  } else {
    appendScript(
        "window.\$crisp.push([\"set\", \"user:email\", [\"${user.email}\"]])");
  }

  if (user.nickname != null) {
    appendScript(
        "window.\$crisp.push([\"set\", \"user:nickname\", [\"${user.nickname!}\"]])");
  }

  if (user.avatar != null) {
    appendScript(
        "window.\$crisp.push([\"set\", \"user:avatar\", [\"${user.avatar!}\"]])");
  }

  if (user.phone != null) {
    appendScript(
        "window.\$crisp.push([\"set\", \"user:phone\", [\"${user.phone!}\"]])");
  }

  this.user = user;
}