Is there any way to start the Google Cloud Messaging Service explicitly. Apparently after sometime (after 4 to 5 hours) my app stops receiving any messages from GCM. If I go to app and check in the running apps tab, I can no longer see the Message Service in my application. Is this normal?
Furthermore I think GCM is the most unreliable service for push notifications. I have encountered many a times an issue where I am not able to send a notification but if I start the application then I start recieving notifications.
I think there are only two possibilities:
GCM is down (unlikely)
Your server doesn't send the messages to the correct device
either because it doesn't send message at all
or because GCM has changed the registration ID, and your application failed to handle this correctly (but it should if you followed the sample from the SDK)
Related
When testing to the android app from the firebase console the status of the messages says completed and shows the delivery date. How do we check whether a message has sent to the receipts and delivered in an android app with fire-base: https://console.firebase.google.com?
I am working on a firebase quickstart app to test push notification message to my target users. Please help me.
#SaikCaskey have an insight of the solution of your question, though I do not agree on some points.
The push notification is not guaranteed to be received to your targeted user actually. Push notification might fail for several reason. But that's not the issue here. You might get notifications even if your application is in background or stopped. You need to start your FirebaseMessagingService with START_STICKY. This behaviour might differ in different devices too. Some devices allows/disallow this behaviour of receiving push notification when your app is stopped.
So, if you need to log when your user has received the push notification, you might get it in a bit complex way. When your device will come online you'll get the push and in your onMessageReceived function you can get the System.Clock for getting the time of notification received. Then create an instance of Firebase and then set the time to the reference node of the user's notification delivery time.
Hope that helps!
I wrote an app which implemented the FirebaseMessagingService; I killed the process which the service belongs to, but the app can still receive the notification from firebase console, except that I forced to stop the app.
So, I just want to know why the app can still receive the notification event though the service not alive? What's the mechanism of android?
I don't have experience in Firebase, but in previous Google Cloud Messaging it was working this way: at first notifications (pushes) are received by Google Play Services and then redirected to your app starting proper broadcast receiver or service. probalby Firebase is working same way - it's starting new service when it is not running currently
When none of the activity is launched even once,i want to send a push notification to the user.
For example, once user installs application but doesnt open then a notification is pushed that please use the application.
Please help me with the code.
You can't. How would the user call the registration process for the push messages if he never ran the app itself? Until he does, the app is considered to be in a stopped state and you can't interact with it unless you have another app installed that would "start" it.
You can start a background service on application level and registering on gcm server and other process so even if app is not used you can send notification as your service has registered your device with gcm id on your server.Call api for registering device to your server from your GCMIntentService class.
I'm trying to build a GCM notification listener, which will basically use the notification to flag the user that some operation should be made (which involve communicating with my remote App-Server).
I assumed that I should create a UI-less application running on the device's startup and listen to the GCM notifications and issue the internal android notification. When the user opens the notification an activity will be opened which will do the rest of the job with the remote App-Server.
Looking at notification examples it seems to me that I may be missing some basic understanding since all te examples which I had found use a UI application to manipulate the notifications.
What do I miss?
The common use case for handling of GCM messages in Android apps is as follows :
Your app registers to GCM upon startup and sends the registration ID to your server.
Your server sends a GCM message to your app.
You app receives the message in a broadcast receiver, which usually starts an intent service.
The intent service usually displays a notification to the user.
The user taps the notification, which starts an activity of the app.
You can see this use case implemented in the official GCM demo and in many other examples.
The fact that the app you wish to develop has no UI doesn't prevent you from implementing the exact same use case.
I am developing Android app using GCM. Currently I am using standard Google libs on client and server sides.
If I am testing on two Android devices GCM works fine when both devices switched on regardless if my app is running or not.
However if Device A is switched off and I am sending messages to it from Device B, when Device A switched back on it doesn't receive any messages been sent while it was off line.
On server side (which initiates an actual send) every message to Device A has no collapse_key, time_to_live is set to 2000000 (just in case for testing purposes). Actual send has retries parameter set to 50 (in case GCM itself is unreachable, however this is unlikely).
Do I need to complete the GCM registration procedure on device boot? Currently I do so.
Please note that GCM broadcast receiver and GCMIntentService were set as well as permissions
in manifest as described on Google web site.
Any advice will be much appreciated. I really got stuck with this issue.
Sorry guys. It was my fault. Shared preferences were not loaded properly, that caused GCMIntentService to operate unproperly. Messages go in fine.
So SOLVED
Do I need to complete the GCM registration procedure on device boot?
No, you don't.
In our project we don't have any problems with receiving messages which was sent while device was switched off or ofline. We don't use any google libraries and done all as described at gcm homepage Also, we don't set any collapse_key and time_to_live for our messages.
By the way, do you process message_type? My be GCM notify you that message was deleted