Results 1 to 3 of 3

Thread: Contact data best practice

  1. #1
    Sencha User
    Join Date
    Dec 2010
    Posts
    83

    Default Contact data best practice

    Hello,
    I am trying to create a marketing app for iphone that uses the contacts from the user's phone. I am developing it with sencha and phonegap (cordova). I know that sencha now has a native packager, but my app will rely on a already developed plugin so it is not an option.

    I need associate qualifiers with the contacts. For instance, do you include this contact in your prospect list, does this person have startup capital, etc. This info needs to be stored on the phone.

    Currently I can pull the contacts in an array object (just the contact id, name and phone numbers). I have then been trying to save that information to a store with a localstorage proxy. The problem is on my test phone (iphone 4 with 300+ contacts) it takes 3 minutes to loop through and add them to the store. When I try to sync the store it freezes the app. This approach works fine on the desktop simulator so I am assuming I am running out of memory on the phone. A couple of times xcode has thrown a memory warning but mostly the app just freezes.

    I have thought of using webSQL for the local storage, but I have no experiance with it. Also, I am concerned about Apple rejecting the app for excessive storage on the phone.

    So, I am reaching out to the sencha community to find out what the best approach would be.

    In summary,
    I need to pull the contacts
    Put the contacts in a list (sortable by qualifiers)
    Set and save qualifiers, like use this contact, they have capital, etc. mostly boolean data
    The approach must be fast and not violate storage limits set by Apple.

    And please, don't suggest that I post this question on phonegap's forum. The phonegap code pulls the 300+ contacts in 2 seconds. It is working fine.

    Thanks

    Code:
    console.log('loadContacts called');var options = new ContactFindOptions({
        filter: "",
        multiple: true
    });
    var fields = ["name","phoneNumbers"];
    console.log('getting phone contacts...');
    navigator.contacts.find(fields, success, failure, {
        filter: "",
        multiple: true
    });
    
    
    
    
    function success(contact) {
        console.log('<start>>');
        var contactData = [];
        var contactRecord = {};
        contactStore = Ext.StoreMgr.lookup('contactStore');
    
    
        function logArrayElements(element, index, array) {
    
    
            contactRecord = {
                index: index,
                contactId: contact[index].id,
                displayName: contact[index].name.formatted,
                givenName: contact[index].name.givenName,
                familyName: contact[index].name.familyName
            };
            contactData.push(contactRecord);
        }
    
    
    
    
    
    
    
    
        contact.forEach(logArrayElements);
        console.log('<done collecting>>');
        contactStore.applyData(contactData); // <-- this takes 3 minutes to complete
      //  contactStore.sync(); <-- this locks the iphone up
        console.log('<<done applying to store>>');
    }
    
    
    function failure(contacts) {}

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,448
    Answers
    3997

    Default

    Why are you saving the contact details to localstorage when you can get them from the phone already?
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  3. #3
    Sencha User
    Join Date
    Dec 2010
    Posts
    83

    Default

    Hello,
    I really just need to save the ID # and associated extra qualifying data. I just thought saving the display name would be quicker than pulling it from the phone again when needed. I may rethink that approach. But my question is still unanswered as to what is the best local storage options for what I need.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •