I have the following code to subscribe agent presence. Base on RingCentral API document, it should get notifed when there's incoming call. But I can only get notified when agent changes presence. But when there's incoming call, no notification.
var loadAgentInfo = function (allAgents) {
var agentIds = getAgentIds(allAgents);
if (agentIds) {
$scope.rcsdk.platform().get('/account/~/extension/' + agentIds, {}).then(function(agentRes) {
var agents = agentRes.multipart();
var subscription = $scope.rcsdk.createSubscription();
var callLogSubscription = $scope.rcsdk.createSubscription();
subscription.on(subscription.events.notification, function(msg) {
$scope.loadAgentsStatus();
});
var callLogEvents = [];
var presenceEvents = [];
for (var j = 0; j < agents.length; j++) {
var agentJson = agents[j].json();
populateAgentInfo(agentJson);
//presenceEvents.push('/account/~/extension/'+ agentJson.id + '/presence');
presenceEvents.push('/account/~/extension/'+ agentJson.id + '/presence?detailedTelephonyState=true');
}
presenceEvents.push('/account/~/presence');
subscription.setEventFilters(presenceEvents).register();
$scope.$apply();
$scope.loadAgentsStatus();
}).catch(function(agentErr) {
Notification.error({message: "Loading agent info failed!", positionY: 'top', positionX: 'center', delay: 10 * 1000});
});
}
}