Skip to content

Commit 6c263de

Browse files
fix(firebase_messaging): fix incorrect HTML example for service worker registration (#17839)
Separated inline JavaScript from script tag with src attribute. Browsers ignore inline JavaScript when a script tag has a src attribute, which was preventing the service worker registration from running. Fixes #17837
1 parent 2f619a3 commit 6c263de

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/cloud-messaging/receive.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ The file must import both the app and messaging SDKs, initialize Firebase and ex
189189
Next, the worker must be registered. Within the `index.html` file, register the worker by modifying the `<script>` tag which bootstraps Flutter:
190190

191191
```html
192-
<script src="flutter_bootstrap.js" async>
192+
<script src="flutter_bootstrap.js" async></script>
193+
194+
<script>
193195
if ('serviceWorker' in navigator) {
194196
window.addEventListener('load', function () {
195197
navigator.serviceWorker.register('firebase-messaging-sw.js', {

0 commit comments

Comments
 (0)