[
https://issues.apache.org/jira/browse/RIPPLE-26?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13686532#comment-13686532
]
Ilya commented on RIPPLE-26:
----------------------------
hi, Brent.
I've found that problem while testing the following demo:
https://github.com/jasond/cordova-mega-demo , which represents main Phonegap
API.
Steps for reproducing:
1. clone that demo ([email protected]:jasond/cordova-mega-demo.git) and run it
via Ripple;
2. change cordova version to the very last one (2.8.1)
3. choose "Contacts" tab -> !contacts_demo.png|thumbnail!
4. press "search contact" button;
5. the error dialog will be shown -> !contacts_error.png|thumbnail!
While debugging I've found the root of the problem in the
"platform/cordova/2.0.0/bridge/contacts" define block.
{code:title=lines 40319 - 40388|borderStyle=solid}
_self = {
search: function (success, error, args) {
var fields = args[0],
options = args[1],
foundContacts = [],
tempContact = navigator.contacts.create(),
contacts = _get();
options = options || {};
// handle special case of ["*"] to return all fields
if (fields.length === 1 && fields[0] === "*") {
fields = utils.map(tempContact, function (v, k) {
return k;
});
}
if (fields.length > 0) {
contacts.forEach(function (contact) {
var newContact = navigator.contacts.create(contact);
if (options && (!_filtered(contact, options))) {
return;
}
utils.forEach(newContact, function (value, prop) {
if (typeof newContact[prop] !== "function" && prop !== "id"
&&
!fields.some(function (field) {
return field === prop;
})) {
delete newContact[prop];
}
});
foundContacts.push(newContact);
});
}
// TODO: don't loop over entire db just to slice the array
if (options.multiple === false) {
foundContacts = foundContacts.splice(0, 1);
}
success(foundContacts);
}
{code}
line 40323 *navigator.contacts.create()* throws the exception
(navigtor.contacts = undefined). I think that line should be replaced with
something like that:
{code}
var frame = document.getElementById("document");
frame.contentWindow.navigator.contacts.create();
{code}
It's very interesting, cause everything works like a charm with cordova
versions 2.0.0 - 2.2.0. Should I sent PR?
> [Cordova] Contacts API doesn't work with cordova (2.3.0 - 2.8.1)
> ----------------------------------------------------------------
>
> Key: RIPPLE-26
> URL: https://issues.apache.org/jira/browse/RIPPLE-26
> Project: Apache Ripple
> Issue Type: Bug
> Reporter: Ilya
> Labels: Cordova
> Attachments: contacts_demo.png, contacts_error.png
>
>
> contacts.find method (
> http://docs.phonegap.com/en/2.7.0/cordova_contacts_contacts.md.html#contacts.find)
> doesn't work in Ripple - cordova 2.3.0 - 2.7.0
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira