Event Callbacks
UtilsNetwork and toast event handlers
Access these methods through agent.utils. Register callbacks to receive system events during automation.
Note: For notification callbacks, see agent.notifications.
setNetworkCallback()
TypeScript
setNetworkCallback(callback: NetworkCallback | null): voidRegisters a callback to receive network state changes. Pass null to unregister.
Parameters
| Name | Type | Description |
|---|---|---|
callback | (networkAvailable: boolean) => void | Callback function or null to unregister |
Examples
TypeScript
agent.utils.setNetworkCallback((networkAvailable) => { if (!networkAvailable) { console.log("Network disconnected!"); }});toastCallback
TypeScript
toastCallback: ((packageName: string, data: { message: string }) => void) | nullSet this property to receive toast messages shown by apps.
Example
TypeScript
agent.utils.toastCallback = (packageName, data) => { console.log("Toast from", packageName + ":", data.message);};Callback Types
NetworkCallback
TypeScript
type NetworkCallback = (networkAvailable: boolean) => void;ToastCallback
TypeScript
type ToastCallback = ( packageName: string, data: { message: string }) => void;