JS Runtime & Core
Inter-App Communication (IPC)
Launch companion apps, handle intents, and open associated files with System.ipc.
16. Inter-App Communication & Intent Dispatcher (System.ipc / IPC)
KryonOS provides comprehensive Inter-App Communication (IPC) for contextual app launching, startup argument passing, file extension association resolution, and runtime message mailboxes.
16.1 Contextual App Launching
System.ipc.launch(targetAppId, launchArgs)
- Parameters:
targetAppId: String - The package name (e.g.,"com.kryonos.imageviewer") or display name of the target application.launchArgs: Object or String (Optional) - JSON payload passed into the target app's startup context.
- Returns:
Boolean-trueif the target app is found and launch requested. - Description: Switches foreground focus to
targetAppIdand passeslaunchArgs. Note: If the target app specified"allowCompanionLaunch": falsein itsapp.json, the OS will reject the launch.
// Launch image viewer with target file
System.ipc.launch("com.kryonos.imageviewer", {
filePath: "/local/photos/sunset.bmp",
autoSlideShow: true
});
16.2 File Extension Association & Intent Opening
System.ipc.openFile(filePath)
- Parameters:
filePath: String - Full path to the file (e.g."/local/documents/notes.txt"). - Returns:
Boolean-trueif an associated handler app was found and launched. - Description: Resolves the file's extension against all installed apps declaring
fileAssociationsin theirapp.json(e.g.,[".bmp", ".png", ".jpg"]or[".txt", ".log"]) and launches the matching viewer with{ filePath: filePath }.
// Automatically opens in text editor or log viewer based on app.json fileAssociations
System.ipc.openFile("/local/logs/system.log");
16.3 Reading Startup Context Arguments
System.ipc.getLaunchArgs()
- Returns:
Objectornull - Description: Called when an application boots up to read the parameters passed by the launching app.
var args = System.ipc.getLaunchArgs();
if (args && args.filePath) {
console.log("Opening context file:", args.filePath);
loadFile(args.filePath);
}
16.4 Runtime Messaging & Mailbox
System.ipc.send(targetAppId, action, payload)
- Parameters:
targetAppId: String - Target package ID, or"*"for broadcast.action: String - Command or event name (e.g."SYNC_DATA","PING").payload: Object or String - Message content.
- Returns:
Boolean - Description: Enqueues a message into the OS runtime message mailbox for background services or active apps.
System.ipc.onMessage(callback)
- Parameters:
callback: Function - Callback receiving(senderAppId, action, payload). - Description: Registers a listener for incoming runtime messages.
// Listen for messages from companion apps
System.ipc.onMessage(function(sender, action, payload) {
console.log("Received from " + sender + ": [" + action + "] " + payload);
});