2017-10-18 03:49:34 +02:00
using System ;
2025-11-14 09:44:01 +01:00
using System.Runtime.Versioning ;
2025-11-09 12:05:07 +01:00
using System.Text.Json.Serialization ;
2017-10-18 03:49:34 +02:00
namespace ElectronNET.API.Entities
2017-10-03 04:40:37 +02:00
{
2017-10-24 21:43:27 +02:00
/// <summary>
///
/// </summary>
2025-11-22 02:16:10 +01:00
/// <remarks>Up-to-date with Electron API 39.2</remarks>
2017-10-03 04:40:37 +02:00
public class NotificationOptions
{
2017-10-15 17:03:07 +02:00
/// <summary>
2025-11-22 02:16:10 +01:00
/// Gets or sets the title for the notification, which will be shown at the top of the notification window when it is shown.
2017-10-15 17:03:07 +02:00
/// </summary>
2017-10-03 04:40:37 +02:00
public string Title { get ; set ; }
2017-10-15 17:03:07 +02:00
/// <summary>
2025-11-22 02:16:10 +01:00
/// Gets or sets the subtitle for the notification, which will be displayed below the title.
2017-10-15 17:03:07 +02:00
/// </summary>
2025-11-22 02:16:10 +01:00
[SupportedOSPlatform("macos")]
[JsonPropertyName("subtitle")]
public string Subtitle { get ; set ; }
2017-10-15 17:03:07 +02:00
/// <summary>
2025-11-22 02:16:10 +01:00
/// Gets or sets the body text of the notification, which will be displayed below the title or subtitle.
2017-10-15 17:03:07 +02:00
/// </summary>
2020-05-21 01:32:38 +02:00
public string Body { get ; set ; }
2017-10-15 17:03:07 +02:00
/// <summary>
2025-11-22 02:16:10 +01:00
/// Gets or sets a value indicating whether to suppress the OS notification noise when showing the notification.
2017-10-15 17:03:07 +02:00
/// </summary>
public bool Silent { get ; set ; }
/// <summary>
2025-11-22 02:16:10 +01:00
/// Gets or sets an icon to use in the notification. Can be a string path or a NativeImage. If a string is passed, it must be a valid path to a local icon file.
2017-10-15 17:03:07 +02:00
/// </summary>
public string Icon { get ; set ; }
/// <summary>
2025-11-22 02:16:10 +01:00
/// Gets or sets a value indicating whether to add an inline reply option to the notification.
2017-10-15 17:03:07 +02:00
/// </summary>
2025-11-22 02:16:10 +01:00
[SupportedOSPlatform("macos")]
2017-10-15 17:03:07 +02:00
public bool HasReply { get ; set ; }
2020-05-21 01:32:38 +02:00
/// <summary>
2025-11-22 02:16:10 +01:00
/// Gets or sets the timeout duration of the notification. Can be 'default' or 'never'.
2020-05-21 01:32:38 +02:00
/// </summary>
2025-11-22 02:16:10 +01:00
[SupportedOSPlatform("linux")]
[SupportedOSPlatform("windows")]
2020-05-21 01:32:38 +02:00
public string TimeoutType { get ; set ; }
2017-10-15 17:03:07 +02:00
/// <summary>
2025-11-22 02:16:10 +01:00
/// Gets or sets the placeholder to write in the inline reply input field.
2017-10-15 17:03:07 +02:00
/// </summary>
2025-11-22 02:16:10 +01:00
[SupportedOSPlatform("macos")]
2017-10-15 17:03:07 +02:00
public string ReplyPlaceholder { get ; set ; }
/// <summary>
2025-11-22 02:16:10 +01:00
/// Gets or sets the name of the sound file to play when the notification is shown.
2017-10-15 17:03:07 +02:00
/// </summary>
2025-11-22 02:16:10 +01:00
[SupportedOSPlatform("macos")]
2017-10-15 17:03:07 +02:00
public string Sound { get ; set ; }
2020-05-21 01:32:38 +02:00
/// <summary>
2025-11-22 02:16:10 +01:00
/// Gets or sets the urgency level of the notification. Can be 'normal', 'critical', or 'low'.
2020-05-21 01:32:38 +02:00
/// </summary>
2025-11-22 02:16:10 +01:00
[SupportedOSPlatform("linux")]
2020-05-21 01:32:38 +02:00
public string Urgency { get ; set ; }
2017-10-18 03:49:34 +02:00
/// <summary>
2025-11-22 02:16:10 +01:00
/// Gets or sets the actions to add to the notification. Please read the available actions and limitations in the NotificationAction documentation.
2017-10-18 03:49:34 +02:00
/// </summary>
2025-11-22 02:16:10 +01:00
[SupportedOSPlatform("macos")]
public NotificationAction [ ] Actions { get ; set ; }
2017-10-18 03:49:34 +02:00
/// <summary>
2025-11-22 02:16:10 +01:00
/// Gets or sets a custom title for the close button of an alert. An empty string will cause the default localized text to be used.
2020-05-21 01:32:38 +02:00
/// </summary>
2025-11-22 02:16:10 +01:00
[SupportedOSPlatform("macos")]
2020-05-21 01:32:38 +02:00
public string CloseButtonText { get ; set ; }
2025-11-22 02:16:10 +01:00
/// <summary>
/// Gets or sets a custom description of the Notification on Windows superseding all properties above. Provides full customization of design and behavior of the notification.
/// </summary>
[SupportedOSPlatform("windows")]
public string ToastXml { get ; set ; }
2020-05-21 01:32:38 +02:00
/// <summary>
/// Emitted when the notification is shown to the user, note this could be fired
/// multiple times as a notification can be shown multiple times through the Show()
/// method.
2017-10-18 03:49:34 +02:00
/// </summary>
[JsonIgnore]
public Action OnShow { get ; set ; }
2017-10-24 21:43:27 +02:00
/// <summary>
/// Gets or sets the show identifier.
/// </summary>
/// <value>
/// The show identifier.
/// </value>
2025-11-09 14:00:30 +01:00
[JsonInclude]
2017-10-18 03:49:34 +02:00
internal string ShowID { get ; set ; }
/// <summary>
/// Emitted when the notification is clicked by the user.
/// </summary>
[JsonIgnore]
public Action OnClick { get ; set ; }
2017-10-24 21:43:27 +02:00
/// <summary>
/// Gets or sets the click identifier.
/// </summary>
/// <value>
/// The click identifier.
/// </value>
2025-11-09 14:00:30 +01:00
[JsonInclude]
2017-10-18 03:49:34 +02:00
internal string ClickID { get ; set ; }
/// <summary>
/// Emitted when the notification is closed by manual intervention from the user.
///
/// This event is not guarunteed to be emitted in all cases where the notification is closed.
/// </summary>
[JsonIgnore]
public Action OnClose { get ; set ; }
2017-10-24 21:43:27 +02:00
/// <summary>
/// Gets or sets the close identifier.
/// </summary>
/// <value>
/// The close identifier.
/// </value>
2025-11-09 14:00:30 +01:00
[JsonInclude]
2017-10-18 03:49:34 +02:00
internal string CloseID { get ; set ; }
/// <summary>
/// macOS only: Emitted when the user clicks the “Reply” button on a notification with hasReply: true.
///
/// The string the user entered into the inline reply field
/// </summary>
[JsonIgnore]
2025-11-22 02:16:10 +01:00
[SupportedOSPlatform("macos")]
2017-10-18 03:49:34 +02:00
public Action < string > OnReply { get ; set ; }
2017-10-24 21:43:27 +02:00
/// <summary>
/// Gets or sets the reply identifier.
/// </summary>
/// <value>
/// The reply identifier.
/// </value>
2025-11-09 14:00:30 +01:00
[JsonInclude]
2017-10-18 03:49:34 +02:00
internal string ReplyID { get ; set ; }
/// <summary>
2025-11-22 02:16:10 +01:00
/// macOS only - The index of the action that was activated.
2017-10-18 03:49:34 +02:00
/// </summary>
[JsonIgnore]
2025-11-22 02:16:10 +01:00
[SupportedOSPlatform("macos")]
public Action < int > OnAction { get ; set ; }
2017-10-18 03:49:34 +02:00
2017-10-24 21:43:27 +02:00
/// <summary>
/// Gets or sets the action identifier.
/// </summary>
/// <value>
/// The action identifier.
/// </value>
2025-11-09 14:00:30 +01:00
[JsonInclude]
2017-10-18 03:49:34 +02:00
internal string ActionID { get ; set ; }
2025-11-22 02:16:10 +01:00
/// <summary>
/// Windows only: Emitted when an error is encountered while creating and showing the native notification.
/// Corresponds to the 'failed' event on Notification.
/// </summary>
[JsonIgnore]
[SupportedOSPlatform("windows")]
public Action < string > OnFailed { get ; set ; }
2017-10-24 21:43:27 +02:00
/// <summary>
/// Initializes a new instance of the <see cref="NotificationOptions"/> class.
/// </summary>
/// <param name="title">The title.</param>
/// <param name="body">The body.</param>
2017-10-15 17:03:07 +02:00
public NotificationOptions ( string title , string body )
{
Title = title ;
Body = body ;
}
2017-10-03 04:40:37 +02:00
}
2025-11-22 02:16:10 +01:00
}