I spent a few hours researching this with no luck, so I'm asking here. I've already checked these questions to no avail:
- How to get data sent from server using fcm if app is in background?
- Push notification not working with FCM
- Google FCM getIntent not returning expected data when app is in background state
Up until today (AFAIK — I haven't tested it in a while), Firebase Cloud Messaging was working just fine. I could send a notification with data from the Firebase Console, and using getIntent().getExtras()
would allow me to access that data from the app.
Today, however, I sent a test notification, but tapping it did not perform the expected action. After some digging, I found out that getIntent().getExtras()
was just returning null
no matter what. This is the relevant code:
private void respondToNotificationClick() {
if (getIntent().getExtras() != null) {
Log.e("NOTIF", "NOTIF");
//...
}
}
(This method is called from both onCreate()
and onResume()
in the main activity.)
But that log is never printed, and if I try to log Intent.getExtras()
outside of the if
statement, I get an NPE.
I suspect it has something to do with Firebase 11 vs 10 or maybe that this app is targeting API 26, but I just can't figure out how to fix it, and Google's documentation isn't always the most helpful.
What's going on here? Is it a known issue? Is it because I'm using a beta API (even though it's supposed to have been finalized)?