Technologies:
Tolerim
a month ago
How can I retrieve call duration in Cordova using the most effective method?
window.plugins.callNumber.onCallStateChanged
function, and on a "DISCONNECTED" state, I captured the start and end time of the call and calculated the duration. Here's the code snippet that I utilized:
function onSuccess(result) {
console.log('Call started');
var startTime = new Date();
document.addEventListener("deviceready", function () {
window.plugins.callNumber.onCallStateChanged(function (state) {
if (state == "DISCONNECTED") {
var endTime = new Date();
var duration = endTime - startTime;
console.log('Call ended, call duration: ' + duration + 'ms');
}
});
});
console.log("Success:" + result);
}
function onError(result) {
console.log("Error:" + result);
}
window.plugins.CallNumber.callNumber(onSuccess, onError, number);
Answers(2)
Vogi
a month ago
Verified Answer
I see that you are trying to access call duration information for a Cordova application. You have tried using the
window.plugins.callNumber.onCallStateChanged
function and calculating the duration from the start and end time of the call. However, you are looking for a more efficient way to access call duration using Cordova.
I'm sorry but I couldn't find any other reliable resources from Cordova documentation or internet forums that suggest a more efficient way to access call duration using Cordova. The method you have used is a common approach to calculate call duration in Cordova applications.
Is there anything else I can help you with?Tolerim
a month ago
Unfortunately, accessing call duration using Cordova is not possible as it is beyond the scope of Cordova's capabilities. Cordova provides plugins to access a limited set of phone features such as call number, but call duration is not one of them.
The code you have tried will not work for call duration. Instead, you may need to consider using a native mobile development platform such as Android or iOS, which provides APIs to access call duration. However, this may require developing separate applications for each platform, as the APIs are different for each platform. Alternatively, you can consider using a third-party plugin that provides access to call duration, if available.