I have implemented GCM push notification in my app. It's working fine. In some scenarios, notification should be received immediately, but I receive it very late. Is there anyway to check whether I have notification in my GCM Queue ?
Note:
I understand that, Push notification mechanism is completely to overcome Polling mechanism. But curious to know whether the above thing is possible or not ?
The Google Cloud Messaging server returns a response for each message you send to it. That message tells you whether the message was accepted or rejected by the server (it doesn't tell whether it was actually delivered to the device) and also specifies the type of error if any.
You may check the Offical Google Cloud Messaging documentation: https://developers.google.com/cloud-messaging/#receipts
Related
I have working with FCM console to send push notification and it has an option to schedule the delivery date.
But in the references, this API is not documented as an option. I need to know if its possible to push a notification with predefined delivery date through a POST request.
If you're looking for a public API of FCM for a scheduled push or a payload parameter where you can set the push date, unfortunately, there's nothing like it as of the moment.
You must implement your own App Server and implement the scheduled push yourself (also mentioned it here).
As an alternative to ALs excellent answer: you could:
send a data message with FCM straight away,
in that message include a field with when the message is to be displayed,
them in your application code show the message when it is due.
This has the added advantage that the message can be delivered when the user has a connection, and then displayed when they don't have a network connection.
Of course this only works if you can determine the exact message before it is displayed. If the contents of the message can only be known right before it is displayed, you will need to implement your own mechanism to schedule deliver as AL said in his answer.
According to the Firebase Cloud Messaging documentation if the app server sets a field "delivery_receipt_requested" in the upstream message, it will receive a delivery confirmation when the app confirms receipt. However it works only if app server is connected with XMPP connection server. It will not work for HTTP connection server.
I'm very new to GCM/FCM and haven't setup my server yet. Hence am working with Firebase console to test my app for notification receipts.
So, following are my queries.
Will the field "delivery_receipt_requested" be sent to the app or the connection server itself will consume it.?
If the app receives this field in a notification will it need to act differently from the notification which do not contain this field.?
Any references to documentation or example implementation which makes use of this field is highly appreciated.
Thanks in advance.
Will the field "delivery_receipt_requested" be sent to the app or the connection server itself will consume it.?
The FCM client installed in Google Play services will handle this.
The application will not notice anything different.
If the app receives this field in a notification will it need to act differently from the notification which do not contain this field.?
The application doesn't need to take any action. indeed the app will not receive this field.
Longer explanation:
delivery_receipt is not exactly a confirmation that the app received the message, but it's a confirmation that the device received the message. To be clear it's still possible that the device crashed or run out of battery while the message is being passed to the app.
this feature is implemented outside of the application. so the application doesn't need to be aware that this message requires a delivery receipt
you can implement a more precise "application delivery receipt" by calling your backend in the method that receives the message.
(like an http call to: http://mywebsite.com/confirm-msg-processed-successfully.php?id=133)
If I want to create an instant messaging application using android, is it a good and efficient to use the Google Cloud Messaging API ?
There are a lot of mentions in GCM documentation and tutorial saying that is no guarantee of order and success receive of messages. Like here:
Note that since there is no guarantee of the order in which messages
get sent, the "last" message may not actually be the last message sent
by the application server.
I suggest you use this as a call to update user chat e.g. when your app get a GCM you request your server-side to get the new messages but not transfer messages by GCM itself also because you have some dayly limits as well.
See more here: http://developer.android.com/google/gcm/index.html
I found the mention above here: http://developer.android.com/google/gcm/server.html. At description of collapse_key here: http://developer.android.com/google/gcm/server.html#params
Yes, it works for Google and you won't have to maintain servers. If your message is short, in can be included in the GCM message. Otherwise the GCM could be a payload to notify your app to check for a new message.
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.
So I have a situation which I didn't think would happen based on my understanding of the registration My understanding:
Phone Registers with google gets registration_id, send registration_id to the server, use registration_id when sending out push notifications. If registration_id is updated by google, they will send a new registration broadcast.
However, I have case where a phone was registered, and was successfully receiving push notifications, but than one day the server goes to send a push notification to the phone and I get a error "NotRegistered" which would suggest the registration_id refreshed but did not get propagated through the system properly, whether it be on the phone side or the server side.
My question is has anyone else hand issues like this? What is the best approach to making sure this doesn't happen?
From the Android Cloud to Device Messaging Framework documentation:
Note that Google may periodically refresh the registration ID, so you should design your application with the understanding that the REGISTRATION Intent may be called multiple times. Your application needs to be able to respond accordingly.