简体   繁体   English

Apache Cordova联系人查找

[英]Apache Cordova ContactFind

Okay so for the past two days I've been struggling to get my first Cordova/Eclipse project up and running. 好的,在过去的两天里,我一直在努力启动并运行我的第一个Cordova / Eclipse项目。 I'm trying to retrieve the contacts from my phone, using the ful sample code provided on the Apache Cordova website. 我正在尝试使用Apache Cordova网站上提供的完整示例代码从手机中检索联系人。 http://cordova.apache.org/docs/en/2.5.0/cordova_contacts_contacts.md.html http://cordova.apache.org/docs/en/2.5.0/cordova_contacts_contacts.md.html

But it's not working. 但这不起作用。 I keep getting this error: "Uncaught ReferenceError: ContactFindOptions". 我不断收到此错误:“未捕获的ReferenceError:ContactFindOptions”。 And yes, I have included the needed plugin using the Cordova CLI. 是的,我已经使用Cordova CLI包含了所需的插件。 I also tried adding it manually, to no avail. 我也尝试过手动添加,但无济于事。

// Cordova is ready
function onDeviceReady() {
    // find all contacts with 'Bob' in any name field
    var options = **new ContactFindOptions()**;
    options.filter="Bob"; 
    var fields = ["displayName", "name"];
    navigator.contacts.find(fields, onSuccess, onError, options);
}

I also included the Cordova.js file in my btw. 我还在btw中包含了Cordova.js文件。 I'm at a complete loss here, and all I can find about this particular problem are more people asking this question, without an answer that works for me :( 我在这里完全不知所措,关于这个特殊问题,我所能找到的只是更多的人问这个问题,而没有一个对我有用的答案:(

It seems I'm supposed to answer my own question instead of putting the answer in the edit. 看来我应该回答我自己的问题,而不是将答案放入编辑中。

Okay, so I figured it out by trial and error. 好吧,所以我通过反复试验弄清楚了。 Apparently sometimes Cordova doesn't update the Cordova_plugins.js file after adding plugins with the CLI. 显然,有时在使用CLI添加插件后,Cordova不会更新Cordova_plugins.js文件。 So you need to run the 'build' command from the project folder in CLI. 因此,您需要在CLI的项目文件夹中运行“ build”命令。 So when you get the Uncaught ReferenceError warning, just check your cordova_plugins.js. 因此,当您收到Uncaught ReferenceError警告时,只需检查cordova_plugins.js。 If it's not updated do it manually! 如果尚未更新,请手动进行!

Hope I can help someone with the same issues by providing this solution, however 'green' it might be. 希望我可以通过提供此解决方案来帮助遇到相同问题的人,无论它是多么“绿色”。

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

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