Skip to main content

buildfire.notifications

Provides a way to notify user using device native features such as beep and vibrate.

note

If you are looking for push or local notifications check out:

Methods

beep()

buildfire.notifications.beep(options, callback)

Reproduces beep sound on device

buildfire.notifications.beep({ times: 3 }, () => {
console.log("Done beeping");
});

options

NameTypeRequiredDescriptionDefault
timesnumbernoThe number of times to repeat the beep.1

callback()

Callback function after beeping is done


vibrate()

buildfire.notifications.vibrate(options, callback)

Vibrates the device

buildfire.notifications.vibrate({ milliseconds: 3000 }, () => {
console.log("Done vibrating");
});

options

NameTypeRequiredDescriptionDefault
millisecondsnumbernoThe number of milliseconds to vibrate. iOS only supports 1000 Milliseconds1000

callback()

Callback function after vibration is done


prompt()

buildfire.notifications.prompt(options, callback)

Prompts the user for input

buildfire.notifications.prompt({ title: "Hi. Whats your name?" }, (result) => {
console.log("Hello ", result);
});

options

NameTypeRequiredDescriptionDefault
titlestringyesPrompt title
messagestringnoPrompt message
buttonLabels[string]noArray of strings specifying button labels["OK","Cancel"]
defaultTextstringnoDefault textbox input value

callback(value)

Callback function the value given by user

NameTypeDescription
valuestringUsers input

alert() - deprecated

buildfire.notifications.alert(options, callback)

danger

This method is deprecated. Please use Dialog Alert instead.

The alert method displays an alert popup with a specified message and an OK button. An alert popup is often used if you want to make sure information comes through to the user.

buildfire.notifications.alert(
{
title: "Access Deined",
message: "You don't have the permission to access this section!",
okButton: { text: "Ok" },
},
(err, data) => {
if (err) return console.error(err);

console.log(data.selectedButton);
}
);

options

NameTypeRequiredDescriptionDefault
titlestringnoDialog title."Alert"
messagestringyesMessage to be displayed inside of the dialog
sizestringnoSize of the dialog. Can be "sm" "md" or "lg""sm"
okButtonobjectnoModifies the ok button

options.okButton

NameTypeRequiredDescriptionDefault
textstringnoButton text."Ok"
keystringnoButton key. To be used in the callback to know what button user clicked"ok"
typestringnoDetermines button style. Can be "default", "primary", "success", "info", "warning", "danger""primary"

callback(err, data)

Callback function after the end user clicked on button. Data contains the selected button object

NameTypeDescription
errstringerror string, null when operation is successful
dataobjectContains selectedButton object ex {selectedButton:{text:"Ok", key:'ok'}}

confirm() - deprecated

buildfire.notifications.confirm(options, callback)

danger

This method is deprecated. Please use Dialog Confirm instead.

The confirm method displays a confirm popup with a specified message, along with an OK and a Cancel button. A confirm popup is often used if you want the user to verify or accept something.

buildfire.notifications.confirm(
{
title: "Are you sure?",
message: "Are you sure to delete this record?",
confirmButton: { text: "Yes", key: "yes", type: "danger" },
cancelButton: { text: "No", key: "no", type: "default" },
},
(err, data) => {
if (err) return console.error(err);

console.log(data.selectedButton);
}
);

options

NameTypeRequiredDescriptionDefault
titlestringnoDialog title."Alert"
messagestringyesMessage to be displayed inside of the dialog
sizestringnoSize of the dialog. Can be "sm" "md" or "lg""sm"
confirmButtonobjectnoModifies the ok button
cancelButtonobjectnoModifies the ok button

options.confirmButton

NameTypeRequiredDescriptionDefault
textstringnoButton text."Confirm"
keystringnoButton key. To be used in the callback to know what button user clicked"confirm"
typestringnoDetermines button style. Can be "default", "primary", "success", "info", "warning", "danger""primary"

options.cancelButton

NameTypeRequiredDescriptionDefault
textstringnoButton text."Cancel"
keystringnoButton key. To be used in the callback to know what button user clicked"cancel"
typestringnoDetermines button style. Can be "default", "primary", "success", "info", "warning", "danger""default"

callback(err, data)

Callback function after the end user clicked on button. Data contains the selected button object

NameTypeDescription
errstringerror string, null when operation is successful
dataobjectContains selectedButton object ex {selectedButton:{text:"Confirm", key:'confirm'}}

showDialog() - deprecated

buildfire.notifications.showDialog(options, callback)

danger

This method is deprecated. Please use Dialog Show instead.

The showDialog method displays a popup with a specified title and message. A showDialog popup is used if you want to build a popup with generic buttons.

buildfire.notifications.showDialog(
{
title: "options available",
message: "Please select the t-shirt size",
buttons: [
{ text: "Small", key: "small", type: "default" },
{ text: "Medium", key: "medium", type: "default" },
{ text: "Large", key: "large", type: "default" },
],
},
(err, data) => {
if (err) return console.error(err);

console.log(data.selectedButton);
}
);

options

NameTypeRequiredDescriptionDefault
titlestringyesDialog title.
messagestringnoMessage to be displayed inside of the dialog
sizestringnoSize of the dialog. Can be "sm" "md" or "lg""sm"
buttons[object]noArray of buttons to be shown in modal

options.buttons[]

NameTypeRequiredDescriptionDefault
textstringyesButton text.
keystringyesButton key. To be used in the callback to know what button user clicked
typestringnoDetermines button style. Can be "default", "primary", "success", "info", "warning", "danger""default"

callback(err, data)

Callback function after the end user clicked on button. Data contains the selected button object

NameTypeDescription
errstringerror string, null when operation is successful
dataobjectContains selectedButton object ex {selectedButton:{text:"Small", key:'small'}}