Push notifications arrive after a long time on some devices - android

On Android, I have been experiencing long push delay in some devices (minutes, half an hour). Seems like the device is asleep (but not for WhatsApp). Even on Pre-Marshmallow devices.
After a while they don't respond to push.
I have created a simple app (copied Google's Cloud Messaging client sample).
Tried to send push via The Firebase Console, setting priority to HIGH and made sure it works.
Experiment 1: After a while - tried to send. The device is not responding.
Experiment 2: Tried to use Telegram and WhatsApp. Message passes immediately on both.
Experiment 3: Tried the my test app again. Not working.
Experiment 4: Tried to downgrade from FCM to GCM and all the way to C2DM. Same thing, not working.
Any ideas?
To make it clear:
The token is okay. In most cases it works. It just falls asleep after a while.
It's a Lollipop device so no Power Saving exempts here or battery saving.
I use priority:high on the payload.
It is no server issue because I use FCM composer and it's just the same.
Waking the device does not necessarily fix it. It just begins to receive notifications minutes later and then all ok.
Other apps such as WhatsApp work without problem whatsoever, always.
I tried C2DM, GCM, FCM. I am using a printout on the C2DM receiver. They all behave the same.
I log everything. Every event, broadcast I get. I don't get push when I should.
Possible clue: some of my customers are using VMWare AirWatch. anybody know about any issues related to AirWatch and Push?

This is not a complete answer so I can't mark this question "Answered".
I found some alternative push mechanism called Pushy. It's mentioned quite a lot in Stack Overflow.
Pros:
I have made tests on a phone where FCM and GCM failed. Pushy succeeded to deliver all my messages, always.
It can work on devices with no Google Play Services enabled
It is also a workaround for the SERVICE_NOT_AVAILABLE issue.
They have a nice friendly console like in FCM, where you can send test messages.
You get a feedback when the message was delivered to Android devices.
Has topics like in FCM so you can send one message to a group.
Cons:
Money. It costs. Not too much. Last time I checked it was 0.5Cent per month for each active user. It may be a lot but my app is an emergency app so availability is a must in my case.
Does not have retries like FCM, as far as I understood. I may be wrong but it does not handle many things that FCM does. It may not do exponential back-off retries or Notification Messages A-la-Apple. I personally hate FCM behaviour on that so I am fine with this.

Related

Is Google Cloud Messaging GCM Reliable?

I am developing an application that will get some data from the server e.g. live feeds. It will be a multicast message. I just want to know if whether GCM is reliable. I don't want the notification to be on time, if the is a delay of about 1 hour then also it is OK for me. Should I try GCM or go for Web Socket. Does any popular android app use GCM? If yes then please do mention.
Neither GCM none other similar services like iOS Push notifications are 100% reliable, but those messages are usually really fast and they always work, so it depends on the level of trust you need. I'd personally go for them.
I have used GCM before, and in my experience it is very reliable.
If at all i faced any issues, they were in upstream messages (i.e from the device to the server).
I would say that you will get much better performance than 70% delivery with a one hour delay.
Go for it! :-)

Send message from Server to Android device and vice versa

I want to implement a chat application. But I have a few questions, which I could not solve by searching the internet.
My requests are:
Of course I can address each device individually from my server (makes sense for a chat app)
I can create a time delay between sending and receiving a message
The application should not require a registration (this is not a MUST, but would be nice)
I wonder if GCM (Google Cloud Messaging) is the appropriate solution for me. I have not yet worked with it, so I would like to have some help. Will I run into troubles with this? And most important: Is a registration required?
You will run into troubles surely, GCM is not for creating chat applications . You will need this XMPP.GCM is kind of thing used for broadcasting messages,which does not even guarantee the delivery of messages instantaneously i.e real time which you will be requiring.
SEE THIS TOO: Android and XMPP: Currently available solutions

Google Cloud Messaging (GCM) not delivering when device is back online

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

C2DM to GCM code Migration

