invertase / flutterfire_cli

A CLI to help with using FlutterFire in your Flutter applications.
Apache License 2.0
164 stars 47 forks source link

request: generate or support web/firebase-messaging-sw.js #215

Open jakusb opened 9 months ago

jakusb commented 9 months ago

Is there an existing feature request for this?

Command

flutterfire configure --include-messaging

Description

Running "flutterfire configure" works like a charm for normal Firebase operations, but is missing out on Cloud Messaging assistance. We now need to still manually and hardcoded introduce our own firebase-messaging-sw.js for web.

Steps to reproduce the behavior: Run "flutterfire configure" Notice web/firebase-messaging-sw.js is not created

Expected behavior web/firebase-messaging-sw.js or any working equivalent should be created, optionally through flag or always

Reasoning

messaging is important component of many apps. Hardcoding should be avoided where possible

Additional context and comments

No response

fourman-alex commented 5 months ago

This is a major headache and one which is hard to find the cause or a solution until you stumble on https://github.com/firebase/flutterfire/issues/11678 This should be documented somehow, maybe as interim workaround flutterfire configure prints a warning when configuring web, if firebase_messaging was added in pubspec.

amrgetment commented 5 months ago

For flavors when you generate that file: my solution by using IndexedDB and Hive https://github.com/firebase/flutterfire/issues/12146 While the best solution is https://github.com/flutter/flutter/issues/141371

JayceeZ commented 3 months ago

I think this is the official reference to how to create the service worker: https://firebase.google.com/docs/cloud-messaging/flutter/receive#web