@quantabit/push-sdk
v1.0.2
Published
Universal push notification adapter: WebSocket, FCM, OneSignal, JPush, SSE, WebPush
Maintainers
Readme
@quantabit/push-sdk
通用推送通知适配层 — 一套 API 接入多种推送服务
支持的推送服务
| 适配器 | 类型 | 场景 | |--------|------|------| | WebPushAdapter | 浏览器原生 | 标准 Web Push | | WebSocketAdapter | 自研 | IM / 实时推送 | | SSEAdapter | 服务端推送 | 单向实时流 | | FCMAdapter | 商业 | Firebase Cloud Messaging | | OneSignalAdapter | 商业 | OneSignal 推送 | | JPushAdapter | 商业 | 极光推送 | | MockAdapter | 测试 | 开发/测试模拟 |
使用示例
import { PushManager, usePush } from '@quantabit/push-sdk';
// 方式1: 类实例
const push = new PushManager({ adapter: 'websocket', url: 'wss://your-server/ws' });
push.connect();
push.onMessage(msg => console.log(msg));
// 方式2: React Hook
const { connected, lastMessage, send } = usePush({ adapter: 'websocket', url: 'wss://...' });
// 方式3: 自定义适配器
const push = new PushManager({ adapter: myCustomAdapter });特性
- 🔌 适配器模式,一行切换推送服务
- 🔄 自动重连 + 指数退避
- 📦 离线消息队列
- 🔧 消息中间件管线
- ⚛️ React Hook + Provider
License
MIT
🌐 Brand & Links
- Official Mainnet: QuantaBit Chain
- Developer Platform: Developer Platform
- Open Platform: Open Platform
- Payment Platform: Pay Platform
- Feedback: Feedback
