Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[馃摎] [firebase_messaging_web] How to load on Flutter 3.22? #12798

Closed
stx opened this issue May 17, 2024 · 4 comments 路 Fixed by #12836
Closed

[馃摎] [firebase_messaging_web] How to load on Flutter 3.22? #12798

stx opened this issue May 17, 2024 · 4 comments 路 Fixed by #12836
Assignees
Labels
good first issue Good for newcomers platform: web Issues / PRs which are specifically for web. plugin: messaging resolution: fixed A fix has been merged or is pending merge from a PR. type: documentation Improvements or additions to documentation

Comments

@stx
Copy link

stx commented May 17, 2024

https://firebase.google.com/docs/cloud-messaging/flutter/receive#web has this:

<html>
<body>
  ...
  <script src="main.dart.js" type="application/javascript"></script>
  <script>
       if ('serviceWorker' in navigator) {
          // Service workers are supported. Use them.
          window.addEventListener('load', function () {
            // ADD THIS LINE
            navigator.serviceWorker.register('/firebase-messaging-sw.js');

            // Wait for registration to finish before dropping the <script> tag.
            // Otherwise, the browser will load the script multiple times,
            // potentially different versions.
            var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;

            //  ...
          });
      }
  </script>

But the Flutter 3.22 index.html format is completely different:

<script src="flutter_bootstrap.js" async></script>

When using existing code in the example and other repos, these deprecations are thrown:

Warning: In index.html:30: Local variable for "serviceWorkerVersion" is deprecated. Use "{{flutter_service_worker_version}}" template token instead.
Warning: In index.html:243: "FlutterLoader.loadEntrypoint" is deprecated. Use "FlutterLoader.load" instead.

Can we get a complete example of loading this with Flutter 3.22?

@stx stx added good first issue Good for newcomers type: documentation Improvements or additions to documentation labels May 17, 2024
@TarekkMA TarekkMA added plugin: messaging platform: web Issues / PRs which are specifically for web. labels May 20, 2024
@TarekkMA
Copy link
Contributor

@stx Thank you for reporting this issue and pointing that out. We will work on updating the current documentation to match the new Flutter version.

@electriko3
Copy link

Hello.
Can someone share the code of how the navigator.serviceWorker.register('firebase-messaging-sw.js' should now be registered in <script src="flutter_bootstrap.js" async></script> ?

@electriko3
Copy link

@stx hello. maybe u can share an example if u found a solution?

@Lyokone
Copy link
Contributor

Lyokone commented May 28, 2024

This pull request should guide you #12836

@TarekkMA TarekkMA added the resolution: fixed A fix has been merged or is pending merge from a PR. label May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers platform: web Issues / PRs which are specifically for web. plugin: messaging resolution: fixed A fix has been merged or is pending merge from a PR. type: documentation Improvements or additions to documentation
Projects
None yet
4 participants