There is an issue with the serialization of the event_time field on systems set to Italian locale. The ':' characters are being converted to '.', which causes the server to return the following error:
Invalid value at 'message.android.notification.event_time' (type.googleapis.com/google.protobuf.Timestamp), Field 'event_time', Invalid time format: Failed to parse input
Steps to reproduce:
Set your client system locale to Italian
Send a notification
Observe the server response
Relevant Code (how to solve):
In file FirebaseAdmin/FirebaseAdmin/Messaging/AndroidNotification.cs
Substitute
/// <summary>
/// Gets or sets the string representation of the <see cref="EventTimestamp"/> property.
/// </summary>
[JsonProperty("event_time")]
private string EventTimeString
{
get
{
return this.EventTimestamp.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:ss.ffffff000'Z'");
}
set
{
if (string.IsNullOrEmpty(value))
{
throw new ArgumentException("Invalid event timestamp. Event timestamp should be a non-empty string");
}
this.EventTimestamp = DateTime.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.None);
}
}
with
/// <summary>
/// Gets or sets the string representation of the <see cref="EventTimestamp"/> property.
/// </summary>
[JsonProperty("event_time")]
private string EventTimeString
{
get
{
return this.EventTimestamp.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:ss.ffffff000'Z'", CultureInfo.InvariantCulture);
}
set
{
if (string.IsNullOrEmpty(value))
{
throw new ArgumentException("Invalid event timestamp. Event timestamp should be a non-empty string");
}
this.EventTimestamp = DateTime.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.None);
}
}
Description:
There is an issue with the serialization of the event_time field on systems set to Italian locale. The ':' characters are being converted to '.', which causes the server to return the following error:
Invalid value at 'message.android.notification.event_time' (type.googleapis.com/google.protobuf.Timestamp), Field 'event_time', Invalid time format: Failed to parse input
Steps to reproduce:
Relevant Code (how to solve):
In file FirebaseAdmin/FirebaseAdmin/Messaging/AndroidNotification.cs Substitute
with