• <legend id='h3Jzr'><style id='h3Jzr'><dir id='h3Jzr'><q id='h3Jzr'></q></dir></style></legend>

    <small id='h3Jzr'></small><noframes id='h3Jzr'>

    • <bdo id='h3Jzr'></bdo><ul id='h3Jzr'></ul>
    <i id='h3Jzr'><tr id='h3Jzr'><dt id='h3Jzr'><q id='h3Jzr'><span id='h3Jzr'><b id='h3Jzr'><form id='h3Jzr'><ins id='h3Jzr'></ins><ul id='h3Jzr'></ul><sub id='h3Jzr'></sub></form><legend id='h3Jzr'></legend><bdo id='h3Jzr'><pre id='h3Jzr'><center id='h3Jzr'></center></pre></bdo></b><th id='h3Jzr'></th></span></q></dt></tr></i><div id='h3Jzr'><tfoot id='h3Jzr'></tfoot><dl id='h3Jzr'><fieldset id='h3Jzr'></fieldset></dl></div>
      <tfoot id='h3Jzr'></tfoot>

        Firebase:更改服务人员的位置

        Firebase: change the location of the service worker(Firebase:更改服务人员的位置)
          <bdo id='2yCMC'></bdo><ul id='2yCMC'></ul>
            <tbody id='2yCMC'></tbody>
          <legend id='2yCMC'><style id='2yCMC'><dir id='2yCMC'><q id='2yCMC'></q></dir></style></legend>

        • <small id='2yCMC'></small><noframes id='2yCMC'>

          1. <i id='2yCMC'><tr id='2yCMC'><dt id='2yCMC'><q id='2yCMC'><span id='2yCMC'><b id='2yCMC'><form id='2yCMC'><ins id='2yCMC'></ins><ul id='2yCMC'></ul><sub id='2yCMC'></sub></form><legend id='2yCMC'></legend><bdo id='2yCMC'><pre id='2yCMC'><center id='2yCMC'></center></pre></bdo></b><th id='2yCMC'></th></span></q></dt></tr></i><div id='2yCMC'><tfoot id='2yCMC'></tfoot><dl id='2yCMC'><fieldset id='2yCMC'></fieldset></dl></div>

                <tfoot id='2yCMC'></tfoot>
                  本文介绍了Firebase:更改服务人员的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用 Firebase 消息传递(网络).Firebase 默认搜索包含 service worker 的文件firebase-messaging-sw.js".

                  I am trying to use Firebase messaging (web). Firebase by default searches for the file "firebase-messaging-sw.js" which holds the service worker.

                  Service Worker 脚本应位于应用程序的绝对路径上!例如:http://localhost/firebase-messaging-sw.js

                  The service worker script is expected to be on the absolute path of the application! For example : http://localhost/firebase-messaging-sw.js

                  如何更改此默认位置?!搜索官方文档我发现了这个方法:useServiceWorker,它接受服务工作者注册,但尝试使用它我得到一个错误,该方法甚至不存在!

                  How to change this default location?! Searching the official docs I found this method: useServiceWorker which accepts a service worker registeration, but trying to use it I get an error that the method doesn't even exist!

                  那么,如何更改用于 Firebase 消息传递的 Service Worker 的位置?

                  So, How to change the location of the service worker for firebase messaging?

                  推荐答案

                  正如 Michael 所说,使用的方法是 useServiceWorker().

                  As Michael has called out, the method to use is useServiceWorker(<registration>).

                  https://firebase.google.com/docs/参考/js/firebase.messaging.Messaging#useServiceWorker

                  Messaging 类是您调用firebase.message() 时返回的内容.

                  The Messaging class is what is returned when you callfirebase.message().

                  所以样本是:

                  navigator.serviceWorker.register('./example/sw.js')
                  .then((registration) => {
                    messaging.useServiceWorker(registration);
                  
                    // Request permission and get token.....
                  });
                  

                  我刚刚在 Github 上的演示应用上尝试了这个,没有问题:https://github.com/firebase/quickstart-js/tree/master/messaging

                  I just tried this on the demo app on Github without issue: https://github.com/firebase/quickstart-js/tree/master/messaging

                  这篇关于Firebase:更改服务人员的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  quot;Status Code:200 OK (from ServiceWorker)quot; in Chrome Network DevTools?(“状态码:200 OK(来自 ServiceWorker)在 Chrome 网络开发工具中?)
                  How to set a header for a HTTP GET request, and trigger file download?(如何为 HTTP GET 请求设置标头并触发文件下载?)
                  Adding custom HTTP headers using JavaScript(使用 JavaScript 添加自定义 HTTP 标头)
                  SQL Query DocumentDB in Azure Functions by an integer not working(通过整数在 Azure Functions 中 SQL 查询 DocumentDB 不起作用)
                  Azure Functions [JavaScript / Node.js] - HTTP call, good practices(Azure Functions [JavaScript/Node.js] - HTTP 调用,良好实践)
                  Azure Functions - Import Custom Node Module(Azure Functions - 导入自定义节点模块)
                    • <legend id='XE85B'><style id='XE85B'><dir id='XE85B'><q id='XE85B'></q></dir></style></legend>
                    • <small id='XE85B'></small><noframes id='XE85B'>

                    • <tfoot id='XE85B'></tfoot>

                        <bdo id='XE85B'></bdo><ul id='XE85B'></ul>

                            <tbody id='XE85B'></tbody>
                          <i id='XE85B'><tr id='XE85B'><dt id='XE85B'><q id='XE85B'><span id='XE85B'><b id='XE85B'><form id='XE85B'><ins id='XE85B'></ins><ul id='XE85B'></ul><sub id='XE85B'></sub></form><legend id='XE85B'></legend><bdo id='XE85B'><pre id='XE85B'><center id='XE85B'></center></pre></bdo></b><th id='XE85B'></th></span></q></dt></tr></i><div id='XE85B'><tfoot id='XE85B'></tfoot><dl id='XE85B'><fieldset id='XE85B'></fieldset></dl></div>