services.json

The services.json file resides in a service's root directory and describes how the service is constructed and operates.

Schema and properties

{
    "services":   [{
        "name"            : string,
        "description"   : string,
        "commands"      :   [{
            "name"              : string,
            "description"     : string,
            "public"          : boolean
        }]
    }]
}
PropertyRequiredTypeDescription
servicesRequiredObject array

Services the application provides. Typically, an application provides only one service. However, there may be reasons to provide multiple services within the same application. An application must define at least one service (since an application without services probably does not make sense).

-nameRequiredString

Name of service on the webOS message bus.

The service name must begin with the app ID. For example, 

  • App ID: com.example.myapplication 
  • Service name: com.example.myapplication.myservice
-descriptionOptionalStringDescription of the service(s).
-commandsRequiredObject array

Indicates what service provides. A service may provide zero or more commands per service (service with no commands may want to run once when the application is started).

--nameRequiredString

Indicates command(s) name. It is good practice to use the camel case naming convention when naming commands. For example: getProperties and setProperties. The command name cannot exceed 255 characters.

--descriptionOptionalString

Indicates command(s) description. This is only for developer use and information.  This information is not available to any apps. 

--publicOptionalBoolean

The default value is false. In order to make the command available to all apps, you must set this property to true.

Example

{
  "services": [
    {
      "name": "com.test.testacct.test.service",
      "description": "Test Contact",
      "commands": [
        {
          "name": "checkCredentials",
          "public": true
        },
        {
          "name": "onCapabiltiesChanged",
          "public": true
        },
        {
          "name": "onCredentialsChanged",
          "public": true
        },
        {
          "name": "onCreate",
          "public": true
        },
        {
          "name": "onEnabled",
          "public": true
        },
        {
          "name": "onDelete",
          "public": true
        },
        {
          "name": "sync",
          "public": true
        }
      ]
    }
  ]
}
No Headings