I have migrated my code for push notifications from C2DM to GCM. The only change I have made on client side is replacing the email account passed in the sender parameter of the registration intent with the project ID. The server side changes have been done too.
However, I experience a delay in receiving push while using GCM. The delay is like for 1 - 2 mins. I did not experience the same delay while using C2DM.
Please help!! Is this problem cause of GCM, or am I missing something.
I've set up GCM and pushes are almost instant. Couple things to check is that your server is sending it without a delay. And also that you are not spamming it, i noticed that after a certain amount of pushes in a small time period, and Google will start delaying pushes..
Other than that the only issue could be the GCM service and/also your phone. Make sure that your phone's radio is open at all times and you are using a stock OS. See if the problem is still happening in couple of hours so (in case there's a problem at the GCM servers)

Send push notifications on android without using C2DM

Is it possible to send push notifications to an android application without using Google server: C2DM?
So, I would like to have my own server which sends notifications directly to the app, but I'm not sure how are the notifications perceived by the device, because the device needs to receive notifications even if the app is not running and the notifications should appear in the notification center.
I think that the guys from www.airpush.com have managed to this, but I'm not sure how.
Can anyone help me with this please?
UPDATE:
Also I would like to know how to display the notifications in the notification center if I don't use C2DM? And if it is possible to configure the notification center to receive notifications from my server even if the user deletes the application developed by us, application which registered that device to receive notifications.
I want to send 3-4 notifications a day, but these notifications need to appear in the notification center and they should go only through our server. How can I configure the notification center within the app to make requests on my server for push notifications.
Thank You!
There is a solution from UrbanAirship called Helium push. According documentation Helium:
Works on Android 1.6 and higher
Does not require a Google Account
No default pushes per day limit
No default pushes per minute limit
Works on Amazon devices (e.g., Kindle Fire)
End to end Urban Airship support (i.e., API to to device)
Best throughput
The problem is that you need development app key for using this one.
Take a look at MQTT:
MQTT stands for MQ Telemetry Transport. It is a publish/subscribe, extremely simple and lightweight messaging protocol, designed for constrained devices and low-bandwidth, high-latency or unreliable networks.
It can be used (and was used in some applications) to implement custom server push solutions. One of the most well known applications using MQTT is Facebook Messanger.
You can easily find more information on MQTT in the Internet, e.g. in this SO question or in this blog post.
According to the FAQ on airpush.com, they're not using real push notifications but rather polling the server a few times per day. One reason I think this is a viable solution for you as well is that Android's C2DM apparently makes use of the Google Play Store, so it won't work on devices distributed outside of the Google eco-system. With over 5 Million Kindle Fires having sold already, that is worth thinking about.
From Airpush FAQ:
When executed once from the main activity of an Androidâ„¢ application, the Airpush client utilizes Androidâ„¢ OS's AlarmManager framework to schedule ongoing server polling events a few times per day. If an ad is polled from the server it is cached until optimal display time, which is algorithmically determined by the server.
Without using C2DM there's not option for a "real push notification". Because (afaik, correct me if I'm wrong) an android device registers at google (they can still deinstall malware from your phone via remote) and with this ip they are able to do a push notification. All other solutions could tend to be a "register at a server, keep the connection alive and wait for requests" or something and tend to be more battery-inefficient.
Parse has an excellent push notification service for Android, very easy to setup. More info here: Parse Android Notification Doc
If you want the user to only receive 3-4 messages per day and your messages are not bound to specific arrival times, you don't need pushing mechanisms.
Just create a service in your app that checks your own web service 5-10 times a day. If there is new data, make your app display it in the notification center.
If you don't want to have a service running all the time (like many messaging apps do), you can set up alarms (using the Android AlarmManager framework) that wake your app up regularily to check for new messages to display.
And if it is possible to configure the notification center to receive
notifications from my server even if the user deletes the application
developed by us, application which registered that device to receive
notifications.
That sounds like you want to write a virus or root kit ;-) You could use e-mails for your messages instead.
UPDATE 2013-12-30:
As just noted in my comment, rebuilding what GCM does is not a nice approach. It's enough when Google Services already load the device with this functionality. If your goal is just that Google does not see what messages you send to your users, you might aswell encrypt them. For Google not being able to actually read your messages, the client app should generate a key and send it to your server. All messages you send via GCM can then be encrypted using that key.
If you just want to circumvent Google's restriction on the amount of messages sent to users, you could pack multiple messages into one GCM notification and show them one after the other. But then again, we are back at some kind of polling solution as described before, with the exception that the user does not need to have internet access when you want to show the messages as they are cached on the device.

Categories

Resources