Notification

Since: BlackBerry 10.0.0

#include <bb/platform/Notification>

To link against this class, add the following line to your .pro file: LIBS += -lbbplatform

A notification message that will trigger effects such as vibration, LED flashing, playing a sound, adding an entry to the Universal Inbox, instant preview, and so on.

The effects are dependent on the notification settings of the application. You can use NotificationApplicationSettings to set your app's notification behavior, including preview behavior. Instant previews are disabled for your app by default, unless the app has an account in the BlackBerry Hub.


Overview

Public Functions Index

Notification (QObject *parent=0)
Notification (const QString &key, QObject *parent=0)
virtual ~Notification ()
QStringbody () const
bb::platform::NotificationError::Typeerror () const
QUrliconUrl () const
bb::system::InvokeRequestinvokeRequest () const
QStringkey () const
voidresetBody ()
voidresetIconUrl ()
voidresetInvokeRequest ()
voidresetSoundUrl ()
Q_INVOKABLE voidresetTimestamp ()
voidresetTitle ()
voidresetType ()
voidsetBody (const QString &body)
voidsetIconUrl (const QUrl &newIconUrl)
voidsetInvokeRequest (const bb::system::InvokeRequest &newInvokeRequest)
voidsetSoundUrl (const QUrl &newSoundUrl)
voidsetTimestamp (const QDateTime &newTimestamp)
Q_INVOKABLE voidsetTimestamp (qint64 millisecondsTimestamp)
voidsetTitle (const QString &title)
voidsetType (bb::platform::NotificationType::Type type)
QUrlsoundUrl () const
QDateTimetimestamp () const
QStringtitle () const
bb::platform::NotificationType::Typetype () const

Signals Index

voidbodyChanged (const QString &value)
voidiconUrlChanged (const QUrl &newIconUrl)
voidinvokeRequestChanged (const bb::system::InvokeRequest &newInvokeRequest)
voidsoundUrlChanged (const QUrl &newSoundUrl)
voidtimestampChanged (const QDateTime &newTimestamp)
voidtitleChanged (const QString &value)
voidtypeChanged (bb::platform::NotificationType::Type &type)

Properties

QString body

Represents the main text of the notification.

Since:

BlackBerry 10.0.0

bb::platform::NotificationError::Type error[read-only]

Represents the error, if any, encountered during the last operation.

Since:

BlackBerry 10.0.0

QUrl iconUrl

Represents the location of the icon to be shown in the preview for this item.

When the notification setting allows instant previews, this property specifies the path to the icon to be shown for the preview of this item. You must specify the iconUrl as a file URI to a public asset or a shared asset on the device. You can set a local asset to be a public asset in the Assets tab of the bar-descriptor.xml file of your project.

Permissions:

You must set the access_shared permission for your app to access shared files.

Since:

BlackBerry 10.2.0

QString key[read-only]

Represents the unique identifier of this notification.

The key can be used to clear the effects of notifications after this notification instance has been destroyed.

Note that notification effects span beyond the application's lifecycle and as such, the key can be persisted in order to cancel notifications that were created in a previous application instance.

Since:

BlackBerry 10.0.0

QUrl soundUrl

Represents the location of the sound to be used when the notification is posted.

You must specify the soundUrl as a file URI to a public asset or a shared asset on the device. You can set a local asset to be a public asset in the Assets tab of the bar-descriptor.xml file of your project.

Permissions:

You must set the access_shared permission for your app to access shared files.

When the notification setting allows for sounds to be played, this property overrides the user preference for which sound to play.
Since:

BlackBerry 10.0.0

QDateTime timestamp

Represents the time at which the event triggering the notification occurred.

If the timestamp is invalid, then the time of the request is used, i.e., when notify() is called.

Since:

BlackBerry 10.0.0

QString title

Represents the title of the notification.

The notification settings determine whether and where the title is shown.

Since:

BlackBerry 10.0.0

bb::platform::NotificationType::Type type

Represents how a notification will be shown.

Allows a notification to be restricted in the way it may be shown and how the user will be alerted.

