Developer Documentation

🚀 PockyBridge
SDK Documentation

PockyBridge provides a seamless interface between Android Native components and WebView. Access device hardware, system UI, and Firebase data through a unified JavaScript object.

01 Setup & Initialization

To enable the bridge, the Android application must register the interface within the WebView setup. Ensure the Pocky object is ready on the web side to receive events.

// Android side
webView.addJavascriptInterface(new PockyBridge(this, webView), "Pocky");

02 API Reference

Utilize the Pocky object to interact with Native features seamlessly.

User Identity

Retrieve authenticated user data fetched from Firebase.

Card & Data Management

!

Important Notes

JSON Handling: All complex data (Arrays/Objects) must be passed as JSON strings. Ensure window.Pocky is initialized early to avoid missing events.

03 Event Callbacks

Define these functions within your window.Pocky object to handle Native → Web events.

Event Description
OnDialogPositive User clicked "Positive" button.
OnDialogNegative User clicked "Negative" button.
OnNewCardAdded Broadcasts new card data.
OnCardDeleted Broadcasts successful removal.

04 Usage Examples

Example: Handling a Confirmation Dialog

// 1. Trigger the dialog
Pocky.showDialog("confirm_delete_01", "Delete this item?", "Delete", "Cancel");

// 2. Listen for the choice
window.Pocky = {
    ...window.Pocky,
    OnDialogPositive: function(data) {
        const response = JSON.parse(data);
        if (response.id === "confirm_delete_01") {
            Pocky.vibrate(100);
        }
    }
};

Example: Syncing Data to Native UI

const myCards = [{ name: "Personal ID", id: "001" }];
Pocky.updateList(JSON.stringify(myCards));