Looking to access recent call logs using Cordova? Unfortunately, there is no official plugin available for that. However, there is still hope with a custom plugin created by someone else. You can find the plugin here. The only issue is that the creator of this plugin has stopped supporting it and it uses AngularJS in the example provided. Despite some attempts by users to use this plugin with JavaScript, there have been no successful solutions reported so far. According to the author's note on GitHub, there are 3 functions that may work with JavaScript:
window.plugins.calllog.list: retrieves recent calls - provide a day limit (e.g., 7 to view calls from the past week)
window.plugins.calllog.show: displays contact information for a specified phone number
window.plugins.calllog.contact: fetches contact details for a given phone number
I have personally tested each function and found that window.plugins.calllog.show works as intended, showing contact information based on specific numbers. Unfortunately, I encountered an issue with window.plugins.calllog.list returning "undefined". If anyone has a solution, please provide assistance. Thank you.
The code snippet in my index.html looks like this:
<button id="call_log" onclick="loadLogs();">Call Log</button>
And here's the relevant part of my app.js:
// Call log
function loadLogs() {
if (window.plugins.calllog == "undefined") {
alert("Function not working");
} else {
alert("Function working");
window.plugins.calllog.show('12345');
var list = window.plugins.calllog.list('7');
alert(list[0]);
}
}
Error: Uncaught TypeError: Cannot read property '0' of undefined