Search code examples
iphoneiostitaniumcontacts

Titanium - how to edit contacts?


how can I edit all users on Contacts ?

I know that with Objective C it can be done with an library adress something...

someone can tell me how can I edit all users on contacts list?

Thanks


Solution

  • I do not see any way within the documentation of Titanium to modify a person directly through defined methods you were correct about that. However, if you look at the documention it provides everything you need to update a contact. First you need to get a person object from one of the following methods:

    getPeopleWithName( String name ) : Titanium.Contacts.Person[]
    getPersonByID( Number id ) : Titanium.Contacts.Person
    

    Once you have the person object you need to use the methods listed within the object

    After you make changes to the person objects you wanted to make changes to you must use the save method located here. What the function looks like:

    save( Titanium.Contacts.Person[] contacts )
    

    Also please make sure that you read the documentation well as it has a note at the top specifially for ios saying:

    iOS Platform Notes:
    On iOS, the contacts database may be modified by an external application, causing any Person or Group objects you've retrieved to be out of sync with the database. The IDs of these objects are not guaranteed to remain the same, so updating an object when it is out of sync may have unpredictable results.

    To avoid this, listen for the reload event. When you receive a reload event, you should assume that any existing Person or Group objects are invalid and reload them from the Contacts module before modifying them.

    See the examples for sample use of the reload event.