firebase / firebase-admin-dotnet

Firebase Admin .NET SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
367 stars 131 forks source link

Add latest HTTP v1 options #153

Closed jwoodwardtfx closed 2 years ago

jwoodwardtfx commented 4 years ago

It seems there are a lot of newer options for FCM not available in the .NET Firebase Admin (see https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#AndroidNotification).

Specifically the newer options for AndroidNotifications. The current class ends at "channel_id", however the following are now available:

"ticker": string, "sticky": boolean, "event_time": string, "local_only": boolean, "notification_priority": enum (NotificationPriority), "default_sound": boolean, "default_vibrate_timings": boolean, "default_light_settings": boolean, "vibrate_timings": [ string ], "visibility": enum (Visibility), "notification_count": integer, "light_settings": { object (LightSettings) }, "image": string

Is there any plan to add support for these?

hiranya911 commented 4 years ago

They will be added eventually. Feel free to send a PR in the meantime. Following API signatures have been proposed to expose these options in .NET:

public sealed class AndroidNotification
{
    public enum Priority
    {
        MIN,
        LOW,
        DEFAULT,
        HIGH,
        MAX,
    }

    public enum Visibility
    {
        PRIVATE,
        PUBLIC,
        SECRET,
    }

    [JsonProperty("title")]
    public string Title { get; set; }

    [JsonProperty("body")]
    public string Body { get; set; }

    [JsonProperty("icon")]
    public string Icon { get; set; }

    [JsonProperty("color")]
    public string Color { get; set; }

    [JsonProperty("sound")]
    public string Sound { get; set; }

    [JsonProperty("tag")]
    public string Tag { get; set; }

    [JsonProperty("image")]
    public string ImageUrl { get; set; }

    [JsonProperty("click_action")]
    public string ClickAction { get; set; }

    [JsonProperty("title_loc_key")]
    public string TitleLocKey { get; set; }

    [JsonProperty("title_loc_args")]
    public IEnumerable<string> TitleLocArgs { get; set; }

    [JsonProperty("body_loc_key")]
    public string BodyLocKey { get; set; }

    [JsonProperty("body_loc_args")]
    public IEnumerable<string> BodyLocArgs { get; set; }

    [JsonProperty("channel_id")]
    public string ChannelId { get; set; }

    [JsonProperty("ticker")]
    public string Ticker { get; set; }

    [JsonProperty("sticky")]
    public bool Sticky { get; set; }

    [JsonProperty("event_time")]
    public DateTime EventTimestamp { get; set; }

    [JsonProperty("local_only")]
    public bool LocalOnly { get; set; }

    [JsonProperty("priority")]
    public AndroidNotification.Priority? Priority { get; set; }

    [JsonProperty("vibrate_timings")]
    public long[] VibrateTimingsMillis { get; set; }

    [JsonProperty("default_vibrate_timings")]
    public bool DefaultVibrateTimings { get; set; }

    [JsonProperty("default_sound")]
    public bool DefaultSound { get; set; }

    [JsonProperty("light_settings")]
    public LightSettings LightSettings { get; set; }

    [JsonProperty("default_light_settings")]
    public bool DefaultLightSettings { get; set; }

    [JsonProperty("visibility")]
    public AndroidNotification.Visibility? Visibility { get; set; }

    [JsonProperty("notification_count")]
    public int? NotificationCount { get; set; }
}

// Add new class for LightSettings

public sealed class LightSettings
{
    [JsonProperty("color")]
    public string Color { get; set; }

    [JsonProperty("light_on_duration")]
    public long LightOnDurationMillis { get; set; }

    [JsonProperty("light_off_durtaion")]
    public long LightOffDurationMillis { get; set; }
}
levimatheri commented 4 years ago

Is anyone working on this, or can I take a stab at it?

hiranya911 commented 4 years ago

@levimatheri nobody's working on it afaik. Feel free to provide a PR :)

JesperNJessen commented 3 years ago

Is there some way of adding the "title_loc_key" to the base Notification object? It seems to be needed for iOS localization of messages as described here:

https://github.com/CrossGeeks/FirebasePushNotificationPlugin/blob/master/docs/LocalizedFirebasePushNotifications.md

Snippet:

Finally, when sending the payload would look like this:
{
     "notification": {
            "title_loc_key" : "NOTIFICATION_TITLE",
            "body_loc_key" : "NOTIFICATION_MESSAGE"
     },
     "priority": "high",
     "condition": "'general' in topics"
}

It doesn't seem to work when using the AndroidConfig class.

WillooWisp commented 2 years ago

Is anyone working on this, or can I take a stab at it?

@levimatheri Did you make any progress on a PR for this?

WillooWisp commented 2 years ago

@hiranya911 seems like even after a year, nothing has happened to making the payload feature complete with v1, why? Is this package deprecated?

levimatheri commented 2 years ago

@WillooWisp I had submitted a PR here a while back.

WillooWisp commented 2 years ago

@hiranya911 and @lahirumaramba why is the PR above not being merge, when you requested it over a year ago?

Please make a new NuGet release with this included.

lahirumaramba commented 2 years ago

@WillooWisp Thank you for pointing this out! Apologies for the delay, we have started the review process. Stay tuned for an update on the release.

lahirumaramba commented 2 years ago

This feature is now available in v2.3.0. Thank you for your patience!