BlocosIA Wiki Editor

App (Kodular / App Inventor)

Export the project as HTML, open it in a Kodular or MIT App Inventor WebViewer and exchange messages with the app: events, requests with answers, TinyDB, toasts, vibrate, share and much more.

In the app: the WebViewer.WebViewStringChange event receives what the project sends (text or JSON). To send something to the project, use WebViewer.RunJavaScript("blocosiaApp('back')") or change the WebViewString property. To answer a request: RunJavaScript("blocosiaApp.responder(ID, 'value')"). In the editor, use "simulate the app sending…" to test. See the full recipe in the Wiki.

To use it: in the editor, click "Extensions" (bottom corner) and add "App (Kodular / App Inventor)".

Boolean

am I inside an app (App Inventor / Kodular)?

True when the exported project is open in an App Inventor or Kodular WebViewer.

Stack

send text ( ) to the app

Sends a text to the app: fires the WebViewer.WebViewStringChange event.

Stack

send event ( ) with data ( ) to the app

Sends a named event with data as JSON: {"tipo":"evento","nome":…,"dados":…}.

Stack

ask the app: [show a toast] ( )

Asks the app for a phone feature: toast, vibrate, open link, share, speak, copy, notification, keep screen on, orientation, another screen or close.

Stack

request ( ) from the app with data ( ) and wait for the answer

Makes a request with a number (id) and waits for the app's answer (up to 10 s). The app answers with RunJavaScript("blocosiaApp.responder(id, value)").

Reporter

app answer

The answer to the last request.

Boolean

did the app answer?

True if the app answered the last request in time.

Stack

store in the app (TinyDB) tag ( ) with value ( )

Asks the app to store a value in TinyDB (it stays on the phone after the app closes).

Stack

read from the app (TinyDB) tag ( ) and wait

Asks the app for a TinyDB tag and waits; the value goes to "app answer".

Hat

when the app sends a message

Starts when the app sends any message or event.

Hat

when the app sends the event [voltar]

Starts when the app sends an event with that name (e.g. back, pause, coin).

Reporter

message received from the app

The text of the last message received from the app.

Reporter

received event name

The name of the last event received.

Reporter

data received from the app

The data of the last event (number, text, list or object).

Reporter

app WebViewString

The current value of the app's WebViewString property.

Reporter

page address parameter ( )

Reads a parameter from the page address (e.g. game.html?level=2 → level = 2).

Stack

simulate the app sending event ( ) with data ( )

Pretends the app sent an event: test the project in the editor without a phone.