通知收件箱
返回发送给用户的通知——应用内“消息”屏幕背后的数据。
GET /api/push/notifications?externalUserId=operator-497&limit=50&offset=0
X-Push-App-Key: <application key>
查询参数
| 参数 | 必填 | 备注 |
|---|---|---|
externalUserId | 是 | 注册时使用的命名空间用户ID。 |
limit | 否 | 页面大小。 |
offset | 否 | 分页偏移量。 |
from | 否 | ISO-8601 日期范围的开始。 |
to | 否 | ISO-8601 日期范围的结束。 |
status | 否 | 按通知状态过滤。 |
在使用前规范化响应
响应可能是一个裸数组或分页封装。早期的构建直接将原始主体传递给 .filter,而非数组会导致整个通知中心崩溃。
const toArray = (data: any) =>
Array.isArray(data) ? data
: Array.isArray(data?.items) ? data.items
: Array.isArray(data?.data) ? data.data
: Array.isArray(data?.notifications) ? data.notifications
: Array.isArray(data?.result) ? data.result
: [];