Skip to main content

Alert · AnswerAlert · AnswerPrompt

This tool on every surface: CLI · MCP · Python · JavaScript · Go · Java · .NET

Read a system dialog, or answer it with accept or dismiss. These call app_alert.

Alert​

func (d *Device) Alert(ctx context.Context) (string, error)

Alert reports what a system dialog says, or "" when none is up.

A permission prompt is another process's window, not the app's. Reading it needs no knowledge of what the buttons say, which is the point.

AnswerAlert​

func (d *Device) AnswerAlert(ctx context.Context, accept bool) error

AnswerAlert accepts or dismisses a system dialog.

These answer a dialog; they do not choose an outcome. On a permission prompt they do not mean grant and deny, and on iOS they are the other way round — accept leaves it denied, dismiss leaves it granted, because W3C accept presses the affirmative button and Apple puts "Don't Allow" last. Tap the button by ref if you need a particular answer.

AnswerPrompt​

func (d *Device) AnswerPrompt(ctx context.Context, text string, accept bool) error

AnswerPrompt types text into a dialog's field, then accepts or dismisses it, in one call. A plain alert has no field, and the platform refuses the text. What accept and dismiss press is as for AnswerAlert.

Examples​

Ask whether a system dialog is up, and what it says​

text, err := dev.Alert(ctx)
if err != nil {
return err
}
if text != "" {
fmt.Println("dialog up:", text)
}

The same call from the command line, mobium alert, printed on an Android 15 emulator:

a dialog is on screen: "Discard changes?\nThey will be lost."

mobium alert on an Android 15 emulator

mobium alert on an Android 15 emulator

Answer it with the platform's accept button​

if err := dev.AnswerAlert(ctx, true); err != nil {
return err
}

The same call from the command line, mobium alert accept, printed on an Android 15 emulator:

accepted the dialog "Discard changes?\nThey will be lost." — this answered it and did not choose an outcome: on a permission prompt accept and dismiss do not mean grant and deny, and on iOS they are the other way round. Tap the button by ref if you need a particular answer
BeforeAfter
Before: mobium alert accept on an Android 15 emulatorAfter: mobium alert accept on an Android 15 emulator

mobium alert accept on an Android 15 emulator

More examples​

Fill a prompt's field and accept it, in one call​

if err := dev.AnswerPrompt(ctx, "Groceries", true); err != nil {
return err
}