Peristiwa Web SDK API

ujet.on(eventName, callback)

ujet.off(eventName, callback)

dibuat

Saat widget Web SDK dibuat. Biasanya hal ini terjadi saat Anda mengklik peluncur.

Anda dapat menggunakan peristiwa ini untuk mengirim token autentikasi:

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 })
  })
})

diotorisasi

Peristiwa ini terjadi saat metode .authenticate dipanggil dan merespons dengan token ke Web SDK.

siap

Web SDK telah mengambil informasi company, dan siap digunakan sekarang.

unread

Mengirim jumlah pesan chat unread:

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

tutup

Saat Web SDK telah ditutup. Peristiwa ini terjadi saat Anda mengklik tombol "tutup" di SDK, atau mengklik peluncur untuk menutup SDK.