services.json

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

Schema & Properties

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

 

Property Required Type Description
services Required Object 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).

-name Required String

Name of service on webOS message bus.  

The service name must begin with the app name. For example, 
  • App name: com.example.myapplication 
  • Service name: com.example.myapplication.myservice
-description Optional String Description of the service(s).
-commands Required Object array

Indicates what a service provides.

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

--name Required String

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.

--description Optional String

Indicates command(s) description. This is only for developer use and information. 

This information is not available to any apps. 

--public Optional Boolean

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
            }                                                                    
         ]
      }
   ]
}

 

Navigation