简体   繁体   English

如何使用Cordova访问android中的通话记录?

[英]How to access call logs in android using Cordova?

I want to access recent call logs using Cordova but there is no official plugin for that, some guy made a custom plugin for that https://github.com/dalyc/Cordova-CallLog-Plugin is the only hope for me, but the problem is this plugin is no longer supported by its creator and it is using AngularJS in his example. 我想使用Cordova访问最近的通话记录,但是没有官方插件,有人为此定制了一个插件https://github.com/dalyc/Cordova-CallLog-Plugin是我唯一的希望,但是问题在于此插件的创建者不再支持该插件,并且在其示例中使用AngularJS。 I did my search work and found that People tried to use this plugin to use with javascript but they got no working solution. 我做了搜索工作,发现People尝试使用此插件与javascript一起使用,但没有有效的解决方案。 As the author mentioned here https://github.com/dalyc/Cordova-CallLog-Plugin/issues/4 there are 3 functions that will work with javascript. 正如作者在这里https://github.com/dalyc/Cordova-CallLog-Plugin/issues/4所提到的,有3个函数可与javascript一起使用。

window.plugins.calllog.list : get recent calls - takes a day limit e.g 7 is go back a week
window.plugins.calllog.show : show contact for specified phone number
window.plugins.calllog.contact : get contact details for specified phone number

I tried each of them and apparently window.plugins.calllog.show is working fine and it is showing contact for specific numbers. 我尝试了其中的每一个, 显然window.plugins.calllog.show工作正常 ,并且正在显示特定号码的联系方式。 But window.plugins.calllog.list did not worked for me it is returning "undefined". 但是window.plugins.calllog.list对我不起作用,它返回“未定义”。 Need help please. 请需要帮助。 Thanks in advance. 提前致谢。

my index.html contains 我的index.html包含

<button id="call_log" onclick="loadLogs();">call log</button>

my app.js contains 我的app.js包含

    //calllog
    function loadLogs() {

        if(window.plugins.calllog == "undefined"){
               alert("Doesn't works");
           }
        else
           {
                alert("works");
                window.plugins.calllog.show('12345'); 
                //this code is working and opening list of contacts having these "12345" in their phonenumber

                var list = window.plugins.calllog.list('7');
                alert(list[0]);
            }

    }

Uncaught TypeError: Cannot read property '0' of undefined 未捕获的TypeError:无法读取未定义的属性“ 0”

Here is a plugin I have made 这是我制作的插件

https://www.npmjs.com/package/callsplugin https://www.npmjs.com/package/callsplugin

you basically have to write the command 您基本上必须编写命令

cordova plugin add callsplugin

and follow the instruction you find in the project site 并按照您在项目现场中找到的说明进行操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM