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.
Related
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.
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.
I'm having the following problem with UWP push notifications.
Scenario:
Foreground registers a background task for push notifications but also wants to be notified of incoming pushes so it gets a channel, updates the server with the channel then hooks onto events on that channel.
Push notification comes in
Background task launches and does it's work. It also checks to see if the channel URI has changed, if it has, it updates the server with the new uri.
Result:
Foreground app no longer receives incoming pushes on the channel because the background task updated the server with a different channel uri from what the foreground app was listening on.
What is the proper way for the foreground app to continue listening for push notifications after the uri potentially changed?
Updated problem for clarification:
Step 1 Foreground app code:
var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
channel.PushNotificationReceived += OnPushNotificationReceived;
//<update server with channel.Uri
Step 2 Background task launches and also checks for a new channel uri:
var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
//update server with channel uri
Problem
If channel uri changes in Step 2 then the even handler in Step 1 never gets invoked again.
because the background task updated the server with a different channel uri from what the foreground app was listening on.
No. Your understanding was incorrect. Let's first check the steps on how to send a push notification:
Your app requests a push notification channel from the Universal Windows Platform.
Windows asks WNS to create a notification channel. This channel is returned to the calling device in the form of a Uniform Resource Identifier (URI).
The notification channel URI is returned by Windows to your app.
Your app sends the URI to your own cloud service. You then store the URI on your own cloud service so that you can access the URI when you send notifications.
When your cloud service has an update to send, it notifies WNS using the channel URI. This is done by issuing an HTTP POST request, including the notification payload, over Secure Sockets Layer (SSL). This step requires authentication.
WNS receives the request and routes the notification to the appropriate device.
Then, if you understand these steps, you will find that the key point of sending a notification to the appropriate device is you need to request a notification channel. This channel URI is unique for every device no matter whether the channel URI is updated. So, even if your UWP app's background task has updated the channel URI on your cloud service, it will not affect the device to receive the notification. As long as you could make sure that the channel URI is the latest when you use this channel URI to send notification, then your device will always receive the notification(Except for some special cases, e.g, the device is powered off or device is in battery saver etc).
Please read Windows Push Notification Services (WNS) overview for more detailed information.
What is the proper way for the foreground app to continue listening for push notifications after the uri potentially changed?
What you said was not correct. There is no relationship between the "listening for push notifications" and "the uri potentially changed".
If you want to do some operations when the devices receive notifications, you could use the Notification listener to perform specific actions when notifications are received.
I have my XMPP server which was working with GCM. I upgraded to FCM as per google says though I am able to receive notifications from FCM notification console, not able to receive any upstream messages with FireBaseMessaging.send() ... If any one has done this migration please help.
Note : I have a XMPP server which was working and able to receive upstream messages via GCM. (After migration to FCM it is not receiving any messages even though the end points are changed. Am i missing anything from docs)
This is fixed ! while using both (GCM, FCM) dependency in my project I was using a string resource default-project_id from GCM dependency. I now removed and replaced that with the project_id and it is fixed. So endpoint change is not mandatory.
Make sure you update the server endpoints. Note that the new FCM version of gcm-http.googleapis.com/gcm/ is fcm.googleapis.com/fcm/ (without "http"):
Change GCM endpoint
gcm-xmpp.googleapis.com
to FCM endpoint
fcm-xmpp.googleapis.com
source: Migrate a GCM Client App for Android to Firebase Cloud Messaging
For more information, Check this Upstream message syntax for FCM and how to send Upstream messages on Android.
I have an app set up to generate passbook passes. The successfully install on the device and I can do manual (pull-down) updates.
Next I began to implement APNS. I'm using the enhanced request method to connect to the production environment, sending in an empty payload (as required) and it returns no error codes when I request a push notification, but my pass never updates and I see no requests hitting my server. I'm using my own device to test until I can get see an update for myself. No pass updates are received.
I then implemented the Feedback service in the hope that it might tell me something. I noticed this. If I pass in the push token, I receive a response which indicates that the device is not receiving notifications (even though the pass is set for automatic updates). The pass is not updated.
I'd appreciate any info into why the the push notifications do not seem to be arriving.
Thanks.
-Erich
One gotcha to check is that you are not using the sandbox APNS server. All Passbook push requests should be sent to the live APNS server.
Try enabling the additional logging option from the PassKit section of the Developer Settings on your device then connecting your device to Xcode and monitoring the console as you send the push. If the push is received, then you should be able to see your device requesting the serials to be updated from your webservice and you should also see your server's response.
Assuming you send a serial and that it matches the serial installed on your device, you should then see the device requesting the updated .pkpass bundle.
If no push is received, try toggling automatic updates on and off while monitoring the device console. It could be that the device is not receiving a valid registration (201) response or that you are using a stale token - you'll be able to see these via the console.