Node v6
Starting with v0.19 Astro must be used with Node v6+!
Menu

Alert View Plugin

The alert view plugin allows you to create a simple one or two button modal that blocks input to the rest of the screen. Alert views are useful when you want to display a popup to the user with an Ok and/or Cancel button.

It is possible to create an alert using a static method or by creating and configuring an instance. The following snippet shows how to create an alert view with the static method

const okButtonPressed = await AlertViewPlugin.alert({
    title: 'Static Alert',
    text: 'This is the static alert text',
    okButton: true,
    cancelButton: 'Custom Cancel'
})
if (okButtonPressed) {
    //Do something
}

The following snippet shows how to create an AlertViewPlugin instance, customize it, and finally show it.

const alertView = await AlertViewPlugin.init()
await alertView.setTitle('Alert with cancel button')
await alertView.setText('Should I do some function?')
await alertView.addOkButton("Yes")
await alertView.addCancelButton()
const okButtonPressed = await alertView.show()
if (okButtonPressed) {
    // do something
}

A button must be added to the alert view, otherwise the app will crash. Calling the same method multiple times will overwrite the previous call.

Alert view with single Ok button

IOS Android

Alert view with Ok and Cancel buttons

IOS Android

Static Methods

AlertViewPlugin.alert(config) #

Create and show an alert view immediately. The alert view is configured with a config object.

{
    title: "Title",
    text: "Alert view text",
    okButton: true|"Custom Ok button text",
    cancelButton: true|"Custom Cancel button text"
}

If true is passed as value for either button property, the default button text is used.

This returns a promise which resolves to true if the Ok button (regardless of its label) was pressed to dismiss the alert.

Methods

AlertViewPlugin.init() #

Creates and returns an instance of the alert view plugin that is used to make subsequent method calls. The same alert view plugin can be presented multiple times without having to re-configure it.


setTitle(title) #

Sets title of alert view.


setText(text) #

Sets the message body of alert view


addOkButton(label) #

Enables and optionally sets label of Ok button.


addCancelButton(label) #

Enables and optionally sets label of Cancel button.


show() #

Presents the alert view on top of the current view. This blocks the rest of the input to the UI until either the Cancel or Ok button is pressed.

This returns a promise which resolves to true if the Ok button (regardless of its label) was pressed to dismiss the alert.