Hi, so I am making an invite system for my Meteor app, the goal is to choose your friends from your contacts list and send them an SMS text with the link to the app, but I am having trouble passing the contacts from the Cordova plugin “contacts” into my blaze template, here is what I am using:
Template.invitarAmigos.helpers({
contactos: function () {
if(Meteor.isCordova){
function onSuccess(contacts){
console.log('Found ' + contacts.length + ' contacts.');
console.log(contacts);
return contacts;
};
function onError(contactError){
return null;
};
var options = new ContactFindOptions();
options.multiple = true;
var fields = ["displayName", "name"];
navigator.contacts.find(fields, onSuccess, onError, options);
}
}
});
the function is working because I can see the log in Xcode, but when I try to display them nothing appears:
<template name="invitarAmigos">
{{#ionList}}
{{#if contactos}}
Sí hay contactos
{{/if}}
{{#each contactos}}
{{#ionItem}}
Contacto
{{/ionItem}}
{{/each}}
{{/ionList}}
</template>
Do anybody knows what is wrong here? Thanks in advance!
Ok, so I fixed this doing the find of the contacts on the .render function and assigning a value to a variable Session which got returned on the helper function, hope this might help somebody.
Good to hear that you managed to get it to work! Would you be willing to share the code that you used? Trying to do pretty much the same thing right now
I think that what this is telling you is that you have the correct package, but the named changed as you can see in the documentation of the Cordova plugin here: https://www.npmjs.com/package/cordova-plugin-contacts