Hi,
I have developed an application using the JSCSDK I have to update presence of user when he is available/ on a call etc.
I have followed the following documentation for implementing presence automatic updates.
https://www.devconnectprogram.com/site/global/products_resources/avaya_client_sdk/programming_docs/current/javascript/communication/guide/publishing_presence.gsp
As per the guide , I saw a few problems. It says to register the self presence callback under contacts.addOnContactsServiceUnavailableCallback.
It should iteally be contacts.addOnContactsServiceAvailableCallback.
I get a success response when I update my presence, but when I check the user on Equinox, he still shows available.
I have implemented the following code
user.getContacts().addOnContactsServiceAvailableCallback(function () {
setTimeout(function () {
this.onContactsAvailableCallback(user);
}.bind(this), 3000);
}
onContactsAvailableCallback: function (user) {
var selfContact = user.getSelfContact();
selfContact.addOnPresenceChangedCallback(function (contact, selfPresence) {
console.log('Overall self presence state is ' + selfPresence.getOverallState());
this.handlePresenceChangedCallback(contact, selfPresence)
}.bind(this));
selfContact.startPresence().then(
function () {
console.log('Successfully subscribed for self presence');
},
/**
* @param {AvayaClientServices.Services.Presence.PresenceError} error
*/
function (error) {
console.error('Failed to subscribe for self presence updates', error);
}
);
// Remove this callback once it's called for the first time as we already retrieved self contact
// this._user.getContacts().removeOnContactsServiceUnavailableCallback(onContactsAvailableCallback);
},
handlePresenceChangedCallback: function (contact, selfPresence) {
this._selfPresence = selfPresence;
console.log("******* Self presence*****123", this._selfPresence);
return this._selfPresence;
},
handleManualPresence: function (state) {
setTimeout(function () {
var selfUser = this._user;
this._selfPresence.setPhoneState(state);
//this._selfPresence._setOverallState(state); Calling this API also returns success but the presence actually does not get updated
selfUser._presenceService.publishAutomaticPresence().then(
function () {
console.log('Channel (automatic) presence has been published successfully'); // I get success response
},
/**
* @param {AvayaClientServices.Services.Presence.PresenceError} error
*/
function (error) {
console.log('Failed to publish channel (automatic) presence', error);
}
);
}.bind(this), 2000);
},