admin管理员组

文章数量:1414887

Up until very recently, when my app sent notifications to Androids, the receiving phone would get our custom icon in the notification bar, and when pulling it down, it would show what was in the "message" part under "data" (we use json messages). Now all of a sudden, many times it shows the generic Android icon, and then it shows the "title" part under notification. Did something recently change in Firebase Messaging -- say since early November?

Up until very recently, when my app sent notifications to Androids, the receiving phone would get our custom icon in the notification bar, and when pulling it down, it would show what was in the "message" part under "data" (we use json messages). Now all of a sudden, many times it shows the generic Android icon, and then it shows the "title" part under notification. Did something recently change in Firebase Messaging -- say since early November?

Share Improve this question asked Feb 21 at 0:28 fbs419fbs419 616 bronze badges 1
  • Even though I use FLAG_IMMUTABLE when I create PendingIntents, I still get this error: EUAlert: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Again, I haven't changed the app. Has anyone had this issue after not touching their app which used to work. It only happens when the app is in the background. It may have to do with older Firebase Messaging libraries, but I can't upgrade them because it's a Xamarin project. Is there any way around this? – fbs419 Commented Feb 23 at 17:11
Add a comment  | 

1 Answer 1

Reset to default 0

It turns out that the problem happened when notification message files were changed from Legacy to HTTP v1. The old messages were "data" messages, but the new ones were changed to "notification" messages. This caused OnMessageReceived (which builds my notifications and sets the IMMUTABLE flag correctly) not to be called when the app was in the background. By taking out:

"notification": {"title": "My TITLE", "body": ""},

from the JSON message file, OnMessageReceived would execute in all cases, and the app started working perfectly again. Posting this in case this happens to someone else.

本文标签: