Customize push notification with a text, the user can choose - firebase

i want to create a push-notification out of xamarin.forms, where the user can choose the text.
Like, the user want to get a reminder for something called "Dad's Birthday".
I have seen i can create push-notifications with firebase, where i can write down something, but i want the user to customize text to shown in the notification.
e.g.
User opens the app, create a new reminder called "Don't forget to drink enough!", set the timer for tommorow 4pm save it and close the app. I don't want to get a notification, only shows something standard for all like 'You have a reminder.'
Maybe there are other services except firebase they can do it?
Is there any way for it?

For your requirement you dont have to actually use the firebase firebase messaging instead. Use local push notification , in your case that best suits your requirement. Use firebase i.e remote push notificatoin only when you want some non user of the app to send the notification to the user of the app , it may be via another app or firebase console.
Answer from - Krishna Acharya

Related

For a simple chat functionality why should I use something like Firestore when Push Notifications might be enough

In this simple scenario, why would someone choose to pay for a realtime service like Firestore for delivering latest updates, when a system based on Push Notifications can work as good?
If the user is not in the app, you can refresh the page as soon as the user taps the notification or opens the app. When the app is open you can refresh when a data notification is received.
What am I missing?
Why should anyone use something like Firestore when Push Notifications seems to be enough?

Send local personalized notifications without login

I have been trying to find an answer for a while now. I am creating a react native App, and want to send personalized notifications to a user. I only want to ask the user for their name and number, and don't want to make them create an account. Is there a way i can save this info in firestore?
Right now for firestore the only way I see to save user data is to first make them sign in.
auth.createUserWithEmailAndPassword(email, password)
I just want to be able to get a users name and save it in a database, to then be able to send notifications like "Good Job John Doe". My app has no need for an email and password auth.
You can use anonymous authentication to create temporary anonymous accounts. This can be linked to a user if they decide to sign up to your app.
You can use firebase firestore to store user information without using authentication.
Just simply ask the user about their name and number, save it in the firestore. Then using Firebase Cloud Messaging subscribe to a topic which will be unique to the user (name+number or something like that). Then using firebase cloud function or manually you can send notifications to each individual user

How to handle FCM subscribeToTopic and unsubscribeFromTopic with Flutter

I am developing an app for which I use firebase as the backend. I am using FCM to send notifications to my users, however, I am not yet grasping how to use subscribeToTopic and unsubscribeFromTopic.
My use case (which I do not know how to get it working):
After a user installs the app, he will be subscribed to the main topic of the app (I have this working). The user could then go to settings to unsubscribe from the main topic (I do not have this working).
The struggle:
All the different tutorials I find describe how to subscribe to a topic, they call subscribeToTopic('some topic') in initstate of the welcome screen. Is it required to do this everytime the app starts? What happens when the user calls unsubscribeFromTopic('some topic') and the next time they start the app subscribeToTopic('some topic') is called again in initstate?
My idea: first time the app is loaded I call subscribeToTopic('some topic') and never again. Then in the settings screen a user can unsubscribe (and subscribe). Does this work? What should I pay attention to?
Thanks in advance for helping!
You check if the app is launched for the first time by either using shared_preferences which stores this information locally or by storing a variable on Firestore that tells you if the user has logged in to the app before.
You subscribe to the topic if it's the first time and if it's not, you do not subscribe.
The first time you open the app show a welcome screen or something like that, where you ask the user to receive notifications or not (which is always more user friendly).
If the user continues you save this value in a local database like shared preferences or hive.
If the user subscribed you call the subscribe to topic method
If the user does not subscribe ofcourse you do nothing.
Then on the settingspage:
Show a switch which value is gathered from the local database you already defined.
When the user taps the value is stored, based on this value you subscribe or onsubscribe.
This is how I have done it in my app where I also use topics instead of tokens.

Send notification when something change in Database

I want to implement logic to my xamarin.Forms application (for android and Ios), which sends notification to user when something new appears in database. For example when other user add an invitation to database, invited user will receive it. Thanks
If you want to send out push notifications, take a look at One Signal. It is free to use and in my experience is also the easiest to set up with Xamarin.Forms. You would need to follow their tutorial on how to get things set up for iOS, Android, and your server side implementations. After that when something in your DB changes just send a push notification from your server.
Here is a link to the Xamarin.Forms setup: One Signal - Xamarin.Forms
You can also use them to notify the users via email, however I have not tried that.
It depends completely on your underlying backend and services (REST? Websockets?, ...) and is to general to answer clearly.
For a good instruction how to use notifications in Xamarin.Android, take a look here:
Local notifications on Android

Dynamic Push Notifications

I know that Firebase has recently added support for Push Notifications and while this is a great thing, I only seem to be able to send push notifications manually via the Notifications Panel.
What I'd like to do is to send push notifications within a user scope...Let me explain that. Each User in my App has an account and then each user can join a group. Within this group the user can perform tasks and has a list of chores to do. Now when certain tasks are due for example I want to remind the user of doing it with a push notification. For 1-10 I might be able to pull this off manually, but is there a way to dynamically based on the data in the Database send out Push Notifications?
I know that certain Push Notifications can be created using the Analytics tool such as "Hey you have not visited for 3 days, please come back whatever"... but I'd like to register push notifications such as "I just created a task, this task needs to be done within 3 days. Remind me in 3 days if the task is still not done".
Is this possible with Firebase or do I need to have my own server connecting to Firebase and handling those events?
-xCoder
You need to implement FCM in your client and in a server. Let me put this straight:
First, you need that your client, or app, to register into FCM and get a FCM token that will be used to identify that device uniquely.
Then, store that token wherever you like. It can be into firebase database or other server you may like. I recommend you to store it into firebase if you are using it as a database for your users; that's my case.
Also, you need to implement a http or xmpp server in order to send FCM messages to your registered devices containing the data you are interested in. For example, you can implement a Google App Engine endpoint (can be done with Android Studio and Java) that is quite simple or a NodeJS module, depending on your preferred language.
If you are using Firebase as database you can connect from your server with the appropriate SDK and get the FCM tokens you want from your users, and then send the message to those with data. Don't forget to secure your serve.
The way you implement your server algorithm to send FCM messages depends on your app purposes.
Hope it is clear enough for you. Also you can find all the documentation with a short video that explains the general structure here: https://firebase.google.com/docs/cloud-messaging
You can use cloud functions to trigger on any create, update or delete operation in your database and in the trigger event, you can choose to send in FCM push notifications to the devices of your choice.
Here is the documentation regarding the use and structure of a cloud function: https://firebase.google.com/docs/firestore/extend-with-functions
Hope this helps!

Resources