Notifications

Notification dizmos may be used to, for example, greet a user or notify them of a new e-mail in their inbox.

The default positioning of a notification

Use the viewer.notify(opts) function to make a notification dizmo appear. By default, the notification appears along the right edge starting from the top. It automatically chooses a free slot to position the next notification dizmo.

Notification dizmo options

The opts parameter contains the options the dizmo will be instantiated with. All parameters below except for title are optional:

Simple example

    viewer.notify({title:"Good morning!"});

Full example

    viewer.notify({
        button_1: 'Close',
        button_2: 'Reply',
        title: 'My Contact',
        sub_title: 'RE: Last Email',
        text: 'Oh, this is brilliant—how soon can we get this working?',
     // important: true,

        callback: function (message) {

            switch (message) {
                case 'click':
                    console.debug('from', this.identifier, '=>', 'click');
                    break;
                case 'timeout':
                    console.debug('from', this.identifier, '=>', 'timeout');
                    break;
                case 'reply':
                    console.debug('from', this.identifier, '=>', 'reply');
                    break;
                case 'close':
                    console.debug('from', this.identifier, '=>', 'close');
                    this.publicStorage.setProperty('close', true);
                    break;
                default:
                    console.debug('from', this.identifier, '=>', message);
            }
        },

        timeout: 5000 // or: null
    });

Custom image

By default, Icon.svg in the assets Folder of the notifying dizmo is used as the image for the notification. If you want to use your own, copy it into the assets Folder of your dizmo, and then add the icon option:

    viewer.notify({title:"Threshold reached","icon":"assets/warning-triangle.svg"});