flyerhq / flutter_firebase_chat_core

Actively maintained, community-driven Firebase BaaS for chat applications with an optional chat UI.
https://flyer.chat
Apache License 2.0
265 stars 211 forks source link

Does it support push notifications? #29

Open petodavid opened 3 years ago

markzakharyan commented 3 years ago

I believe you need to write your own firebase cloud messaging function for push notifications

demchenkoalex commented 3 years ago

Will leave this open to add some documentation examples

SalahAdDin commented 3 years ago

Will leave this open to add some documentation examples

Any news about this?

demchenkoalex commented 3 years ago

@SalahAdDin when something is changed I always update the issue, there are other things we are working on right now. I am sure there are tons of resources on how to add push notifications to FCM and it is doable without any "examples". I have left this open for anyone to share the setup, if that will happen before we get to this ourselves.

dvird commented 2 years ago

I think the problem for you going to be that you need to hold the fcm token on the server somehow. Im using realtime database for that because firestore charge per read and write and it can be really expensive for something that has high read and write Frequency

but thats how i did it on the firebase functions here is an example : https://paste.ofcode.org/33gBdZAH3iLNYd82meFdLQe

you should be aware that this library is very expensive and its only for mvp and not for scale.

demchenkoalex commented 2 years ago

It is correct, this is not for scale. I mean creating something to scale requires paid developers I guess, not a free library.

dvird commented 2 years ago

I want to believe that not, there are some projects but they not are not in nodejs so i skipped. thats great library for a lot of people, i improved it and i have architecture that can scale easily to a lot of users without costs on firebase. but i think you should add advise to people to add limit to firebase because some cute junior can get 1000$ bill easily with that

demchenkoalex commented 2 years ago

Will do, thanks for the suggestion!

demchenkoalex commented 2 years ago

Btw you mean you combine Firestore with Realtime Database, or you use Realtime Database only?

dvird commented 2 years ago

im using realtime db, in a way of a pipe. its not good for every application but for me it does. you have whatsapp? whatsapp dont save your data on their servers, they just hold it till you sync it to your phone and then delete it. and because realtime db not charge per operation so its pretty cheap. the problem with firestore is that their developer that invest too much time to help us reduce costs. when you read 100 documents so yes there kind of cache mechanism but you can be sure that 100 read going to be 10,000 per device

demchenkoalex commented 2 years ago

yeah, it is a very specific use case, which should be developed from scratch for a particular project. With this lib I just wanted to make something that work quickly, to show the MVP or even use it until you have like thousands of users, that means money, that means you can develop your own scalable solution.

dvird commented 2 years ago

yes cool, its also why im using your library :)

MarlonJD commented 2 years ago

I think the problem for you going to be that you need to hold the fcm token on the server somehow. Im using realtime database for that because firestore charge per read and write and it can be really expensive for something that has high read and write Frequency

but thats how i did it on the firebase functions here is an example : https://paste.ofcode.org/33gBdZAH3iLNYd82meFdLQe

you should be aware that this library is very expensive and its only for mvp and not for scale.

can you share this code again?

igoSilva27 commented 2 years ago

Acho que o problema para você será que você precisa manter o token fcm no servidor de alguma forma. Estou usando o banco de dados em tempo real para isso porque o firestore cobra por leitura e gravação e pode ser muito caro para algo que tenha alta frequência de leitura e gravação

mas foi assim que fiz nas funções do firebase aqui está um exemplo: https://paste.ofcode.org/33gBdZAH3iLNYd82meFdLQe

você deve estar ciente de que esta biblioteca é muito cara e é apenas para mvp e não para escala.

can you share this code again?

cledilsonwisp commented 2 years ago

Acho que o problema para você será que você precisa manter o token fcm no servidor de alguma forma. Estou usando o banco de dados em tempo real para isso porque o firestore cobra por leitura e gravação e pode ser muito caro para algo que tem alta frequência de leitura e gravação

mas foi assim que fiz nas funções do firebase aqui está um exemplo: https://paste.ofcode.org/33gBdZAH3iLNYd82meFdLQe

você deve estar ciente de que esta biblioteca é muito cara e é apenas para mvp e não para escala.

Could you send it again?

DikshaCT27 commented 2 years ago

https://medium.com/@duytq94/flutter-chat-app-extended-push-notification-messages-a26c669f4675

You can try this link to send push notifications using firebase cloud functions.

smunshimi commented 1 year ago

Anyone able to get push notifications to work as intended?

giorgio79 commented 1 year ago

There are plenty of tutorials and examples already that can be tailored to the app.

Here are the best

This one has good tips. Eg if the user is on the chat screen in the foreground, save a "chattingWith" userId, so the app wont send messages (would be annoying to see the chat on the screen and in a notification..." Etc

Sam-Guru-In-Training commented 1 year ago

I've adapted the first Medium tutorial for my chat screen.

I skimmed the second 'follow on' article, it uses this:

document(‘messages/{groupId1}/{groupId2}/{message}’) is the path to message document.

This is how it observes when new messages are written. But this is not how messages are stored in the first Medium tutorial 😭

I need a way to send push notifications for peer-to-peer messaging, where the Firestore Collections are a hash of each user's Id, and the records are given an Id from Timestamp.millisecondSinceEpoch the instance they were sent.

I use Flutter so some complexity is removed. The fact I'm considering Javascript complicates things greatly for me because that's a whole other domain to hack.

It would be really REALLY great to have an example of how to use this plugin with push notifications, with specific instructions for dummies.

It's got to the point where I looked up off-the-shelf solutions {SendBird, Stream}, but they rapidly cost $500+ a month or guarantee you downtime. I think it's highly likely that Firestore even with considerable Transactions will be cheaper for a LONG time; you'd need a MASSIVE number of chatty users before the off-the-shelf solutions are cheaper. But a chat screen without push notifications 🤷