Chuyển đến nội dung

Widget

Các widget Màn hình chính, Màn hình khóa và Chế độ chờ trên iOS được điều khiển bằng push. Khai báo một widget một lần, cập nhật nội dung của nó bằng một PATCH, và các phiên bản WidgetKit của người dùng sẽ tự động làm mới.

Thông tin

Widgets require iOS 26 or later. On older versions the iOS app hides the widget management screen and your widgets remain dormant — the server keeps the content current so they render correctly once the user upgrades.

Widgets are persistent — once the user pins one to their Home Screen, Lock Screen, or StandBy, it stays there until they remove it. Use a widget for ambient state that should always be glanceable (a sensor reading, a server health indicator, a daily counter). For something that is currently happening and has a known end — a download, a timer, a print — reach for a Live Activity instead.

Templates

Each template is tuned for a different shape of data. Tap a card for that template's field list, worked example, and behavior notes; the shared content fields they all accept live in the API reference.

valueValue

Một con số lớn duy nhất với đơn vị, nhãn và mũi tên xu hướng tùy chọn. Phù hợp nhất cho các giá trị cảm biến và bộ đếm.

Required: none (optional value, unit, label, trend)

Value widget — large "20" deploys count on a dark card with badges and an Up trend arrow.

progressProgress

Một thanh tiến trình với nhãn và màu nhấn. Phù hợp nhất cho phần trăm hoàn thành và các đợt triển khai.

Required: value 0.0 – 1.0

Progress widget — Pages 100% with a green progress bar and "10 of 10 acked".

statusStatus

Một viên trạng thái có biểu tượng được điều khiển bởi mức độ nghiêm trọng (info, warning, critical, success). Không có con số — chỉ trạng thái.

Required: none (optional severity: info, warning, critical, success)

Status widget — Incident card with a green warning octagon and "resolved" pills.

gaugeGauge

Một đồng hồ kim giữa giá trị min và max có thể cấu hình. Phù hợp nhất cho SLO, ngân sách lỗi và dung lượng.

Required: value, min_value, max_value

Gauge widget — Errors dial at 0.4% out of 5%, with MIN/MAX labels and Mute/Logs buttons.

stat_listDanh sách số liệu

Tối đa sáu hàng nhãn/giá trị. Phù hợp nhất cho các bảng điều khiển gọn — MRR / Subs / Trials, Up / Down / Maintenance.

Required: stat_rows (array, 1 – 6 entries)

Stat list widget — On-call card with Primary, Secondary, and Time left rows.
Sắp có trong phiên bản ứng dụng 1.6

Phần này mô tả một tính năng trong bản cập nhật ứng dụng đang chờ App Store xét duyệt. Tính năng sẽ tự động mở khóa tại đây ngay khi bản cập nhật được phát hành.

Every template accepts the shared content fields — label, subtitle, icon, the colors, and the three tap-action slots — so the styling you already use carries across. Preview any of them on the playground.

Thông tin

stat_list stores up to 6 rows, but how many render depends on the placement size. By default, medium and large Home Screen widgets show all 6; the small widget shows 4, and the Lock Screen rectangular shows 3, packing rows two-up to fit up to 6 when every value is very short (a single status glyph, a small count). You can change Row Density per widget in the PushWard app: Compact packs two columns to surface up to 6 rows on any size (labels may truncate on the small placements), and Comfortable keeps a single column with larger rows (showing fewer on the smaller sizes). To see all 6 rows with full labels, use a medium or large widget, or set Compact.

How it works

  1. Your integration calls POST /widgets to declare a widget by slug, with a template and initial content.
  2. The user opens the widget picker on their device and selects your slug for any system widget family they want — small, medium, large, accessory-rectangular, accessory-circular, or accessory-inline. The same slug can appear in multiple slots.
  3. Your integration calls PATCH /widgets/{slug} whenever the underlying value changes. The server merges (RFC 7396) and pushes a thin update; the iOS widget extension reloads its timeline.
  4. If a push is missed (background fetch coalescing, no network), iOS calls back into the extension every ~30 minutes for a freshness pull — GET /widgets/{slug} always returns the latest content.

Two ways to create widgets

Widgets don't require an integration to exist. There are two paths to the same backend, and both can target the same slug — a widget created in the app can later be driven by an integration, and vice versa.

  • In the iOS app. Open the Widgets tab in PushWard, choose a template, and fill in the slug, name, and initial content. This is the right path for personal widgets — a temperature you key in by hand, a morale dial, a counter you bump from a Shortcut. The new slug appears immediately in the iOS widget picker for Home Screen, Lock Screen, and StandBy.
  • Via the HTTP API. Use this when an external service should keep the widget content current — a homelab probe, a CI job, a smart-home automation. See the API reference.

Authentication

The widgets API is reachable with an integration key (hlk_) that has the widgets flag enabled. This is the right choice for third-party integrations — toggle the flag on the key in the iOS app's integration-keys screen.

Next steps