Sailfish OS
  • Info
  • User Experience
  • Cases
  • Community
  • Developers
  • Contact
  • Get Sailfish OS
Select Page

API Documentation

Documentation for developing SailfishOS applications
  • API Documentation
  • Libsailfishapp
  • Sailfish Silica
    • Documentation
    • Icon Reference
  • Sailfish Components
    • Sailfish Accounts
    • Sailfish Bluetooth
    • Sailfish Contacts
    • Sailfish Crypto
    • Sailfish Gallery
    • Sailfish Media
    • Sailfish Pickers
    • Sailfish Secrets
    • Sailfish Share
    • Sailfish Telephony
    • Sailfish Webview
    • Amber Web Authorization
    • Amber MPRIS
  • Nemo QML Plugins
    • Configuration
    • Contacts
    • D-Bus
    • Keepalive
    • Notifications
    • Thumbnailer
  • Sailfish Middleware
    • MDM Framework
    • MDM Policy Framework
    • User Manager Daemon

Contents

  • Public Functions
  • Detailed Description

NotificationInfo Class

(Sailfish::Mdm::NotificationInfo)

The NotificationInfo class creates user-visible notifications. More...

Header: #include <mdm-notifications.h>
  • List of all members, including inherited members

Public Functions

NotificationInfo(QObject *parent = Q_NULLPTR)
~NotificationInfo()
bool closeNotification(quint32 notificationId)
quint32 createNotification(const Sailfish::Mdm::NotificationData &data)
QList<NotificationData> notifications(const QString &owner = QString())
QList<NotificationData> notificationsByCategory(const QString &category)
quint32 updateNotification(quint32 notificationId, const Sailfish::Mdm::NotificationData &data)

Detailed Description

The NotificationInfo class creates user-visible notifications.

It can be used to retrieve, update or close existing notifications, and to publish new notifications.

For more in-depth information about notifications in Sailfish OS, please see the documentation for the nemo-qml-plugin-notifications library.

To use this class, clients must add the following to their qmake project:

 CONFIG += link_pkgconfig
 PKGCONFIG += sailfishmdm

and then #include <mdm-notifications.h>.

Example of usage:

 #include <mdm-notifications.h>
 void publishNotification(QObject *parent)
 {
     QVariantMap defaultAction;
     defaultAction.insert("name", "default");
     defaultAction.insert("displayName", "Do It!");
     defaultAction.insert("icon", "icon-s-do-it");
     defaultAction.insert("service", "org.sailfishos.example");
     defaultAction.insert("path", "/example");
     defaultAction.insert("iface", "org.sailfishos.example");
     defaultAction.insert("method", "doIt");
     defaultAction.insert("arguments", QVariantList() << "argument" << 2);

     QVariantList remoteActions;
     remoteActions << defaultAction;

     Sailfish::Mdm::NotificationData data;
     data.itemCount = 5;
     data.category = "x-nemo.example";
     data.appName = "Example App";
     data.appIcon = "/usr/share/example-app/icon-l-application";
     data.summary = "Notification summary";
     data.body = "This is the body of an example notification";
     data.previewSummary = "Notification preview summary";
     data.previewBody = "This is the preview body";
     data.timestamp = QDateTime::currentDateTime();
     data.remoteActions = remoteActions;

     Sailfish::Mdm::NotificationInfo *info = new Sailfish::Mdm::NotificationInfo(parent);
     quint32 id = info->createNotification(data);
     info->deleteLater();
     qInfo() << "Created notification with id:" << id;
 }

Member Function Documentation

NotificationInfo::NotificationInfo(QObject *parent = Q_NULLPTR)

Creates a NotificationInfo with the given parent.

NotificationInfo::~NotificationInfo()

Destroys a NotificationInfo.

bool NotificationInfo::closeNotification(quint32 notificationId)

Closes the notification with the given notificationId.

Returns true if the notification exists and was closed.

quint32 NotificationInfo::createNotification(const Sailfish::Mdm::NotificationData &data)

Creates a new notification with the given data.

Returns the new notification's id on success, or zero on failure.

QList<NotificationData> NotificationInfo::notifications(const QString &owner = QString())

Returns data for all notifications from the specified owner.

The owner is the name of the application which created the notification. Currently, this defaults to the value returned by QCoreApplication::applicationName() but can be overridden by the application.

If the owner is empty, this method will return notifications created via the MDM API.

QList<NotificationData> NotificationInfo::notificationsByCategory(const QString &category)

Returns data for all notifications in the specified category.

quint32 NotificationInfo::updateNotification(quint32 notificationId, const Sailfish::Mdm::NotificationData &data)

Updates the notification with the given notificationId according to the updated data.

Returns the updated notification's id on success, or zero on failure.

  • Legal
  • Contact Us
  • Jolla Mobile Ltd © 2025

  • Facebook
  • Twitter
  • Mastodon
  • YouTube
  • LinkedIn