Eventi API SDK web

ujet.on(eventName, callback)

ujet.off(eventName, callback)

creato

Quando viene creato il widget Web SDK. In genere, questo accade quando fai clic sul launcher.

Puoi utilizzare questo evento per inviare il token di autenticazione:

const ujet = new UJET({
  // ...
  // authenticate: getAuthToken
})

// when you didn't use `authenticate` option, you need to call
// `.authenticate` method manually

ujet.on('created, () => {
  fetch('/token').then(resp => {
    return resp.json()
  }).then(data => {
    ujet.authenticate({ token: data.token })
  })
})

autorizzato

Questo evento si verifica quando viene chiamato il metodo .authenticate e viene restituito un token all'SDK web.

pronte

L'SDK web ha recuperato le informazioni company ed è pronto per l'uso.

unread

Emetti unread conteggio messaggi di chat:

ujet.on('unread', function(num) {
  console.log('has ' + num + ' unread messages')
})

chiudi

Quando l'SDK web è stato chiuso. Questo evento si verifica quando fai clic sul pulsante "Chiudi" nell'SDK o sul pulsante di avvio per chiudere l'SDK.