Skip to content
Petar edited this page Jun 5, 2014 · 4 revisions

DEA.notifications

Usage

To use this API, call the notifications.create method, passing in the notification details via the options parameter:

DEA.notifications.create(options, callback); 

All template types (basic, image, and video) must include a notification title and message, as well as an iconUrl, which is a link to a small icon that is displayed to the left of the notification message. The image template type also includes an imageUrl, which is a link to an image that is previewed within the notification. These URLs can point to a local resource or use a absolute URL.

Here's an example of a text template:

var options = {
    type: "text",
    title: "Primary Title",
    message: "Primary message to display",
    iconUrl: "url_to_small_icon",
    buttonPrimary: "Yes"
}

The image template displays an image with an imageTitle in addition to a title and a description:

var options = {
    type: "image",
    title: "Primary Title",
    message: "Primary message to display",
    iconUrl: "url_to_small_icon",
    imageUrl: "url_to_image",
    imageTitle: "image title",
    buttonPrimary: "Yes",
    buttonSecondary: "No",
}

Listening for and responding to events

All notifications can include event listeners and event handlers that respond to user actions. For example, you can write an event handler to respond to an notifications.onButtonClicked event.

Notification Options (Template)

type name description
string (required) type Which type of notification to display
string (optional) iconUrl Sender's avatar, app icon, or thumbnail image for notifications
string (optional) title Title of the notification
string (optional) message Main notification content
string (optional) imageUrl Image thumbnail for image-type notifications
string (optional) imageTitle Image title for image-type notifications
string (optional) buttonPrimary Title for primary action button
string (optional) buttonSecondary Title for secondary action button

Summary

Methods

  • create − DEA.notifications.create(object options, function callback)
  • clear- DEA.notifications.clear(function callback)

Events

Events are available as target in the DEA.notifications.create callback when a user interacts with the notification.

Possible targets

type name description
string closer Clicked on the X
string title Clicked on the title of the notification
string description Clicked on the notification description
string icons Clicked on the notification icon in the upper left hand side
string gallery-image Clicked on the gallery image for image type notification
string gallery-image title Clicked on the gallery image title for image type notification
string button primary Clicked on the primary action button
string button secondary Clicked on the secondary action button

Example: Listening to events in the DEA.notifications.create callback

window.DEA.notifications.create(options, function(target) {

    // Possible Events
    switch (target) {
        case 'closer':
            break;
        case 'title':
            break;
        case 'description':
            break;
        case 'icons':
            break;
        case 'gallery-image':
            break;
        case 'gallery-image title':
            break;
        case 'button primary':
            break;
        case 'button secondary':
            break;
        default:
            break;
    }
});