# Class: PresenceService

## Constructor

#### new PresenceService(presenceProvider)

  The class encapsulates all presence-related features available to the user.

  The presence service encapsulates such features as publishing presence, subscribing for self-presence update events, and creating presence list subscriptions to watch the presence of other users.

  The service is configured with PresenceConfiguration object created by the client application as a part of the UserConfiguration.
  In order to get the service object and leverage the available presence features User.getPresenceService() is used.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `presenceProvider` | AvayaClientServices.Providers.Interfaces.PresenceProvider |

## Methods

#### getPresenceListSubscription() → {AvayaClientServices.Services.Presence.PresenceListSubscription}

  Returns presence list subscription instance. It can be used for subscribing and watching for other users presence information.

  ##### Returns:

  { AvayaClientServices.Services.Presence.PresenceListSubscription }

#### getSelfPresence() → {AvayaClientServices.Services.Presence.SelfPresence|undefined}

  Returns self-presence object associated with the user. If the self-presence is not yet retrieved by the service, this function returns undefined.
  Once the self-presence is retrieved by the service, the onSelfPresenceReceivedCallback is invoked.

  Deprecated:
    - Yes

  ##### See:

    - {AvayaClientServices.Services.Presence.PresenceService#onSelfPresenceReceivedCallback}
    - {AvayaClientServices.User#getSelfContact}
    - {AvayaClientServices.Services.Contacts.Contact#startPresence}
    - {AvayaClientServices.Services.Contacts.Contact#getPresence}
    - {AvayaClientServices.Services.Contacts.Contact#stopPresence}

  ##### Returns:

  { AvayaClientServices.Services.Presence.SelfPresence | undefined }

#### publishAutomaticPresence() → {AvayaClientServices.Base.Promise.<(undefined|AvayaClientServices.Services.Presence.PresenceError)>}

  Publishes automatic presence properties of the local user:

  - Phone channel state
  - Video channel state
  - Enterprise instant messaging channel state

  Self-presence object properties should be updated before this function is called. Instance of self-presence object can be obtained using PresenceService.getSelfPresence() function.

  Phone, video and enterprise IM channel state can be set using SelfPresence.setPhoneState(), SelfPresence.setVideoState() and SelfPresence.setEnterpriseIMState() functions.

  To publish manual presence properties of the local user, use PresenceService.publishManualState(), PresenceService.publishLocationMode() and PresenceService.publishNote() functions.

  ##### See:

    - {AvayaClientServices.Services.Presence.PresenceService#getSelfPresence}

  ##### Returns:

  { AvayaClientServices.Base.Promise.<(undefined|AvayaClientServices.Services.Presence.PresenceError)> }

#### publishLocationMode(mode) → {AvayaClientServices.Base.Promise.<(undefined|AvayaClientServices.Services.Presence.PresenceError)>}

  Publishes the local user presence location mode to subscribers.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `mode` | AvayaClientServices.Services.Presence.PresenceLocationMode | Mode.

  ##### Returns:

  { AvayaClientServices.Base.Promise.<(undefined|AvayaClientServices.Services.Presence.PresenceError)> }

#### publishManualState(state) → {AvayaClientServices.Base.Promise.<(undefined|AvayaClientServices.Services.Presence.PresenceError)>}

  Publishes the local user manual presence state to subscribers.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `state` | AvayaClientServices.Services.Presence.PresenceManualState | State.

  ##### Returns:

  { AvayaClientServices.Base.Promise.<(undefined|AvayaClientServices.Services.Presence.PresenceError)> }

#### publishNote(note) → {AvayaClientServices.Base.Promise.<(undefined|AvayaClientServices.Services.Presence.PresenceError)>}

  Publishes the local user presence note to subscribers.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `note` | string | undefined | Note.

  ##### Returns:

  { AvayaClientServices.Base.Promise.<(undefined|AvayaClientServices.Services.Presence.PresenceError)> }

### Callbacks

#### addOnPresenceServiceAvailableCallback(callback)

  Adds new onPresenceServiceAvailableCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Presence.PresenceService#onPresenceServiceAvailableCallback |

#### addOnPresenceServiceUnavailableCallback(callback)

  Adds new onPresenceServiceUnavailableCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Presence.PresenceService#onPresenceServiceUnavailableCallback |

#### addOnSelfPresenceReceivedCallback(callback)

  Adds new onSelfPresenceReceivedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Presence.PresenceService#onSelfPresenceReceivedCallback |

  Deprecated:
    - Yes

#### removeOnPresenceServiceAvailableCallback(callback)

  Removes existing onPresenceServiceAvailableCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Presence.PresenceService#onPresenceServiceAvailableCallback |

#### removeOnPresenceServiceUnavailableCallback(callback)

  Removes existing onPresenceServiceUnavailableCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Presence.PresenceService#onPresenceServiceUnavailableCallback |

#### removeOnSelfPresenceReceivedCallback(callback)

  Removes existing onSelfPresenceReceivedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Presence.PresenceService#onSelfPresenceReceivedCallback |

  Deprecated:
    - Yes

## Type Definitions

#### onPresenceServiceAvailableCallback(presenceService)

  Interface for the callback function to be invoked when the presence service is able to handle operations.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `presenceService` | AvayaClientServices.Services.Presence.PresenceService | The presence service instance associated with the callback.

#### onPresenceServiceUnavailableCallback(presenceService)

  Interface for the callback function to be invoked when the presence service is not able to handle operations.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `presenceService` | AvayaClientServices.Services.Presence.PresenceService | The presence service instance associated with the callback.

#### onSelfPresenceReceivedCallback(presenceService, presence)

  Interface for the callback function to be invoked when presence information is received for the local user.

  This callback is deprecated and not recommended for use as it might lead to unexpected behavior.
  Instead, please get self contact using User.getSelfContact() then subscribe for presence and retrieve presence using Contact.getPresence() and Contact.getPresence() functions respectively.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `presenceService` | AvayaClientServices.Services.Presence.PresenceService | Presence service instance associated with the callback.
  `presence` | AvayaClientServices.Services.Presence.SelfPresence | Self presence information object.

  Deprecated:
    - Yes

  ##### See:

    - {AvayaClientServices.User#getSelfContact}
    - {AvayaClientServices.Services.Contacts.Contact#startPresence}
    - {AvayaClientServices.Services.Contacts.Contact#getPresence}
    - {AvayaClientServices.Services.Contacts.Contact#stopPresence}