0

When I was using Parse from Facebook, I could test notification while in development (i.e. no app on the Play Store). But right now I am trying to implement Firebase into my app. My app is not published yet. I am done with android side implementation and am trying to send a notification from the Firebase console to my app. But my device never receives the notification. Why is that? I am targeting "All Users" because firebase does not have a version or any of my topics.

OKAY

So I did some more troubleshooting and here it is: my device is receiving notifications, but it's doing so weirdly:

  1. when the app is open and the user is interacting with it, the notification goes through the expected pathway of calling onMessageReceived.

  2. When the app is closed (not in recent apps either), the notification skips calling onMessageReceived and displays a notification in the status bar.

But then here is the log from FireBase when onMessageReceived is skipped

05-24 07:15:52.842  D/TimaKeyStoreProvider: TimaSignature is unavailable
05-24 07:15:52.842  D/ActivityThread: Added TimaKeyStore provider
05-24 07:15:53.102  D/FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
05-24 07:15:53.132  D/FirebaseApp: Initialized class com.google.firebase.iid.FirebaseInstanceId.
05-24 07:15:53.142  D/FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
05-24 07:15:53.222  I/FA: App measurement is starting up, version: 9080
05-24 07:15:53.222  I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
05-24 07:15:53.352  D/FirebaseApp: Initialized class com.google.android.gms.measurement.AppMeasurement.
05-24 07:15:53.352  I/FirebaseInitProvider: FirebaseApp initialization successful
05-24 07:15:53.372  D/AlgorithmsProvider: onCreate
05-24 07:15:53.452  I/FA: Tag Manager is not found and thus will not be used
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Katedral Pillon
  • 14,534
  • 25
  • 99
  • 199
  • you can test anytime just like parse. Parse used the same thing as Firebase – tyczj May 23 '16 at 15:50
  • I kept trying and it finally started working. But I see a problem. When my app is open, then the notification goes to `FirebaseMessagingService#onMessageReceived` (I am logging it). But if my app is not open, then I see a notification in the device's status bar, but the onMessageReceived never gets a call. – Katedral Pillon May 23 '16 at 16:01
  • 1
    That indeed sounds like the expected behavior for Notifications. If you want more control over what happens, you'll want to use Firebase Cloud Messaging (the rebranded-and-updated version of GCM). – Frank van Puffelen May 23 '16 at 16:24
  • @KatedralPillon if you want finer control over what happens do not put a `notification` tag in your payload and use a data tag. Using a data tag will always call your onMessageReceived – tyczj May 23 '16 at 18:34
  • @FrankvanPuffelen I am migrating from GCM. I am trying to take advantage of sending notification from the console as opposed to the usual from my server. @tyczj, this notification vs data tag distinction sounds promising, but I don't believe I am using a notification tag. Where in the console would I make this distinction? As far as I know I am using data tags under `Advanced Options` – Katedral Pillon May 24 '16 at 13:47

1 Answers1

1

For the display-messages (messages with notification tag), it's the expected behaviour that the onMessageReceived only called when the app is on foreground.

If you want to use data-messages (message without notification tag), you can't do it via console (at least until this time). You have to manually create post request to FCM server. You can see that post request example from answer to this question How to handle notification when app in background in Firebase.

Community
  • 1
  • 1
Kharda
  • 1,318
  • 14
  • 23