Native Toast Message

0
Hello,   I need assistance with displaying a toast message after deleting an item in Mendix. I'm utilizing the native toast message widget on native pages. When I place the widget directly on a page, it functions properly. However, I want the message to appear after the file has been deleted, so I've set its visibility. Unfortunately, the widget is no longer visible in the page.   Has anyone encountered and resolved this issue before? I appreciate any guidance you can provide.
asked
2 answers
0
// Create a javascript action and try this code. This will display the toast message wherever the JSA is called. 
import { ToastAndroid } from 'react-native';

export async function ShowToastMessage(message) {
	// BEGIN USER CODE
	if (!message) {
		console.warn("ShowToastMessage called without a message!");
		return false;
	}
	ToastAndroid.show(message, ToastAndroid.SHORT);

	return true;
	// END USER CODE
}


answered
0

Hi,


The issue occurs because Native Toast Message widget is UI-driven, not event-driven.

When you delete the object, the page refreshes and the widget loses its context — so the toast never appears.

Why Your Current Approach Fails

  • You placed the Toast widget on the page
  • You controlled visibility after delete
  • But after deletion:
    • The object is gone
    • The UI re-renders
    • Widget is no longer in context

So the toast cannot be triggered.

Correct Working Approach

In Native Mobile, toast messages must be triggered using a Nanoflow action, NOT by widget visibility.

Solution

Step 1: Use Nanoflow for Delete Action

Instead of directly deleting:

  • Create a Nanoflow
  • Add:
    1. Delete Object
    2. Show Message (or Toast action)

Step 2: Show Toast After Delete

In the same Nanoflow:

  • After Delete activity
  • Add:
    • Show Message action
    • Set:
      • Type → Information / Success
      • Message → "Item deleted successfully"

This works as a toast in Native

Step 3: Call Nanoflow from Button

  • Button → On Click → Call Nanoflow
  • Do NOT rely on widget visibility

  • Native does NOT support:
    • Triggering toast via widget visibility
  • Toast must be:
    • Event-triggered (Nanoflow)
  • After delete:
    • Always show message immediately in same flow

Alternative If Using Native Toast Widget

If you still want to use the Toast widget:

  • Trigger it using:
    • Boolean helper variable
  • But still:
    • Control it via Nanoflow logic
  • Not recommended for delete scenarios

  • Widget-based toast → Not reliable after delete
  • Nanoflow-based message → Correct and recommended

Use a Nanoflow → Delete Object → Show Message instead of controlling Toast widget visibility.

This is the actual working approach used in Mendix Native apps and aligns with platform behavior.



answered