إعداد صندوق رسائل الويب
المتطلبات المسبقة
Anchor link toتأكد من أنك قمت بتطبيق Pushwoosh Web SDK على موقع الويب الخاص بك. للقيام بذلك، يرجى اتباع دليلنا.
تسمح Message Inbox لمواقع الويب بتخزين إشعارات الويب الفورية (web push notifications) حتى يتمكن المستخدمون من زيارتها مرة أخرى لاحقًا، مما يضمن رؤية الرسائل المهمة.
كيف تعمل
Anchor link toفيما يلي سير عمل نموذجي مع InboxMessages:
| الخطوة | الطريقة |
|---|---|
| تحميل الصفحة | |
| مزامنة الرسائل مع الخادم |
|
| حذف الرسائل القديمة |
|
| تلقي عدد الرسائل غير المقروءة لتحديث الشارة |
|
| تحميل الرسائل لعرضها في Inbox |
|
| وضع علامة “مقروءة” على الرسائل التي تظهر في إطار العرض |
|
| تنفيذ إجراء مخصص للرسالة المفتوحة |
|
| حذف الرسائل بالنقر على أيقونة الحذف أو السحب لليمين على رسالة |
|
مستمعو الأحداث (Event listeners)
Anchor link to// 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); });}]);// Executed by ServiceWorker after the Inbox Message is received and saved to indexedDB.Pushwoosh.push(['onPutNewMessageToInboxStore', function(api, message) { console.log('EVENT: onPutNewMessageToInboxStore', message);}]);الوحدة العامة (Public module)
Anchor link toتقدم WebSDK InboxMessagesPublic module واجهة عامة لتطبيق Web Inbox.
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"}الطرق العامة (Public methods)
Anchor link toتحقق من أوصاف الطرق العامة في دليل Web Push SDK 3.0.