> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sub.jerrylu.app/llms.txt
> Use this file to discover all available pages before exploring further.

# 使用 Bark 续费提醒

> 配置 Netlify Scheduled Functions 和 Bark，为即将续费的订阅发送推送。

# 使用 Bark 续费提醒

Subscription Manager 可以通过 Bark 发送续费提醒。托管提醒流程使用 Netlify Scheduled Function 和保存在 Supabase 中的通知设置。

## 用户需要配置什么

用户在应用内配置 Bark 设置：

* Bark server URL。
* Bark device key。
* 提醒提前天数。
* 每个订阅自己的通知开关。

## 必需托管服务

* Supabase 保存通知设置和订阅数据。
* Netlify Functions 执行定时检查。
* Bark 官方服务器或自托管 Bark server。

## 必需环境变量

```bash theme={null}
VITE_SUPABASE_URL=
VITE_SUPABASE_ANON_KEY=
SUPABASE_SECRET_KEY=
```

旧变量名 `SUPABASE_SERVICE_ROLE_KEY` 仍作为兼容别名支持。

## SQL 设置

通知相关表和约束已经包含在 Supabase migrations 中。当前部署使用：

```text theme={null}
supabase/migrations/20260615000100_baseline.sql
supabase/migrations/20260615000200_harden_existing_schema.sql
```

旧安装说明和 legacy migration 文件保留在 `supabase/legacy/`。

## 定时函数

定时函数位于：

```text theme={null}
netlify/functions/send-scheduled-notifications.ts
```

它会检查符合条件的订阅，发送 Bark 消息，记录发送历史，并避免重复发送。

## 本地测试

```bash theme={null}
npm run test:notifications
```

测试完整 Functions runtime 时使用 Netlify Dev：

```bash theme={null}
npm run dev:full
```
