The custom events system is a powerful feature that enables bidirectional data communication between a miniapp and the host app. The miniapp can send data that the host app can recognize. Additionally, certain operations can be implemented at the native app level for enhanced functionality.
java
Handle custom events by listening to .customEvents()
.
Example receiving and sending back same event:
For cases when you want to hide all miniapps when a custom event is received, you can call Appboxo.hideMiniapps()
;
Example:
Handling custom events in React Native is straightforward. Use customEvents to both subscribe to and send custom events between the miniapp and the host app.
Example:
TIP
Please don’t forget to unsubscribe from events
Usage:
Boxo Event Bridge is a bidirectional communication functionality that enables host apps and miniapps to exchange events and information seamlessly within the Boxo ecosystem.
Here is a diagram illustrating the event communication process between a miniapp and a host app.
*Note: Feature must be enabled in Dashboard Partnership
Data format
JSON is used for data exchange. Event payloads can contain any valid JSON structure that both the sender and receiver agree upon.
This endpoint allows your app to receive events from the Boxo Platform.
URL and METHOD:
This endpoint must handle a HTTPS POST request URL to endpoint must be provided in Dashboard
Headers:
Key | Value |
---|---|
Authorization | <prefix> <base64 encoded(hostapp_client_id:hostapp_secret_key)> |
Content-type | application/json |
<prefix>
: Token
. Access token prefix can be set in Boxo Connect.hostapp_client_id
and hostapp_secret_key
must be provided in DashboardBody
Field | Data type | Description |
---|---|---|
app_id | String | Miniapp identifier |
client_id | String | Hostapp identifier |
event_type | String | Event type identifying the purpose of the event |
payload | Object | Event data containing information specific to the event |
Response:
200
in all casesRequest Example:
This endpoint allows your app to send events to miniapps through the Boxo Platform.
URL and METHOD
This is HTTPS POST /api/v1/event-bridge/hostapp/
endpoint
Headers
Key | Value |
---|---|
Authorization | <prefix> <base64 encoded(hostapp_client_id:hostapp_secret_key)> |
Content-type | application/json |
<prefix>
: Token
. Access token prefix can be set in Boxo Connect.hostapp_client_id
and hostapp_secret_key
must be provided in DashboardBody
Field | Data type | Description |
---|---|---|
app_id | String | Miniapp identifier (recipient) |
client_id | String | Hostapp identifier (sender) |
event_type | String | Event type identifying the purpose of the event |
payload | Object | Event data containing information specific to the event |
Response
200
if the event was delivered successfullyRequest Example
Here are some common event types that can be used for communication between host apps and miniapps:
Event Type | Description | Example Payload |
---|---|---|
user_profile_updated | User profile information has been updated | {"user_id": "123", "updated_fields": ["email"]} |
payment_completed | A payment has been processed successfully | {"transaction_id": "tx_123", "amount": 100.50} |
location_updated | User’s location has been updated | {"latitude": 37.7749, "longitude": -122.4194} |
app_state_change | The state of the host app has changed | {"new_state": "background", "timestamp": 123456} |
Event Type | Description | Example Payload |
---|---|---|
order_created | A new order has been created in the miniapp | {"order_id": "ord_123", "amount": 50.25} |
product_viewed | User has viewed a product in the miniapp | {"product_id": "prod_123", "category": "shoes"} |
cart_updated | User’s shopping cart has been updated | {"cart_id": "cart_123", "item_count": 3} |
content_shared | User has shared content from the miniapp | {"content_id": "cont_123", "content_type": "image"} |
If an error occurs during event processing, the Boxo Platform will return an appropriate error response:
Error Code | Description |
---|---|
EVENT_RECEIVER_DISABLED | Event receiver is not enabled for the recipient |
INVALID_EVENT_DATA | The event data format is invalid |
EVENT_DELIVERY_FAILED | Failed to deliver the event to the recipient |
UNAUTHORIZED | Sender is not authorized to send events |
By following these guidelines, you can create a robust event-driven communication system between your host app and miniapps using Boxo Event Bridge.
The custom events system is a powerful feature that enables bidirectional data communication between a miniapp and the host app. The miniapp can send data that the host app can recognize. Additionally, certain operations can be implemented at the native app level for enhanced functionality.
java
Handle custom events by listening to .customEvents()
.
Example receiving and sending back same event:
For cases when you want to hide all miniapps when a custom event is received, you can call Appboxo.hideMiniapps()
;
Example:
Handling custom events in React Native is straightforward. Use customEvents to both subscribe to and send custom events between the miniapp and the host app.
Example:
TIP
Please don’t forget to unsubscribe from events
Usage:
Boxo Event Bridge is a bidirectional communication functionality that enables host apps and miniapps to exchange events and information seamlessly within the Boxo ecosystem.
Here is a diagram illustrating the event communication process between a miniapp and a host app.
*Note: Feature must be enabled in Dashboard Partnership
Data format
JSON is used for data exchange. Event payloads can contain any valid JSON structure that both the sender and receiver agree upon.
This endpoint allows your app to receive events from the Boxo Platform.
URL and METHOD:
This endpoint must handle a HTTPS POST request URL to endpoint must be provided in Dashboard
Headers:
Key | Value |
---|---|
Authorization | <prefix> <base64 encoded(hostapp_client_id:hostapp_secret_key)> |
Content-type | application/json |
<prefix>
: Token
. Access token prefix can be set in Boxo Connect.hostapp_client_id
and hostapp_secret_key
must be provided in DashboardBody
Field | Data type | Description |
---|---|---|
app_id | String | Miniapp identifier |
client_id | String | Hostapp identifier |
event_type | String | Event type identifying the purpose of the event |
payload | Object | Event data containing information specific to the event |
Response:
200
in all casesRequest Example:
This endpoint allows your app to send events to miniapps through the Boxo Platform.
URL and METHOD
This is HTTPS POST /api/v1/event-bridge/hostapp/
endpoint
Headers
Key | Value |
---|---|
Authorization | <prefix> <base64 encoded(hostapp_client_id:hostapp_secret_key)> |
Content-type | application/json |
<prefix>
: Token
. Access token prefix can be set in Boxo Connect.hostapp_client_id
and hostapp_secret_key
must be provided in DashboardBody
Field | Data type | Description |
---|---|---|
app_id | String | Miniapp identifier (recipient) |
client_id | String | Hostapp identifier (sender) |
event_type | String | Event type identifying the purpose of the event |
payload | Object | Event data containing information specific to the event |
Response
200
if the event was delivered successfullyRequest Example
Here are some common event types that can be used for communication between host apps and miniapps:
Event Type | Description | Example Payload |
---|---|---|
user_profile_updated | User profile information has been updated | {"user_id": "123", "updated_fields": ["email"]} |
payment_completed | A payment has been processed successfully | {"transaction_id": "tx_123", "amount": 100.50} |
location_updated | User’s location has been updated | {"latitude": 37.7749, "longitude": -122.4194} |
app_state_change | The state of the host app has changed | {"new_state": "background", "timestamp": 123456} |
Event Type | Description | Example Payload |
---|---|---|
order_created | A new order has been created in the miniapp | {"order_id": "ord_123", "amount": 50.25} |
product_viewed | User has viewed a product in the miniapp | {"product_id": "prod_123", "category": "shoes"} |
cart_updated | User’s shopping cart has been updated | {"cart_id": "cart_123", "item_count": 3} |
content_shared | User has shared content from the miniapp | {"content_id": "cont_123", "content_type": "image"} |
If an error occurs during event processing, the Boxo Platform will return an appropriate error response:
Error Code | Description |
---|---|
EVENT_RECEIVER_DISABLED | Event receiver is not enabled for the recipient |
INVALID_EVENT_DATA | The event data format is invalid |
EVENT_DELIVERY_FAILED | Failed to deliver the event to the recipient |
UNAUTHORIZED | Sender is not authorized to send events |
By following these guidelines, you can create a robust event-driven communication system between your host app and miniapps using Boxo Event Bridge.