DedrisFrameworkDedrisFramework

← Plugins  /  Dialogs (Notification)

💬

Dialogs (Notification)

cordova-plugin-dialogs
iOS Android 🌐 Browser

This Apache Cordova plugin gives your app native alert, confirm and prompt dialogs — plus a device beep — that match the look and feel of the platform. Unlike the browser's built-in window.alert and window.confirm, these don't block the WebView and they appear as proper system dialogs, so your app feels at home on the device.

Installation

Add the plugin to your Cordova project from the command line:

terminal
cordova plugin add cordova-plugin-dialogs

Methods

The plugin exposes its functions on the global navigator.notification object. Call them after deviceready has fired:

MethodDescription
navigator.notification.alert(message, callback, [title], [buttonName])Shows a single-button native alert. The callback runs when the dialog is dismissed.
navigator.notification.confirm(message, callback, [title], [buttonLabels])Shows a dialog with multiple buttons. The callback receives the 1-based index of the button that was pressed; 0 means the dialog was dismissed without a choice.
navigator.notification.prompt(message, callback, [title], [buttonLabels], [defaultText])Shows a dialog with a text field. The callback receives a results object of the form {buttonIndex, input1}.
navigator.notification.beep(times)Plays the device's notification beep the given number of times.

Usage example

Ask the user to confirm a destructive action and act on the button they chose:

www/js/app.js
document.addEventListener("deviceready", onReady, false);

function onReady() {
  navigator.notification.confirm(
    "Delete this item?",
    function(i) {
      if (i === 1) {
        removeItem();
      }
    },
    "Confirm",
    ["Delete", "Cancel"]
  );
}

Tips

📚 Source: the technical reference on this page (the methods, their parameters and the install command) is based on the official Apache Cordova dialogs documentation. Descriptions and examples have been rewritten in DedrisFramework's own words. Apache Cordova documentation is published by the Apache Software Foundation under the Apache License 2.0.
← Back to plugins Start a project