跳转到内容

Bark

协议
bark:
运行时
Node.js浏览器
官方文档
bark://<server>[:<port>]/<device-key>[/<device-key>...]
import { send } from 'statocysts'
await send(
'bark://api.day.app/DEVICE_KEY',
{ title: 'Deployment complete', body: 'Production is healthy.' },
)

通知提供方会向 <server>/push 发送 HTTPS 请求。增加路径段可以在一个请求中向多个设备密钥投递。

支持以下 Bark 字段:

  • subtitle、group、url、icon、sound 和 ciphertext;
  • level:active、timeSensitive、passive 或 critical;
  • call=1、autoCopy=1 和 isArchive=1;
  • volume、数字类型的 badge、copy 和 action=none。
bark://api.day.app/DEVICE_KEY?group=operations&level=timeSensitive&sound=alarm

查询参数会进入 JSON 请求体。枚举值或标志值非法时,投递会失败。

包含正文时,标题作为 title,正文作为 markdown;只有标题时,标题作为 markdown。

直接调用 bark.send() 可以传入 fetchOptions:

import { bark } from 'statocysts'
await bark.send(target, notification, {
fetchOptions: { timeout: 5000 },
})