GCM Sent messages before subscribing - android

I just implemented Google Cloud Messaging successfully in my Android application and to test it I sent some messages from my server, that worked perfectly.
I was wondering what happens if I send a message to an specific topic and then a device subscribes to that topic, will it receive the message?
Will my users receive the messages I sent while I was testing it?
Thanks

I have not found this behavior defined in the GCM documentation. My experience (version 8.3.0) has been that when a client subscribes to a topic, it does not receive messages previously sent to that topic. Although messages have a default time_to_live of 4 weeks, server processing to hold the message and send it later is only applied to devices that have subscribed but are not able to receive the message because they are turned off or do not have a network connection.

Related

FCM Message delivery report is not received

I use an Application Server to send downstream message to android device via FCM using XMPP.
As mentioned in docmentation, I set "delivery_receipt_requested" to true, but most of the times I am not receiving delivery request report from device. I just receive ACK messages from FCM which confirms that Data Message is delivered to FCM Server (but not received by the target android device).
Is there any way from experts to help me?

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.

Simpler push-notification, perhaps ask server if there is any?

Im working on a ide where I as an admin can send notifications to all my clients(mobile). Ive been searching and found GCM and other services... I want to know if there is any simpler solutions.
I thought about making a rest call from all clients(mobile) to my server every 1 hour to check for new notifications. And if there is, get them and then present those notifications i the clients(mobile).
Polling will result to more battery life consumption and some other extra unnecessary process (as also mentioned in the comments by #MohammedAtif), for example, is when your client app makes the call to your server but ends up empty. The process is wasted since nothing really happened.
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.

Latter Delivery Ack. from GCM to App server?

I am using GCM for Chat App. If User is Offline(not Connected to App but internet is active) then i Send push notification to devices It receive perfectly.
But when Device is totally offline(neither connected to App and nor active internet) at that time GCM send me response like { id: XXXXXXXX,success: 3,failure: 2{message_id:xxxxx,ect:..}} on my App server.
two device are totally offline they don't have active internet connection..
when device will connect to internet GCM Send them message.
but how can my App server will Know that Message is delivered by GCM.
I Search a lot but can't get any satisfied answer.
I tried that on messageRecive at client device(Android device) i will send httpRequest to my App server but it not suitable for my app it makes App very slow.
So Question is how Can i know that my failure 2 message are delivered.
First of all, you do not need to update your app server in case of a downstream message after it is sent to GCM Server. As explained here, GCM server stores the message in case of an offline device and delivers it once the device is online.
(Now assuming that what you want is to handle network tasks on the client)
You can use GcmNetworkManager to batch network discovery and connectivity related tasks across the system through Play Services. Go through the documentation.
You can use GCM Statistics and Diagnostics from Google Play Developer Console, too. This gives you details of messages handled by a particular app (through Registration token) down to status of specific messages (through message IDs). More explanation here.
(However I am not too clear exactly what you want)
EDIT
but how can my App server will Know that Message is delivered by GCM.
Sorry, reading through again I realised this is the real question. Answer is pretty straight forward here.
.

GCM Message Delivery Confirmation

I am implementing push notifications with Google Cloud Messaging. I am simply testing with their demo applicaitons on official site.
All is working well.
But, has anyone idea of how to gurantee the delivery of message, in anyway?
Or can we invoke server to let know once the message are delivered in device, and will it be reliable approach?
Take a look at the answer on Android GCM delivery monitoring.
"They don't guarantee delivery but they try for a max of 4 weeks to deliver the message depending on the duration you set in the message you send to Google's GCM servers and if you wish to let Google keep the data for eventual delivery of msg to the device in case the device was offline when the message was to be delivered."
Google has added support so that you can receive delivery receipts from Cloud Connection Server (CCS):
You can use upstream messaging to get delivery receipts (sent from CCS to your 3rd party app server) when a device confirms that it received a message sent by CCS.
To enable this feature, the message your 3rd-party app server sends to CCS must include a field called "delivery_receipt_requested". When this field is set to true, CCS sends a delivery receipt when a device confirms that it received a particular message.
https://developers.google.com/cloud-messaging/ccs#receipts

Categories

Resources