onMessageReceived called randomly - android

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!

Related

Android - Some way to start Firebase Messasing (FCM) with activity?

Some way to start Firebase Messasing (FCM) with activity?
I'm see that sometimes it stops working randomly (this is serious and there has not been a significant change in the example code of the Google).
So I would like to start it in several possible events, to ensure its operation.
I find it strange that an official application fails so badly.
Receiving notification was supposed to be simple.
Works perfectly until you stop randomly, the application does not crash. I navigate through the application, close and open and no message arrives, then when I turn on and off the wifi the messages arrive.
The messages in Notifications have a little unpredictable behaviour for FCM. But it is nothing to worry about. Most (>99%) of Firebase notifications are delivered in less than 1 second. But occasionally for really small volumes in apps that are 'under development' on 'in experiment' you will find unexplained delays in delivery times of the notifications. I suspect this is because the FCM Servers prioritise the delivery queue. Nothing much to worry about. Keep on developing your app and you will find that more notifications you deliver using FCM, the more reliable it starts to become.

Firebase does not provide proof of the notifications been sent or delivered to the android app

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!

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

weird behavior when receiving push notifications

So I followed Parse's guide on setting up push notifications yesterday. I left the client channel to "" for Broadcast. And when I tried to send notifications, My phone didn't receive any. After trying to trouble shoot for a while I gave up and went to bed.
Then I was waken up by my phone buzzing at 6 in the morning. I look at it and it's the dozen push notifications I sent like 8 hours earlier. (To be clear when I sent them I set the all to now. I didn't schedule them). So when I try to send them today it didn't work. I tried switching the channel and it worked. I sent a push notification and my phone received it instantly. After that I went to eat, came back and tried to test some things out and my phone doesn't receive them anymore.
Has anyone ever noticed behavior like this or know what the problem might be. Parse tells me that they send just fine and I don't know if it's an issue with my code because it CAN receive them.

GCM duplicated messages

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).

Categories

Resources