How to get, filter and sort call history

This code shows how to get the Call history of Tizen mobile with filtering and sorting the history data.
//config.xml
  <tizen:privilege name="http://tizen.org/privilege/callhistory.write"/>
  <tizen:privilege name="http://tizen.org/privilege/callhistory.read"/>

//main.js
/* TEL - for all protocols with phone number addressing (PSTN, GSM, CDMA, LTE, etc. */
var ifilter = new tizen.AttributeFilter('type', 'EXACTLY', 'TEL');

/* Defines sort mode: descending on call start time */
var sortMode = new tizen.SortMode('startTime', 'DESC');
tizen.callhistory.find(onSuccess, onError, ifilter, sortMode);
function onSuccess(results) {
   console.log(results.length + ' call history item(s) found!');
   for (var i = 0; i < results.length; i++) {
   console.log(i+1);
   console.log('Duration: ' + results[i].duration);
   console.log('RemoteParty: ' + results[i].remoteParties[0].remoteParty);
   console.log('startTime: ' + results[i].startTime);
   console.log('CallingParty: ' + results[i].callingParty);
   console.log('Type: ' + results[i].type);
  }
}
function onError(error) {
   console.log(' error'+error);
}

Responses

0 Replies