I opened this topic to learn the best way and get advice from you.
I have a cryptocurrency app. For now, I'm only showing the instantaneous values of certain tokens with the help of an API. What I want to do is add a reminder. For example, to be more descriptive, I would like the user to be notified when the value of a token reaches the value he has set.
I have a few questions at this point:
For this, would it be better to keep the data that the user added to
receive notifications in SQLite or should I use firebase?
Will there be any issues if I trigger notifications via Firebase
Cloud messaging?
Can I communicate between Firebase Database and Cloud Messaging?
How can I constantly check the token values received with the help
of the API while the application is closed?
These are my questions, I would be very happy if someone who is knowledgeable on this subject can help me draw a roadmap or architecture.
Related
I am new to flutter and Firebase. I have registered my android app with firebase. My final goal is to send notifications to all the users automatically with a cloud function. So far, I know either I need to store the list of FCM tokens of all the users or subscribe them to perticular topic. I was thinking of going with subscribing to the topic, so that I will not have to store the tokens in my firestore. So, my question is where should I write
FirebaseMessaging.instance.subscribeToTopic("drawNotifications");
Because, If I put it in the main or initState, then it will be called everytime the user runs the app and if I do so, is it the right way to?
Please feel free to let me know if I need to explain it more clearly as this is my very first question in Stackoverflow.
It is good practice to give a user option to opt in to receive notifications. Prompt the user to get consent to receive notification and give an option to cancel at any point.
Although subscribeToTopic can be called multiple times from the same device within certain restrictions.
The frequency of new subscriptions is rate-limited per project. If you send too many subscription requests in a short period of time, FCM servers will respond with a 429 RESOURCE_EXHAUSTED ("quota exceeded") response. Retry with exponential backoff.
https://firebase.google.com/docs/cloud-messaging/flutter/topic-messaging
I am working on a project there i need to implement notifications one day before the expiry of the documents , hour before the pickup etc. And the dates for the expiry and pickup are stored in the database I have to fetch it and send a notification to the user.
I need to implement something that could fetch the data when the expiry is near can i use firebase cloud messaging for the same? or any other ways to do it more efficiently.
Thanks in advance.
If data stored in remote database then there is two possible way.
First, all logic have to implement in remote side and server will send payload for notification, which you have to triggered through FCM.
And secondly, you can call api and implement notification on app side.
Implement a custom Firebase Cloud function that would run on a certain schedule (1h or 5 mins, based on your usecase) and would check if any documents expire within a given timeframe. If you find such documents, issue a FCM to notify the owners of the document.
It is not a good idea to implement this behavior in the app itself because nobody can guarantee that the application will be live at the time when the check should be performed. This is primarily due to android battery optimizations introduced in the latest OS versions.
For more info and examples, look at the following documentation:
Cloud Functions - https://firebase.google.com/docs/functions
Scheduled functions - https://firebase.google.com/docs/functions/schedule-functions
I think the title is clear enough. How can I do that? I need to set my custom data as token to any device in FCM. is it possible? Thanks
FCM tokens (nowadays called Instance IDs) are determined by FCM, and cannot be determined by your own code.
You might want to elaborate in your question on the actual use-case, since there typically is another/better way to accomplish the goal when this comes up. Also see What is the XY problem?
I'd like to make notifications with Firebase when the Firebase Database is modified. I guess this could make with Firebase functions and Firebase Cloud Messaging, but I don't know if this way is correct or not, please if someone can help me clarifying this doubt, below I explain that I want my application to do, thx!!
I want my app to send notifications all the users near the another user(1km for example) when this user publish an ad.
As fellow developers, I encourage you to boldly try whatever comes up in your mind!
But if I were you, I'd do the same thing. Firebase Functions allow you to have function trigger according to Firebase Realtime Database events. So you can use that, to trigger a specific function that will send a FCM Message.
In your Android App, make sure to implement FirebaseMessagingService (and set it up in your AndroidManifest.xml), and every time message is received (through FirebaseMessagingService.onMessageReceived), create new notification!
The latest launch of Firebase notifications feature allows to manually give the time and content of notification. Is it possible to automate it so that notification is received every time a particular variable is changed in the Firebase database?
Thanks for the reply Hamid. I didn't want to get into the technicalities of GCM therefore I implemented the notifications using a service. This service listen on the Firebase database and sends a notification whenever new data is added there.
I think you would have to setup a GCM (Switched to FCM now) server that handles all that. But I also do wish that there was a simple way of setting that up without needing to build a full server.
There is a friendlyping application that helped me set the XPMM server.
I think the current Firebase Notifications are very much in its early days. It doesn't provide many of the functionalities of Batch.com or Parse Server... yet.