Reputation: 63
I would like to receive firebase notifications in my flutter web app. I know that the firebase_messaging package is not available for web. But I've already managed configure my app to get a token, receive and display a message when the web app is in the backgroud and to receive (but not yet display a message) when the app is in the foreground.
I did so by creating JavaScripts (and service workers) as described here:
https://medium.com/@rody.davis.jr/how-to-send-push-notifications-on-flutter-web-fcm-b3e64f1e2b76
https://firebase.google.com/docs/cloud-messaging/js/client
https://firebase.google.com/docs/cloud-messaging/js/receive
The problem is that so far I've only managed to sent the messages to 'a specific token' or 'to everyone' and I need to send messages to a 'specific topic'.
The documentation for cloud messages to specic topics with JS contiues here: https://firebase.google.com/docs/cloud-messaging/js/topic-messaging
But the problem is that in this part the codes are no longer placed in the index.html file as before. (It's either node.js, java, python, Go or C#)
And I do not know how to implement that in my flutter web app. Is it even possible?
This is the part that I would like to add to my flutter web app:
Upvotes: 3
Views: 5586
Reputation: 2364
While an answer has been given, I would like to point out that when using Flutter, use the flutter firebase package rather than the javascript SDK. The flutter package allows you to register and unregister the user from a topic directly from Flutter, rather than dealing with the server side SDK
Upvotes: -1
Reputation: 599081
The JavaScript SDK for Firebase Cloud Messaging does not support subscribing to topics, which unfortunately that Flutter for web also doesn't/won't have it.
This means that a web app cannot subscribe itself to topics, like Android and iOS apps can. Instead, for web apps, you will have to use a server-side SDK to subscribe to a topic.
So you'll need to:
Also see:
Upvotes: 8