GCM duplicated messages - android

I have an app based on Google Cloud Messaging and it was working well. Now (today) all of a sudden it started having a problem we've never seen before. For each message sent between devices, the receiving device will get it twice. The first will arrive almost instantly (within less than 3 seconds of sending). The second arrives a few minutes later. There are two devices in the test, the problem is the same whichever one is the sender/receiver. So if a device sends a few message to the other, the other will get them pretty much instantly--but then at a later time, it will receive a barrage of messages which are the second copies of the messages it has received.
I have put in breakpoints to make sure that the sending device wasn't the culprit: the message was sent exactly once (i.e. the web service for sending was called exactly once--and the code for the backend, which runs on Google App Engine, hasn't changed for ages.) However, the message somehow gets delivered to the receiving device twice. By using breakpoints I also made sure our own code on receiving side isn't responsible: it is verified that GCMIntentService::onMessage() indeed gets invoked twice for each sent message.
We also made sure the registration id in our database is the latest. At this point I'm stumped and need ideas to make any further progress. So any ideas?

https://groups.google.com/forum/#!topic/android-gcm/EHZUTEJMeyw
Check the official GCM thread above. Everyone is experiencing this issue. Google's fault!

We also have the same problem, and we are sure we don't send the message twice.
It could be an issue related to what's explained here about "Canonical IDs": http://developer.android.com/google/gcm/adv.html
[...] However, if a bug in the application triggers multiple registrations for the same device, it can be hard to reconcile state and you might end up with duplicate messages.

Same problem here. We have many apps integraded with MyMalcom and Urban Airship and all of them are getting pushes twice since Monday. We have checked also the canonicalId changes as suggested by Ferran, but the delivered to GCM messages are ok (no cannonical Id changes).

Related

Push notifications arrive after a long time on some devices

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.

FCM data message not received in Android when the application is in background

I face a very strange problem; I had a previous version of my application published using GCM 8.4.0 which worked fine. I updated some code, without changing anything about GCM and I realised that the messages where not received anymore when the application was in background. This on several different devices.
As I was unable to find any explanation, I migrated to FCM. I made few unsuccessful attempts and it began to work !?! Then I was able to send several different messages successfully without changing anything! Houra!!!!
Just before generating my signed APK, I made a last test! Arrggghhhhh.... messages were not received anymore when the application was in background!!!!
I made the test with my server, with Advance REST Request, in the same conditions as I used for successful attempts and no way, it works when the application is in foreground but no more at all when the application is in background!!!
Did you exeperience such problem???
I precise that when I receive a message with the application in foreground and I generate a notification from it, There are 2 different behaviors:
When the application is able to receive it in background, the notification remains when I swipe the app out from the recent apps list.
When the application is not able to receive it in background, as in my current case, the generated notification is removed when I swipe the application out.
Does it mean something useful?
Edit
I updated to 9.2.0 but the problem remains.
So I got it working few weeks ago but rebuilding the project with several updates, studio, sdk, java, I cannot get the same project working now anymore.
I spent few hours to explore the web, notably Stackoverflow about this problem and the answer I could do is "It depends...." I personnally got it working, it doesn't work anymore, for some of you it works, for some others it doesn't...
So I started from the FireBase quickstart-android project and what I can say is:
No, data messages are not received when the application is in background. Or maybe I would say: data-messages are not received anymore when the application is in background.
So I ask the question to Firebase-support expecting a good answer. I was really disappointed, the answer is:
Hello ... team,
Thank you for reaching out to us.
Actually data payload is not supposed to be received in background. Data message intents are delivered to the application and received inside onMessageReceived() method (which does not fire in background). Only display messages/ Notifications are delivered when the app is in background.
...
Sincerely,
K...
I don't know what you think about that but for me it's a real disaster!
I don't know if it's a temporary situation or not, maybe someone could have more precise information because I cannot believe that background message reception is not supported anymore. Or at least for us because according to my logs, the device receive background messages displaying the following message:
07-18 15:28:34.371 3068-3068/? W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.google.firebase.quickstart.fcm (has extras) }
But the onMessageReceive() callback is not invoked!
IMPORTANT EDIT
Building this kind of project, for example FireBase quickstart-android project from command line tools perfectly works but not when you build it from IDE debug button.
If you want to build your project from IDE debug button, use Android Studio 1.5 strange but works perfectly).
Complete test case is available here.
Sorry, I didn't pay attention that delay_while_idle was set to true by mistake.
Edit
The behavior is strange anyway because even with delay_while_idle= true, my previously published application using GCM 8.4.0 and built with Studio 1.5.2, receives messages while in background.
The same project rebuilt with Studio 2.1.2. (nothing changed in the project except the asked update to gradle 2.1.2) doesn't receive the messages while in background, which is the expected behavior.
But it doesn't receive it either while coming in foreground!
Updating to FCM 9.2.0 works similarly, i.e. it doesn't receive messages while in background, ok, but it doesn't receive it while coming in foreground, which seems not correct.
** EDIT 2 **
I definitively cannot get it working anymore

onMessageReceived called randomly

I've just released an update for an application and I've noticed something strange. In the app, push notifications are sent out to users when new news is available and this has been working fine ever since the first version, however, since the new version there have been instances where onMessageReceived is called but the bundle is null. Now what makes this strange is that firstly this only happens to two HTC users at roughly the same time and secondly no code has changed in the app regarding the push notifications.
When I initially looked into the issue I thought that the users may be receiving push notifications late and then for some reason the data was null, however, no push notifications have been sent out in the last few days yet this error is still occurring happening.
Are there any other circumstances why onMessageReceived would be getting called even if there are no remote push notification being sent out?
Any feedback would be fantastic!

sinch messaging APi Recieving duplicate messages

I am using the sinch.com's service for instant messaging but I recieve old messages anytime a user logs in or reinstall the app.
actually those messages have already been retrieved from their servers.. according to their documentation the messages are persisted only when the user is not online and also the persist the message for maximum of 30 days after when it will be deleted.
the issue might be the way you have implemented the sinch api. you can limit the IM retrieval only for certain time range. Can you share your code snippet or explain a bit more!
When you log out, our servers dont know that the messages have been delivered to that device. We keep messages for delivery for 30 days. AS a developer you will experience this more since you are wiping the install when you deploy.
If you just kill the app and launch it again you will see that its not delivered again.

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)

Categories

Resources