ujet.on(eventName, callback)
ujet.off(eventName, callback)
已建立
建立 Web SDK 小工具時。通常點選啟動器時就會發生這種情況。
您可以使用這個事件傳送驗證權杖:
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 })
})
})
已授權
呼叫 .authenticate 方法並以 token 回應 Web SDK 時,就會發生這個事件。
已就緒
Web SDK 已擷取 company 資訊,現在可以使用。
未讀
發出 unread 則即時通訊訊息:
ujet.on('unread', function(num) {
console.log('has ' + num + ' unread messages')
})
關閉
Web SDK 關閉時。當您在 SDK 中點選「關閉」按鈕,或點選啟動器關閉 SDK 時,就會觸發這個事件。