The Modals API provides methods for triggering native modal windows for alerts, confirmations and input prompts.
Modals.beep(3); //Beep 3 times
...
Modals.alert({
title: 'Wellcome',
message: 'Hello world',
buttonTitle: 'Hi'
})
.then(() => console.log('Dialog dismissed'))
.catch(e => console.log('Error ', e));
...
Modals.confirm({
title: 'Register',
message: 'Do you want to proceed to registration?',
cancelButtonTitle: 'Cancel',
okButtonTitle: 'Proceed'
})
.then((resp) => {
if(resp == 1){
console.log('Wellcome ');
}else{
console.log('Registration canceled');
}
})
.catch(e => console.log('Error ', e));
...
Modals.prompt({
title: 'Hello',
message: 'What\'s your name?',
cancelButtonTitle: 'Cancel',
okButtonTitle: 'Register',
inputText: ''
})
.then((resp) => {
if(resp.buttonIndex == 1){
console.log('Wellcome ',resp.input1);
}else{
console.log('Canceled');
}
})
.catch(e => console.log('Error ', e));
window.Modals.confirm({
title: "Register",
message: "Do you want to proceed to registration?",
cancelButtonTitle: "Cancel",
okButtonTitle: "Proceed",
})
.then((resp) => {
if (resp == 1) {
console.log("Wellcome ");
} else {
console.log("Registration canceled");
}
})
.catch((e) => console.log("Error ", e));
...
window.Modals.prompt({
title: "Hello",
message: "What's your name?",
cancelButtonTitle: "Cancel",
okButtonTitle: "Register",
inputText: "",
})
.then((resp) => {
if (resp.buttonIndex == 1) {
console.log("Wellcome ", resp.input1);
} else {
console.log("Canceled");
}
})
.catch((e) => console.log("Error ", e));
...
window.Modals.alert({
title: "Wellcome",
message: "Hello world",
buttonTitle: "Hi",
})
.then(() => console.log("Dialog dismissed"))
.catch((e) => console.log("Error ", e));
window.Modals.alert({
title: "Wellcome",
message: "Hello world",
buttonTitle: "Hi",
})
.then(() => console.log("Dialog dismissed"))
.catch((e) => console.log("Error ", e));
...
window.Modals.confirm({
title: "Register",
message: "Do you want to proceed to registration?",
cancelButtonTitle: "Cancel",
okButtonTitle: "Proceed",
})
.then((resp) => {
if (resp == 1) {
console.log("Wellcome ");
} else {
console.log("Registration canceled");
}
})
.catch((e) => console.log("Error ", e));
...
window.Modals.prompt({
title: "Hello",
message: "What's your name?",
cancelButtonTitle: "Cancel",
okButtonTitle: "Register",
inputText: "",
})
.then((resp) => {
if (resp.buttonIndex == 1) {
console.log("Wellcome ", resp.input1);
} else {
console.log("Canceled");
}
})
.catch((e) => console.log("Error ", e));
(<any>window).Modals.alert({
title: "Wellcome",
message: "Hello world",
buttonTitle: "Hi",
})
.then(() => console.log("Dialog dismissed"))
.catch((e) => console.log("Error ", e));
(<any>window).Modals.confirm({
title: "Register",
message: "Do you want to proceed to registration?",
cancelButtonTitle: "Cancel",
okButtonTitle: "Proceed",
})
.then((resp) => {
if (resp == 1) {
console.log("Wellcome ");
} else {
console.log("Registration canceled");
}
})
.catch((e) => console.log("Error ", e));
(<any>window).Modals.prompt({
title: "Hello",
message: "What's your name?",
cancelButtonTitle: "Cancel",
okButtonTitle: "Register",
inputText: "",
})
.then((resp) => {
if (resp.buttonIndex == 1) {
console.log("Wellcome ", resp.input1);
} else {
console.log("Canceled");
}
})
.catch((e) => console.log("Error ", e));
window.Modals.alert({
title: "Wellcome",
message: "Hello world",
buttonTitle: "Hi",
})
.then(() => console.log("Dialog dismissed"))
.catch((e) => console.log("Error ", e));
...
window.Modals.confirm({
title: "Register",
message: "Do you want to proceed to registration?",
cancelButtonTitle: "Cancel",
okButtonTitle: "Proceed",
})
.then((resp) => {
if (resp == 1) {
console.log("Wellcome ");
} else {
console.log("Registration canceled");
}
})
.catch((e) => console.log("Error ", e));
...
window.Modals.prompt({
title: "Hello",
message: "What's your name?",
cancelButtonTitle: "Cancel",
okButtonTitle: "Register",
inputText: "",
})
.then((resp) => {
if (resp.buttonIndex == 1) {
console.log("Wellcome ", resp.input1);
} else {
console.log("Canceled");
}
})
.catch((e) => console.log("Error ", e));
beep(count: number): void
Causes the device to beep.
confirm(options: ConfirmOptions): Promise<number>
Show a confirmation modal.
Returns a promise that resolves the button index that was clicked, or 0 if the user has dismissed the dialog by clicking outside the dialog box. Note that the index use one-based indexing.
interface AlertOptions { buttonTitle ?: string; message : string; title : string; }
interface ConfirmOptions { cancelButtonTitle ?: string; message : string; okButtonTitle ?: string; title : string; }
interface PromptOptions { cancelButtonTitle ?: string; inputText ?: string; message : string; okButtonTitle ?: string; title : string; }
interface PromptResult { buttonIndex : number; //The index of the pressed button input1 : string; //The text entered in the prompt dialog box }