### Class

# Gio Notification

since: 2.40

#### Description [src]

    final class Gio.Notification : GObject.Object
    {
      /* No available fields */
    }

`GNotification` is a mechanism for creating a notification to be shown to the user — typically as a pop-up notification presented by the desktop environment shell.

The key difference between `GNotification` and other similar APIs is that, if supported by the desktop environment, notifications sent with `GNotification` will persist after the application has exited, and even across system reboots.

Since the user may click on a notification while the application is not running, applications using `GNotification` should be able to be started as a D-Bus service, using `GApplication`.

In order for `GNotification` to work, the application must have installed a `.desktop` file. For example:

    [Desktop Entry]
    Name=Test Application
    Comment=Description of what Test Application does
    Exec=gnome-test-application
    Icon=org.gnome.TestApplication
    Terminal=false
    Type=Application
    Categories=GNOME;GTK;TestApplication Category;
    StartupNotify=true
    DBusActivatable=true
    X-GNOME-UsesNotifications=true

The `X-GNOME-UsesNotifications` key indicates to GNOME Control Center that this application uses notifications, so it can be listed in the Control Center’s ‘Notifications’ panel.

The `.desktop` file must be named as `org.gnome.TestApplication.desktop`, where `org.gnome.TestApplication` is the ID passed to `g_application_new()`.

User interaction with a notification (either the default action, or buttons) must be associated with actions on the application (ie: `app.` actions). It is not possible to route user interaction through the notification itself, because the object will not exist if the application is autostarted as a result of a notification being clicked.

A notification can be sent with `g_application_send_notification()`.

Available since: 2.40

#### Ancestors

- GObject

#### Constructors

###### g_notification_new

Creates a new `GNotification` with `title` as its title.

since: 2.40

#### Instance methods

###### g_notification_add_button

Adds a button to `notification` that activates the action in `detailed_action` when clicked. That action must be an application-wide action (starting with “app.”). If `detailed_action` contains a target, the action will be activated with that target as its parameter.

since: 2.40

###### g_notification_add_button_with_target

Adds a button to `notification` that activates `action` when clicked. `action` must be an application-wide action (it must start with “app.”).

since: 2.40

###### g_notification_add_button_with_target_value

Adds a button to `notification` that activates `action` when clicked. `action` must be an application-wide action (it must start with “app.”).

since: 2.40

###### g_notification_set_body

Sets the body of `notification` to `body`.

since: 2.40

###### g_notification_set_category

Sets the type of `notification` to `category`. Categories have a main type like `email`, `im` or `device` and can have a detail separated by a `.`, e.g. `im.received` or `email.arrived`. Setting the category helps the notification server to select proper feedback to the user.

since: 2.70

###### g_notification_set_default_action

Sets the default action of `notification` to `detailed_action`. This action is activated when the notification is clicked on.

since: 2.40

###### g_notification_set_default_action_and_target

Sets the default action of `notification` to `action`. This action is activated when the notification is clicked on. It must be an application-wide action (it must start with “app.”).

since: 2.40

###### g_notification_set_default_action_and_target_value

Sets the default action of `notification` to `action`. This action is activated when the notification is clicked on. It must be an application-wide action (start with “app.”).

since: 2.40

###### g_notification_set_icon

Sets the icon of `notification` to `icon`.

since: 2.40

###### g_notification_set_priority

Sets the priority of `notification` to `priority`. See `GNotificationPriority` for possible values.

###### g_notification_set_title

Sets the title of `notification` to `title`.

since: 2.40

###### g_notification_set_urgent

Deprecated in favor of g_notification_set_priority().

deprecated: 2.42 since: 2.40

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Signals

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.