Operating system: Android
Operating system version: 6.0
What steps will reproduce the problem:
void Awake()
{
FirebaseMessaging.MessageReceived += FirebaseMessagingOnMessageReceived;
}
private void FirebaseMessagingOnMessageReceived(object sender, MessageReceivedEventArgs e)
{
var inboxMessage = new InboxMessage{
Title = e.Message.Notification.Title,
Body = e.Message.Notification.Body,
IsRead = false
};
SavingLoading.SaveMessage(inboxMessage); //This isn't a monobehaviour just a pure static claass.
}
What is the expected result?
App opens and stores the notification.
What happens instead of that?
After the 'Powered by Unity' splash screen, the app crashes.
I've used a logcat so I could trackdown some sort of exception if it occured, but none of the exceptions happened which are Unity or Firebase related.
@kantagara is this reproducible with our quickstart? If not, I suggest opening a support request on http://firebase.google.com/support so our support staff can take a look at your problematic project.
Also, it would be useful to know which version of Unity you're using, .NET version, build system (Gradle, Internal etc.) & host operating system & Firebase SDK version.
@kantagara , also what would be useful is attaching the logcat output to this bug so we can take a look. We haven't seen this issue and neither have any other customers AFAIK.
@stewartmiles Thank You for the reply.
I'm currently experimenting with quickstart app, and I think I found the issue. For whatever reason, Notification in e.Message object is null, and because of the nullreferenceexception in the script where I load the notification, that exception is causing all the other scripts to not function properly (didn't use try-catch block in the callback).
Do You have any idea why the Notification is null, although the title and the body of the notification are shown properly in the notification bar?
Thank You very much again.
EDIT: I can achieve the desired functionality (to store the messages I receive) by adding two KeyValuePairs in the data dictionary: one for the body and one for the title. But it still bugs me why the notification object is null.
EDIT2: I think I found the answer in the firebase documentation for Unity:
Messages received while the app is in the background have the content of their notification field used to populate the system tray notification, but that notification content will not be communicated to FCM. That is, FirebaseMessage.Notification will be a null.
@stewartmiles You can close this issue, and thanks again for the tip to check my idea with this quickstart. Will do that every time if l encounter any issue in my game.
Best regards.
@kantagara the notification field will be null when there is no notification data. You can send messages with or without a notification payload. See https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages for different message types and https://firebase.google.com/docs/reference/unity/class/firebase/messaging/firebase-message#class_firebase_1_1_messaging_1_1_firebase_message_1aa10fa82f455d7186e3ed5b06872c4a3f for a description of this field (note it's optional, only set when the message contains a notification payload)
The 5.1.0 release of the Firebase Unity SDK resolves this issue:
Release notes: https://firebase.google.com/support/release-notes/unity#5.1.0
Download: https://firebase.google.com/docs/unity/setup