GetNotification()

Description:

The GetNotification method notifies the client when the value of a system attribute is changed.

This is an asynchronous method.

Syntax:

GetNotification(parameters:Object, callback:Object):Object

Arguments:

  • parameters:

    This is an object that specifies the system attribute to monitor for changes. For more information about the object properties and how to define them, see section Parameters for change notifications.

  • callback:

    The callback argument is the name of the method that is executed when a GetNotification call has results or status information to return. You must define this method separately. Follow the instructions in section Defining the callback handler for an asynchronous method to define the callback method.

Return value:

The GetNotification method returns an object that contains the initial return value for the asynchronous call it started (see the following table). The actual notification information is returned by the callback method in the ReturnValue property of its result object.

Table: Return value properties for GetNotification

Property

Description

Value

TransactionID

This is a number used as an identification to match transactions started with the asynchronous GetNotification call to one or more calls it generates to callback.

 

ErrorCode

This is a number that specifies a predefined error code.

See Service API error codes.

ErrorMessage

This is a text string that describes the error.

Table: Return value properties for GetNotification callback

Property

Description

Value

ReturnValue

This is an object (a system attribute object) that contains the information for the changed system attribute.

This object contains the properties Entity and Key as well as one or more additional properties representing the system attribute value. The name and type of these properties depend on the specific system attribute and its system data type.

For example, if you request notification for the Connectivity - ConnectionStatus system attribute, whose system data type is ConnectionInfo, callback returns the following properties:

  • ReturnValue.Entity

  • ReturnValue.Key

  • ReturnValue.ConnectionStatus

  • ReturnValue.IAPID

  • ReturnValue.ConnectionType

  • ReturnValue.IAPName

  • ReturnValue.NetworkName

  • ReturnValue.IAPConnectionName

See System attributes.

ErrorCode

This is a number that specifies a predefined error code.

See Service API error codes.

ErrorMessage

This is a text string that describes the error.

Remarks:

Example code:

The following sample code illustrates how to register a callback method to receive notifications of changes in a system attribute value:

import com.nokia.lib.Service;
var sysInfo = new Service("Service.SysInfo", "ISysInfo");
var inParams = {Entity:"General", Key:"PredictiveText"};
sysInfo.GetNotification(inParams,onNotify);
function onNotify(transactionID:Number, eventID:String, outParam:Object) {
  var systemData = outParam.ReturnValue;
  var Status = systemData.Status;
}