Skip to main content

showAlert

Displays a dialog (alert or action sheet).

Parameters

interface AlertConfig {
title?: string;
message?: string;
preferredStyle?: "alert" | "actionSheet";
actions: AlertAction[];
}

interface AlertAction {
title?: string;
style?: "cancel" | "destructive";
key: string;
}

AlertConfig

NameTypeRequiredDefaultDescription
titlestringNoTitle
messagestringNoMessage
preferredStyle"alert" or "actionSheet"NoalertStyle
actionsAlertAction[]YesButton configuration

AlertAction

NameTypeRequiredDefaultDescription
titlestringNoButton text
style"cancel" or "destructive"NoButton style
keystringYesalertCallback key when clicked

Return Value

NameTypeDescription
datastring?Key of the button clicked by the user; if canceled, it will be empty

Example

import { showAlert } from "minip-bridge";

showAlert({
title: "default alert",
message: "message",
preferredStyle: "alert",
actions: [
{
title: "ok",
key: "ok",
},
{
title: "destructive",
key: "destructive",
style: "destructive",
},
{
title: "cancel",
key: "cancel",
style: "cancel",
},
],
}).then((res) => {
if (res.hasData()) {
console.log(`Selected ${res.data}`);
} else {
console.log("Canceled");
}
});