GCM Server knowing of successful delivery - android

As far I as know, upon successful posting a notification to GCM Server, it will return a status code of 200 and a response as such id=1:2342.
However, according to their documentation, this does not guarantee successful delivery to the device. Just a successful status of delivering the notification to the GCM server.
So my question is, is there a way for me to know that the notification has been sent to the phone successfully? Is there a Delivery Notification returned by GCM to my side upon successful delivery? If not, does any of you guys have any ideas on keeping track of those?
Thanks.

GCM does not notify your server when the message is sent to the phone.
If you require that functionality, you'll have to implement it yourself. You can attach a message identifier field to the GCM message. When the message arrives to the phone, your app will send that message identifier back to your server (using an HTTP request), to acknowledge that it received the message.

Related

How to diagnose notifications that have a GCM outcome of 'Success' but don't reach the device

This is really a continuation of another question I posted, except now I'm using Azure's push notification telemetry and Google discontinued FCM diagnostics in the Play Console.
I get reports from users saying they haven't received notifications. But the Azure telemetry shows results like these, even for these notifications:
"GcmOutcomeCounts": {
"Outcome": {
"Name": "Success",
"Count": "1"
}
}
Crashlytics shows no crashes, so the only thing I've come up with is putting calls to a logging API in to see where it fails or stop working, but it never even reaches the app in this case.
There has to be a way of figuring out exactly where and why the notification fails. What is it?
There has to be a way of figuring out exactly where and why the notification fails. What is it?
Here is my 2 cents. In general, there can be many points of failure for notifications. Your aim would be to figure out which at which point the issue lies. Below is the diagram from the home page of FCM:
Potential failure points:
When the app sends registration token to your server.
Handling update of the FCM registration token.
If there is an error sending registration token, then you can have a
custom non-fatal exception send to Crashlytics. Since you already
seem to have the token I don't think it is the issue. However in
some cases the token might change, so just double check that
you are implementing onNewToken() and sending the new registration
token to server in case its changing.
When sending notification from your server to FCM.
When sending it from FCM to user device.
To confirm if there is no issue when sending the notification from
your server -> FCM -> user device, you can try getting a delivery
receipt from FCM as mentioned here: Receive delivery
receipts.
It says:
For Android and Chrome client apps, you can get delivery receipts (sent from FCM to your app server) when a device confirms that it received a message sent by FCM.
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, I've seen sometimes issues with firewall on the user's network, back in days when there was GCM. There could be an issue where firewall is blocking the notification. IP range of google GCM push notification server? Try opening the potential list of ports if that's the case or try testing on carrier data network. Since you mention that you've to include log at various points in the app but it never reaches. Looking into the above points can be the next steps.
Handling notification within your app / showing the notification in the notification drawer.
Hope this helps a bit in debugging your issue.

Fetching analytics related to push notification in `FCM Cloud Messaging`

I want to know whether push notifications are delivered to all the registrationId mapped to my user database or not.
I have 8000 users and all are having registrationId. I had sent notification to all of them and now i want to determine whether all those user had received the notification or not.
so is there any way to access this analytics using some FCM url.
I am aware that i can see analytics in google publisher from STATISTICS menu and selecting FCM messages and to check the delivery status i can go to FCM Diagnostics
Firebase support page
but using that tool to determine 8k users is nearly impossible so how can i get the analytics of cloud messaging.
Long back i have seen some link but forgot to bookmark :(
There is currently no API to retrieve the delivery status for sent FCM messages.
In general, when the FCM server successfully receives the payload you've sent from your App Server, it should return a success:1 response along with a message_id.
If what you're aiming for is to know if the device has successfully received the message, you should implement Delivery Receipts:
Delivery Receipt: If the app server included delivery_receipt_requested in the downstream message, the XMPP connection server sends a delivery receipt when it receives confirmation that the device received the message.

Lossing messages due to connection loss through openfire

Turning off internet on mobile device directly causes problems in my chat application. Messages are not stored in openfire offline table as Openfire still shows me online on abrupt disconnection from the server. when a relogin attempt is made the messages that were sent in that period are lost.
I am working on a chat application,after login to openfire I am able to chat and other users can see me online but the problem is if one user losses the connection like WIFI off,In such situation Openfire is not showing my status as offline and it still shows Online which results in message packet loss.
Please provide me the solution I am unable to resolve it.
On a sidenote how whatsapp and other apps send messages. Do they use message storage strategy on server and acknowledgement or am I missing something here.
Both client and Server needs to acknowledge that messages were sent & delivered, say for instance you send a message to someone else, what you can do here is that you save this message on your server, from server this message will be sent to receiver and wait for an acknowledgement by the receiver that the message was delivered, once you get acknowledgement - delete the message from the server.
How whatsapp do it? I found this answer by Michael Donohue on Quora
Whatsapp works on store and forward, The WhatsApp client will store any message you send, and keep trying to send it to the WhatsApp servers. When a WhatsApp mobile app connects to the chat servers, the store-and-forward process occurs in both directions. The client sends any pending messages in it's mesage store to the server, while the server sends all the accumulated messages destined for that client to the client. This process is done on an acknowlegement basis. This means messages are sent repeatedly until the other side acknowledges receipt of the message. server drops messages once they are acknowledged - there is no long term storage. Whereas the client will update the UI to double-check status once the ack arrives, but will keep the message.
In android client using Smack framework, you must disable Stream Mananement just after creating XMPPTCPConnection and before run connection.login().
connection.setUseStreamManagement(false);
I had this problem and with this code was solved.

Status of the Push Notification from google server

Is there any Possible way for getting the status of the push notificatioin wheater it is queued for sending or already Send.
I had posted some push notifications to gcm server but customers didnt got it.
Is there any possible way for getting the status of the notification
There is no way to get the status of an individual message from GCM server.
The response you get from Google only tells you whether your message was valid and accepted by GCM server.
Once the message reaches your app, the only way for your server to know about it is if your app notifies the server as part of handling the message. That's something you'll have to implement yourself, with an API call to your server.
Other then that, if a message was accepted by GCM server and didn't reach the app, you have no way of knowing whether Google attempted to deliver it or not.

UnExpected reply from GCM Server when i am sending the Expected URL

**Question (i)**
I have registered my android app in my mobile (Samsung Galaxy Pop) i am recieved a
registrataion_id
APA91bG9NI4U2jr4sUn1HLy5nHMFe1e0JOTgOoZv1Px**********************************
when i sent this registration_id to server side code which is refrenced from here
here i used function SendNotification having 2 parameters
My Registration_ID
My Message Which i want to show on notufication
http://www.codeproject.com/Tips/434338/Android-GCM-Push-Notification
I hit the GCM- Server and the result I got is
id=0:1368258967353783%978fee9266d6cf16
I did not understand what does this response means ? is it good ? bad ?
Question (ii)
if mobile device gets registration id from gcm server is it registered or still waiting for server side to send the Registration ID to GCM Server
Please help !! , Thanks in advance
Answer to(i)
The data you are getting is on plain text format and the data is refering to the message id. In this case the message was correctly sended.
To understand how it works visit this page GCM Architectural Overview
Answer to (ii)
The way GCM works it's
Your device request a registretion to GCM services.
Device is registered correctly by receiving the regId.
You send that regId to your server to receive push notifications.
Server saves the data
Servers wants to send a message to that device, sends a mesage using GCM services.
The device, if it is online, receives it and knows wich app haves to start.
The app receives the message.
On the same website you have further explanation, by the way start reading from getting started section.

Categories

Resources