Since:

BlackBerry 10.2.0

Public Functions

Notification (

Constructs a new instance of a notification.

Parameters
parent

If not 0, the supplied parent will be responsible for deleting this instance.

Since:

BlackBerry 10.0.0

Notification (

Constructs a new instance of a notification.

Parameters
key

The key to associate with this instance. Note that supplying a non-unique key results in undefined results.

parent

If not 0, the supplied parent will be responsible for deleting this instance.

Since:

BlackBerry 10.0.0

virtual~Notification ()

Destructor.

Since:

BlackBerry 10.0.0

QString body ()

Retrieves the text associated with this notification.

Return:

The text of the notification.

Since:

BlackBerry 10.0.0

bb::platform::NotificationError::Type error ()

Retrieves the error that occurred during the request.

The return value will be reset when a new request is made.

Return:

The error that occurred.

Since:

BlackBerry 10.0.0

QUrl iconUrl ()

Retrieves the icon for previews associated with this notification.

If empty, no icon will be shown on previews.

Return:

The icon URL of the notification.

Since:

BlackBerry 10.2.0

bb::system::InvokeRequest invokeRequest ()

Retrieves a copy of the invoke request associated with this notification.

Return:

The invoke request of the notification.

Since:

BlackBerry 10.0.0

QString key ()

Retrieves the unique identifier associated with this notification.

Return:

The notification's identifier.

Since:

BlackBerry 10.0.0

void resetBody ()

Resets the body for the notification.

This resets the body property to its context-specific default value. The default is QString::null.

Since:

BlackBerry 10.0.0

void resetIconUrl ()

Resets the icon for the preview of this notification.

When reset, no icon will be shown.

Since:

BlackBerry 10.2.0

void resetInvokeRequest ()

Resets the invoke request for the notification.

This resets the invokeRequest property to its context-specific default value. The default is a default-constructed bb::system::InvokeRequest instance.

Since:

BlackBerry 10.0.0

void resetSoundUrl ()

Resets the sound for the notification.

When reset, the user setting will be used.

Since:

BlackBerry 10.0.0

Q_INVOKABLE void resetTimestamp ()

Resets the timestamp for the notification.

This resets the timestamp property to its context-specific default value. The default is a null QDateTime.

Since:

BlackBerry 10.0.0

void resetTitle ()

Resets the title for the notification.

This resets the title property to its context-specific default value. The default is QString::null.

Since:

BlackBerry 10.0.0

void resetType ()

Resets the type of this notification to default.

Resets the type of this notification to fully enable all user settings

Since:

BlackBerry 10.2.0

void setBody (

Sets the text of the notification.

Parameters
body

The body for the notification.

Since:

BlackBerry 10.0.0

void setIconUrl (
  • const QUrl &newIconUrl)

Sets the icon for previews associated with this notification.

If no icon is set then no icon will be shown for previews. You must specify the iconUrl as a file URI to a public asset or a shared asset on the device. You can set a local asset to be a public asset in the Assets tab of the bar-descriptor.xml file of your project.

Permissions:

You must set the access_shared permission for your app to access shared files.

Parameters
newIconUrl

The URL for the icon for this notification.

Since:

BlackBerry 10.2.0

void setInvokeRequest (

Sets the invoke request of the notification.

Parameters
newInvokeRequest

The invoke request for the notification.

Since:

BlackBerry 10.0.0

void setSoundUrl (
  • const QUrl &newSoundUrl)

Sets the sound of the notification.

You must specify the soundUrl as a file URI to a public asset or a shared asset on the device. You can set a local asset to be a public asset in the Assets tab of the bar-descriptor.xml file of your project.

Permissions:

You must set the access_shared permission for your app to access shared files.

Parameters
newSoundUrl

The URL for the sound for this notification.

Since:

BlackBerry 10.0.0

void setTimestamp (

Sets the timestamp of the notification.

The notification will be triggered when notify is invoked. The timestamp is the time of the event associated with the notification.

Parameters
newTimestamp

The time to associate with the notification.

Since:

BlackBerry 10.0.0

Q_INVOKABLE void setTimestamp (
  • qint64millisecondsTimestamp)

Sets the timestamp of the notification.

The notification will be triggered when notify is invoked. The timestamp is the time of the event associated with the notification.

Parameters
millisecondsTimestamp

The time in milliseconds since the epoch to associate with the notification.

Since:

BlackBerry 10.0.0

void setTitle (

Sets the title of the notification.

Parameters
title

The title for the notification.

Since:

BlackBerry 10.0.0

void setType (

Sets the type of this notification.

Parameters
type

The type of the notification.

Since:

BlackBerry 10.2.0

QUrl soundUrl ()

Retrieves the sound associated with this notification.

If empty, the user setting will be used.

Return:

The sound URL of the notification.

Since:

BlackBerry 10.0.0

QDateTime timestamp ()

Retrieves the timestamp associated with this notification.

Return:

The time of the notification.

Since:

BlackBerry 10.0.0

QString title ()

Retrieves the title associated with this notification.

Return:

The title of the notification.

Since:

BlackBerry 10.0.0

bb::platform::NotificationType::Type type ()

Retrieves the type of this notification.

Return:

The type of the notification.

Since:

BlackBerry 10.2.0

Public Slots

bb::platform::NotificationError::Type clearEffects ()

Clears effects for this notification but keeps it in the notification (universal) inbox.

Return:

The result of this request.

Since:

BlackBerry 10.0.0

bb::platform::NotificationError::Type clearEffects (

Clears effects for the specified notification but keeps it in the notification (universal) inbox.

The key of notification can be obtained through key().

Parameters
key

The unique identifier for the notification for which all effects should be cleared.

Return:

The result of this request.

Since:

BlackBerry 10.0.0

bb::platform::NotificationError::Type clearEffectsForAll ()

Clears effects for all notifications posted by the application.

Return:

The result of this request.

Since:

BlackBerry 10.0.0

bb::platform::NotificationError::Type deleteAllFromInbox ()

Deletes all notifications from the notification inbox for this application.

Return:

The result of this request.

Since:

BlackBerry 10.0.0

bb::platform::NotificationError::Type deleteFromInbox ()

Deletes the notification from the notification inbox.

Return:

The result of this request.

Since:

BlackBerry 10.0.0

bb::platform::NotificationError::Type deleteFromInbox (

Deletes the specified notification from the notification inbox.

The key of notification can be obtained through key().

Parameters
key

The unique identifier for the notification to delete from the notification inbox.

Return:

The result of this request.

Since:

BlackBerry 10.0.0

bb::platform::NotificationError::Type notify ()

Posts the notification.

The result of this operation can be retrieved through error().

Return:

The result of this request.

Since:

BlackBerry 10.0.0

Signals

void bodyChanged (

Emitted when the body property changes programmatically.

Parameters
value

The new value for the body property.

Since:

BlackBerry 10.0.0

void iconUrlChanged (
  • const QUrl &newIconUrl)

Emitted when the iconUrl property changes programmatically.

Parameters
newIconUrl

The new value for the iconUrl property.

Since:

BlackBerry 10.2.0

void invokeRequestChanged (

Emitted when the invokeRequest property changes programmatically.

Parameters
newInvokeRequest

The new value for the invokeRequest property.

Since:

BlackBerry 10.0.0

void soundUrlChanged (
  • const QUrl &newSoundUrl)

Emitted when the soundUrl property changes programmatically.

Parameters
newSoundUrl

The new value for the soundUrl property.

Since:

BlackBerry 10.0.0

void timestampChanged (

Emitted when the timestamp property changes programmatically.

Parameters
newTimestamp

The new value for the timestamp property.

Since:

BlackBerry 10.0.0

void titleChanged (

Emitted when the title property changes programmatically.

Parameters
value

The new value for the title property.

Since:

BlackBerry 10.0.0

void typeChanged (

Emitted when the type property changes programmatically.

Parameters
type

The new value for the type property.

Since:

BlackBerry 10.2.0

Last modified: 2014-09-29



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus