For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /developer/service-worker.md.
  • 简体中文
  • 接入您的Service Worker

    • 自定义service worker:将您自定义的service worker文件路径(例如:"./**/您的service worker文件名" 或者"./您的service worker文件名")注入到window.__rb_app.swUrl全局变量中,注入完后输出变量检查路径是否一致,然后在您的service worker文件中插入importScripts("./notification-sw.js")这行代码。

    接入代码示例

    • index.html
    <!doctype html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <meta content="IE=edge" http-equiv="X-UA-Compatible" />
        <meta content="width=device-width, initial-scale=1.0" name="viewport" />
        <title></title>
        <script>
            window.__rb_app.swUrl = './**/您的service worker文件名" 或者"./您的service worker文件名'
        </script>
        <!--  其他代码  -->
      </head>
      <body></body>
    </html>
    • service-worker.js
    // service-worker.js
    importScripts("./notification-sw.js")
    /**
     * 您的代码
     */

    注意事项

    • window.__rb_app.swUrl注入时机需要前置在index.html的head标签中
    • 只支持自研接入,包网接入可忽略
    • 接入有问题请联系客服沟通