Note
WebOSServiceBridge API is available only on webOS Open Source Edition (OSE) 2.0 or higher.
WebOSServiceBridge API is available only on webOS Open Source Edition (OSE) 2.0 or higher.
WebOSServiceBridge is a JavaScript API that enables web applications to access Luna Bus.
WebOSServiceBridge()
: Creates a WebOSServiceBridge object.onservicecallback
: Registers the callback routine to handle the response.Invokes the Luna service method.
Name | Type | Description |
---|---|---|
url | String | URL of the Luna service method |
params | JSON string | Parameter for the method to invoke |
var bridge = new WebOSServiceBridge();
bridge.call("luna://com.webos.service.applicationmanager/launch", '{"id":"APP_ID"}');
var url = 'luna://com.webos.service.db/putKind';
var params = JSON.stringify({
"id":"test.db-api:1",
"owner":"APP_ID"
});
bridge.call(url, params);
Cancels the call()
request.
This method has no return value, because the call is canceled.
var bridge = new WebOSServiceBridge();
bridge.onservicecallback = function (msg) { var response = JSON.parse(msg); console.log(response.returnValue);};
bridge.call("luna://com.webos.service.applicationmanager/running", '{"subscribe":true}');
bridge.cancel();
The following shows an example of JavaScript code that uses WebOSServiceBridge API.
servicetest.js | ||
---|---|---|
|
You can test the code above by including the JavaScript file inside an HTML file as below.
index.html |
---|
|
Contents