make push notification service with signalr - signalr

Hi can I make push notification service with signalR?
for example when user start the app,app can recive message and if app closed again app can recive messgae from servers or clients

Until you can send the message to clients that user is online.
And with the closure of the app, Disconnect Communication server with the client. And the ability to send any message disappears.
If you want to send notification after app closed, It is better to use the google service. (e.g: Firebase Cloud Messaging (FCM) services),
Otherwise you can only use signalR for send message in your app.
I hope this is useful description.

If you want the ability to send messages or have messages available to any client then store them in a database table. When they are connected, you can send those messages to them. When they are disconnected they would stay in the database.
You can control flagging messages as read after they are delivered and then deleting them from the database.
Your "push notification" is just querying for the messages when a client is connected.

Related

How to Test FCM Data Push Notifications Delivery?

I have an Azure Web Service which is using an Azure Notification Hub to push data notifications using FCM via Firebase to a Xamarin Android App. Initially the app is getting a token which is posted to the web service. The web service then sends it with the data to the notification hub which is sending it to Firebase. The response back from the hub is indicating a successful transfer it seems from the notification properties and the ReqID property. But the notification is not reaching the app. Is there a way to see individual notifications' status on the Firebase site? Currently I don't see anything under the "Cloud" report for Data.
[
Thanks for asking question! One of the notification failure point could be when sending it from FCM to user device. To confirm this, you may try getting a delivery receipt from FCM.
You may refer to this article Receive delivery receipts. It says for Android and Chrome client apps, you can get delivery receipts which can be sent from FCM to your app server. To enable this feature, the message your app server sends to FCM must include the field delivery_receipt_requested. When this field is set to true, FCM sends a delivery receipt when a device confirms that it received a particular message. Also check for firewall on the user's network.

Can my phone receive Firebase push notification if I have installed an app that support it but I have never open it before

Do I need to open the app at least once in order for my phone to receive a push notification?
The must run at least once so it can collect a device ID token and send that to the backend that will send the message. Without that token collected, the app can never receive a message on that device.
Read more about it: What is FCM token in Firebase?
Actually you do not need the device token to send/receive the messages.
However, it is required that the user give permission to receive notifications, and that would only happen during runtime. I tested this and can confirm it works. The device token is only used to subscribe users to specific topics, but you can send a message to all users that have your app installed without needing to specify device tokens.

Can I send push notification without using device token

I want to send automatic push notifications to my clients who are installing my flutter application. Can I do it without getting their device tokens. I am using firestore as my database
You can send messages to client apps using topic messaging, but each client app will need to be subscribed to the named topic. You will not be able to single out a specific device without a device token.

Firebase Cloud Functions - Send Notification user when they are online again?

I'm using fcm to send user notification and its triggedred by writing data to firebase database. But when user is offline notification send but never received and user cannot see it after they back online. How to send notification in all conditions.
Example: If user online send message normally but if user offline wait until user online and send them. How can I do this?
According to documents firebase cloud messaging already support what i want.
If the device is not connected to FCM, the message is stored until a
connection is established (again respecting the collapse key rules).
When a connection is established, FCM delivers all pending messages to
the device. If the device never gets connected again (for instance, if
it was factory reset), the message eventually times out and is
discarded from FCM storage. The default timeout is four weeks, unless
the time_to_live flag is set.
So FCM service wait until client device connected again.And sen notification when cliend connected. But if user hasnt connected for four weeks message deletes itself and never sent.
https://firebase.google.com/docs/cloud-messaging/concept-options#ttl

Does push notification cause a continuous polling on server?

I am using Google Channel to do Push notification from server. It's working fine, but when I open the debugger windows, I can see lot of polling request that are going to the server.
Is that the way push notification works? If yes, then what is the use of it?
var token ="<%token%>";// This will creaete unique identifier(some id created by google api + ur key)
channel = new goog.appengine.Channel(token);
socket = channel.open();
socket.onopen = function() {
$('#messages').append('<p>Connected!</p>');
};
Thanks.
GCM doesn't do that. Gonna refer to the official docs on it's flow.
Lifecycle Flow
Send and receive downstream messages.
Send a message. The app server sends messages to the client app:
The app server sends a message to GCM connection servers.
The GCM connection server enqueues and stores the message if the device is offline.
When the device is online, the GCM connection server sends the message to the device.
On the device, the client app receives the message according to the platform-specific implementation. See your platform-specific documentation for details.
Receive a message. A client app receives a message from a GCM connection server.
Also announced in the recent I/O 2016, GCM's successor is now Firebase Cloud Messaging, which not only has the Push Notification Service, but also has other features (one example is Analytics) for free.
So overall, using GCM (or FCM) is a simpler method than polling. It handles the queuing of the messages you sent, and some others.
Part of my answer here. Also includes an idea why Polling is not ideal when sending push notifications.

Resources