Class: NotificationManager

mmir. NotificationManager

mmir.NotificationManager

Requires

  • module:mmir.MediaManager

Methods

alert(message, alertCallback, title, buttonName)

Opens a (native) alert-notification dialog.
Name Type Description
message String the alert message
alertCallback function optional callback that is triggered, after dialog was closed
title String optional OPTIONAL the title for the alert dialog (may not be provided / settable in all execution environments)
buttonName String optional OPTIONAL the label for the close button in the alert dialog (may not be provided / settable in all execution environments)
Trigger a beep notification sound.
Name Type Description
times Number how many times should to beep repeated

confirm(message, alertCallback, title, buttonLabels)

Opens a (native) confirm-notification dialog.
Name Type Description
message String the confirm message
alertCallback function optional callback that is triggered, after dialog was closed. The callback will be invoked with 1 argument:
callback(wasConfirmed : Boolean)
if the OK/CONFIRM button was pressed, wasConfirmed will be true, otherwise false.
title String optional OPTIONAL the title for the confirm dialog (may not be provided / settable in all execution environments)
buttonLabels Array.<String> optional OPTIONAL the labels for the buttons of the confirm dialog (may not be provided / settable in all execution environments)

createSound(name, url, isKeepOnPause)

Create a sound notification.

After creation, the sound "theSoundId" can be played via playSound("theSoundId", 1)

Name Type Description
name String the name / identifier for the sound
url String the URL for the audio of the sound
isKeepOnPause Boolean optional OPTIONAL flag indicating, if the audio resources should be keept when the device goes into pause mode (may not apply to all execution environments; e.g. relevant for Android environment)
DEFAULT: false
used by framework to initialize the NotificationManager
Initialize a sound notification.

NOTE a sound does not need to be explicitly initialized, playSound will automatically initialize the sound if necessary.

Initializing a sound prepares all resources, so that the sound can be immediately played. For instance, a sound that needs to loaded from a remote server first, may take some time before it can be played.

NOTE the sound must be created first, before initializing it.

Name Type Description
name String the name / identifier for the sound
See:
Check if the execution environment supports vibrate.

If false is returned, calling the vibrate() function will have no effect.

Returns:
Type Description
Boolean true if #vibrate is functional
Check if vibrate is functional and enabled.

If false is returned, calling the vibrate() function will have no effect.

Returns:
Type Description
Boolean true if #vibrate is functional

playSound(name, times)

Trigger a sound notification by NAME (needs to be created first).
Name Type Description
name String the name / identifier for the sound (if null, beep notification is used)
times Number how many times should to beep repeated
See:

setVibrateEnabled(enabled)

Enable or disable vibrate.

NOTE: If {@ #isVibrateAvailable} returns false, enabling will have no effect.

Name Type Description
enabled Boolean set vibrate function to enable
Set the volume for sound notifications.
Name Type Description
vol Number the new volume: a number between [0, 1]
See:
Stop a sound notification, if it is playing. Has no effect, if the notification is not playing.
Name Type Description
name String the name / identifier for the sound

vibrate(milliseconds)

Trigger a haptic vibration feedback.

Note: The device / execution environment may not support haptic vibration feedback

Name Type Description
milliseconds Number duration for vibration in milliseconds. Must be > 0