webOSDev API

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

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

Methods

TypeNameDescription
Member
Holds properties representing the list of built-in apps opened on the webOS TV.
Holds properties that represent the DRM error number and the DRM type.
Method
Returns the `DRMAgent` instance of a specific DRM type.
Launches an application with parameters.
Passes parameters when an app is being launched after `webOS.launch` is called.
Returns a device ID provided by the webOS TV (`LGUDID`) since webOS TV 3.0.
Returns the network connection state.

APP

Description

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

Properties

Name

Type

Description

BROWSER

String

The 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

Name

Type

Description

error

DRMError

The error number from the DRM service

type

DRMType

The type of DRM

See also

  • None

drmAgent

Description

Returns `DRMAgent` instance of a specific DRM type.

For more details about `DRMAgent`, see DRMAgent.

Parameters

NameTypeDescriptionRequired
type
String
The DRM type to be set to the `DRMAgent` instance.
Properties
NameTypeDescription
PLAYREADY
String
PlayReady
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
parameters
Object
The JSON object containing an app ID, parameters, and callback handlers.
Properties
NameTypeDescription
id
String
The app ID or webOSDev.APP
params
Object
The JSON data object to pass when launching an app
onSuccess
Function
The callback function called when the method succeeds.
onFailure
Function
The callback function called when the method fails.
Yes

Success callback returns

None

Failure callback returns

NameTypeDescription
error
Object
The JSON object containing DRM service's error details.
Properties
NameTypeDescription
errorCode
String
The error code returned when the method fails.
errorText
String
The error text returned when the method fails.

Call returns

Returns undefined.

Example

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

// In app B: receive the parameters passed by app 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.launch` 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

Name

Type

Description

params

Object

Parameters 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 the device ID provided by the webOS TV since webOS TV 3.0.

Parameters

NameTypeDescriptionRequired
parameters
Object
The JSON object containing handlers.
Properties
NameTypeDescription
onSuccess
Function
The callback function called when the method succeeds.
onFailure
Function
The callback function called when the method fails.
Yes

Success callback returns

NameTypeDescription
info
Object
The JSON object containing the device ID.
Properties
NameTypeDescription
id
String
LG unique device ID.

Failure callback returns

NameTypeDescription
info
Object
The JSON object containing UDID error details.
Properties
NameTypeDescription
errorCode
String
The error code returned when the method fails.
errorText
String
The error text returned when the method fails.

Call 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
parameters
Object
The JSON object containing handlers.
Properties
NameTypeDescriptionRequired
onSuccess
Function
The callback function called when the method succeeds.
Yes
onFailure
Function
The callback function called when the method fails.
Yes
subscribe
Boolean
Indicates whether to subscribe the network connection status.
  • true: Subscribe to the network connection status.
  • false: Do not subscribe the network connection status.
Yes
Yes

Success callback returns

NameTypeDescription
response
Object
The JSON object containing the service's response data related to the network connection.
Properties
NameTypeDescription
isInternetConnectionAvailable
Boolean
Indicates whether the internet connection is available.
  • true: The internet connection is available.
  • false: The internet connection is unavailable.
wired
Object
The object that contains information about the state of the wired connection.
For more details, see wired object.
wifi
Object
The object that contains information about the state of the WiFi connection.
For more details, see wifi object.
wifiDirect
Object
The object that contains information about the state of the WiFi direct connection.
For more details, see wifiDirect object.

Failure callback returns

NameTypeDescription
info
Object
The JSON object containing the error details.
Properties
NameTypeDescription
errorCode
String
The error code returned when the method fails.
errorText
String
The error text returned when the method fails.

Call 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