webOSDev API

The webOSDev API provides methods for device information, digital right management (DRM), and app launch.

Most methods of webOSDev API are newly added, especially for webOS TV.

Methods

TypeNameDescription
MemberAPPHolds properties representing the list of built-in apps opened on the webOS TV.
DRMHolds properties that represent the DRM error number and the DRM type.
MethoddrmAgentReturns DRMAgent instance of a specific DRM type.
launchLaunches an application with parameters.
launchParamsPasses parameters when an app is being launched after webOS.launch is called.
LGUDIDReturns a device ID provided by the webOS TV ( LGUDID ) since webOS TV 3.0.
connection.getStatusReturns the network connection state.

APP

Description

A member representing the list of built-in apps on the webOS TV opened to external developers.

Properties

NameTypeDescription
BROWSERStringThe built-in browser on the webOS TV

Example

// You can launch webOS browser application.
webOSDev.launch({
  id: webOSDev.APP.BROWSER,
  params: {
    target: 'http://www.your-web-page.com', // target should be
  },
  onSuccess(res) {
    // do something
  },
  onFailure(res) {
    // handle error
  },
});

See also

  • None

DRM

Description

An object containing properties that represent the DRM error number and the DRM type.

Properties

NameTypeDescription
ErrorDRMErrorThe error number from DRM service
TypeDRMTypeThe type of DRM

See also

  • None

drmAgent

Description

Returns DRMAgent instance of a specific DRM type.

For more details of DRMAgent, see DRMAgent.

Parameters

NameTypeDescriptionrequired
typeStringThe DRM type to be set to the DRMAgent instance

Properties

NameTypeDescription
PLAYREADYStringPlayReady
Yes

Call returns

Returns the Instance of DRMAgent.

Example

var drmagent;
drmagent = webOSDev.drmAgent(webOSDev.DRM.Type.PLAYREADY);

See also

  • None

launch

Description

Launches an application with parameters.

Parameters

NameTypeDescriptionrequired
parametersObjectThe JSON object containing an app ID, parameters, callback handlers

Properties

NameTypeDescription
idStringThe app ID or webOSDev.APP
paramsObjectThe JSON data object to pass when launching an app
onSuccessFunctionThe callback function called when the method succeeds.
onFailureFunctionThe callback function called when the method fails.
Yes

Success Callback Returns

None

Failure Callback Returns

NameTypeDescription
errorObjectThe JSON Object containing DRM service's error details.

Properties

NameTypeDescription
errorCodeStringThe error code returned when the method fails.
errorTextStringThe error text returned when the method fails.

Call returns

Returns undefined.

Example

// Calls the launch application 'B' in 'A'
webOSDev.launch({
  id: 'your.app.B',
  params: {
    userId: 'user',
    page: 'shown page',
  },
  onSuccess: function (res) {
    // do something
  },
  onFailure: function (res) {
    // error
  },
});

// 'B' receives parameters that are passed by the application 'A'
document.addEventListener('webOSLaunch', function (data) {
  console.log(data.detail.userId + ', ' + data.detail.page);
});

document.addEventListener('webOSRelaunch', function (data) {
  console.log(data.detail.userId + ', ' + data.detail.page);
});

var params = webOSDev.launchParams();
if (params.userId === 'user') {
  console.log(params.userId + ' wants to access to ' + params.page);
}

See also

launchParams

Description

Passes parameters of an app launched by the webOSDev.lauch method.

Note
The parameters are usually delivered when the webOSLaunch event or webOSRelaunch event occurs. This method can be used to get the parameters from elsewhere where those events don't occur.

Parameters

None

Call returns

NameTypeDescription
paramsObjectParameters passed to the app

Example

var params = webOSDev.launchParams();
if (params) {
  console.log(params.userId + ' wants to access to page ' + params.page);
}

See also

LGUDID

Description

Returns a device ID provided by the webOS TV since webOS TV 3.0.

Parameters

NameTypeDescriptionRequired
parametersObjectThe JSON object

Properties

NameTypeDescription
onSuccessFunctionThe callback function called when the method succeeds.
onFailureFunctionThe callback function called when the method fails.
Yes

Success Callback Returns

NameTypeDescription
infoObjectThe JSON Object containing the device ID.

Properties

NameTypeDescription
idStringLG unique device ID.

Failure Callback Returns

NameTypeDescription
infoObjectThe JSON Object containing UDID error details.

Properties

NameTypeDescription
errorCodeStringThe error code returned when the method fails.
errorTextStringThe error text returned when the method fails.

Callback Returns

Returns undefined.

Example

webOSDev.LGUDID({
  onSuccess: function (res) {
    // user device from server
    if (res.id === user.device) {
      // do something
    }
  },
  onFailure: function (res) {
    // API calling error
  },
});

See also

  • None

connection.getStatus

Description

Returns the network connection state.

Parameters

NameTypeDescriptionRequired
parametersObjectThe JSON object containing handlers

Properties

NameTypeDescriptionRequired
onSuccessFunctionThe callback function called when the method succeeds.Yes
onFailureFunctionThe callback function called when the method fails.Yes
subscribeBooleanIndicates whether to subscribe the network connection status.
  • true: Subscribe the network connection status.
  • false: Not subscribe the network connection status.
Yes
Yes

Success Callback Returns

NameTypeDescription
responseObjectThe JSON object containing the service's response data related to the network connection.

Properties

NameTypeDescription
isInternetConnectionAvailableBooleanIndicates whether the internet connection is available.
  • true: The internet connection is available.
  • false: The internet connection is unavailable.
wiredObjectThe object that contains information about the state of the wired connection.
For more details, see wired object.
wifiObjectThe object that contains information about the state of the WiFi connection.
For more details, see wifi object.
wifiDirectObjectThe object that contains information about the state of the WiFi direct connection.
For more details, see wifiDirect object.

Failure Callback Returns

NameTypeDescription
infoObjectThe JSON Object containing the error details.

Properties

NameTypeDescription
errorCodeStringThe error code returned when the method fails.
errorTextStringThe error text returned when the method fails.

Callback Returns

Returns undefined.

Example

webOSDev.connection.getStatus({
  onSuccess: function (res) {
    if (res.isInternetConnectionAvailable === false) {
      // pop up network error message
    } else {
      if (res.wired) {
        // do something
      } else if (res.wifi) {
        // do something
      }
    }
  },
  onFailure: function (res) {
    // API calling error
  },
  subscribe: true,
});

See also

  • None
No Headings