Bỏ qua, đến nội dung

@digiforce-nc/plugin-firebase-notification

Plugin thông báo đẩy Firebase — gửi push notification đến thiết bị mobile và web browser qua Firebase Cloud Messaging (FCM), quản lý device token và đăng ký kênh thông báo.

Plugin này làm gì?

Khi hệ thống cần gửi thông báo đẩy đến user (đơn hàng mới, task được gán, tin nhắn mới...), plugin tích hợp Firebase Cloud Messaging (FCM) — dịch vụ push notification miễn phí của Google. Plugin đăng ký một notification channel type tên firebase vào hệ thống, quản lý device token của từng user, và gửi push đến đúng thiết bị.

Ba nhiệm vụ chính

#Nhiệm vụChi tiết
1Đăng ký channelĐăng ký notification channel type firebase vào hệ thống
2Device token managementLưu/cập nhật/xóa device token cho mỗi user-device
3Push deliveryGửi notification qua FCM API đến đúng thiết bị

Kiến trúc

Luồng gửi push notification

Luồng đăng ký device token

API endpoints

EndpointMô tả
deviceTokens:registerĐăng ký device token mới (token, platform)
deviceTokens:unregisterHủy đăng ký token (khi logout hoặc gỡ app)
deviceTokens:listDanh sách device tokens của user hiện tại
firebaseConfig:getLấy cấu hình Firebase (projectId, vapidKey)
firebaseConfig:updateCập nhật cấu hình Firebase (admin only)

Database

BảngChứa gìVí dụ
deviceTokensDevice token của user (userId, token, platform){ userId: 1, token: 'fcm_xxx', platform: 'android' }
firebaseConfigCấu hình Firebase (projectId, serviceAccount){ projectId: 'my-app', vapidKey: '...' }

Cấu hình

Tham sốMô tả
serviceAccountFirebase service account JSON (private key)
projectIdFirebase project ID
vapidKeyVAPID key cho web push (Web Push Certificate)

Thành phần client

Thành phầnMô tả
FCMConfigFormForm cấu hình Firebase credentials (Settings → Notifications → Firebase)
DeviceTokenListDanh sách thiết bị đã đăng ký của user
PushPermissionPromptPrompt yêu cầu user cho phép nhận push notification

Dependencies

PackageVai trò
@digiforce-nc/serverServer framework (peer)
@digiforce-nc/databaseDatabase ORM (peer)
@digiforce-nc/clientClient UI framework (peer)
firebase-adminFirebase Admin SDK — gửi push qua FCM API

Mục lục chi tiết