Integrating Your Service Worker
- Custom Service Worker: Inject the path of your custom service worker file
(eg: "./**/your-service-worker-filename" or "./your-service-worker-filename")
into the global variablewindow.__rb_app.swUrl
. After injecting, output the variable to check if the path is correct. Then, in your service worker file, insert the lineimportScripts("./notification-sw.js")
.
Integration Code Example
- index.html
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 = './**/your-service-worker-filename" or "./your-service-worker-filename'
</script>
<!-- 其他代码 -->
</head>
<body></body>
</html>
- service-worker.js
js
// service-worker.js
importScripts("./notification-sw.js")
/**
* 您的代码
*/
Important Notes
- The injection of window.__rb_app.swUrl must occur before the closing of the
<head>
tag in index.html. - Only self-developed integrations are supported; packaged integrations can be ignored.
- For any integration issues, please contact customer support for assistance.