ข้ามไปยังเนื้อหา

ตั้งค่ากล่องข้อความเว็บ

ข้อกำหนดเบื้องต้น

Anchor link to

ตรวจสอบให้แน่ใจว่าคุณได้ติดตั้ง Pushwoosh Web SDK บนเว็บไซต์ของคุณแล้ว หากต้องการทำเช่นนั้น โปรดปฏิบัติตามคู่มือของเรา

กล่องข้อความสำหรับเว็บไซต์ ช่วยให้คุณสามารถจัดเก็บการแจ้งเตือนแบบพุชบนเว็บเพื่อให้ผู้ใช้สามารถกลับมาดูได้ในภายหลัง ทำให้มั่นใจได้ว่าข้อความสำคัญจะถูกมองเห็น

วิธีการทำงาน

Anchor link to

นี่คือเวิร์กโฟลว์ทั่วไปของ InboxMessages:

ขั้นตอนเมธอด
การโหลดหน้าเว็บ
การซิงโครไนซ์ข้อความกับเซิร์ฟเวอร์

InboxMessagesModel.updateMessages
ดำเนินการขณะที่ SDK กำลังเริ่มต้น

การลบข้อความที่ล้าสมัย

InboxMessagesModel.updateMessages
ดำเนินการขณะที่ SDK กำลังเริ่มต้น

การรับจำนวนข้อความที่ยังไม่ได้อ่านเพื่ออัปเดตป้ายสถานะ

Pushwoosh.pwinbox.unreadMessagesCount
ดำเนินการด้วยตนเอง (หลังจากเหตุการณ์ onUpdateInboxMessages ทำงาน)

การโหลดข้อความที่จะแสดงในกล่องข้อความ

Pushwoosh.pwinbox.loadMessages
ดำเนินการด้วยตนเอง (หลังจากเหตุการณ์ onUpdateInboxMessages ทำงาน)

การทำเครื่องหมายข้อความที่อยู่ใน viewport ว่าอ่านแล้ว

Pushwoosh.pwinbox.readMessagesWithCodes
ดำเนินการด้วยตนเอง

การดำเนินการที่กำหนดให้กับข้อความที่เปิดขึ้น

Pushwoosh.pwinbox.performActionForMessageWithCode
ดำเนินการด้วยตนเอง

การลบข้อความโดยการคลิกที่ไอคอนลบหรือปัดข้อความไปทางขวา

Pushwoosh.pwinbox.performActionForMessageWithCode
ดำเนินการด้วยตนเอง

Event Listeners

Anchor link to
onUpdateInboxMessages
// Executed after the Inbox is updated automatically while the page is loading.
Pushwoosh.push(['onUpdateInboxMessages', function(api, pwinbox) {
pwinbox.loadMessages().then(function(messages) {
console.log('EVENT: onUpdateInboxMessages', messages);
});
}]);
onPutNewMessageToInboxStore
// Executed by ServiceWorker after the Inbox Message is received and saved to indexedDB.
Pushwoosh.push(['onPutNewMessageToInboxStore', function(api, message) {
console.log('EVENT: onPutNewMessageToInboxStore', message);
}]);

โมดูลสาธารณะ

Anchor link to

โมดูล WebSDK InboxMessagesPublic นำเสนออินเทอร์เฟซสาธารณะเพื่อการติดตั้ง Web Inbox

Model
type TInboxMessageTypePlain = 0;
type TInboxMessageTypeRichmedia = 1;
type TInboxMessageTypeURL = 2;
type TInboxMessageTypeDeeplink = 3;
type TInboxMessageType = TInboxMessageTypePlain // depends on action_params
| TInboxMessageTypeRichmedia
| TInboxMessageTypeURL
| TInboxMessageTypeDeeplink;
interface IInboxMessagePublic {
code: string; // inbox_id
title: string; // title
message: string; // body
imageUrl: string; // image
sendDate: string; // send_date
type: TInboxMessageType; // depends on action_params
isRead: boolean; // true if status is "read" or "open"
link: string; // Deeplink | URL | "/"
isActionPerformed: boolean; // true if status is "open"
}

เมธอดสาธารณะ

Anchor link to

ตรวจสอบคำอธิบายเมธอดสาธารณะในคู่มือ Web Push SDK 3.0