Opened 7 years ago

Closed 5 years ago

#14462 closed task (fixed)

Create a Dojo Store for PhoneGap Contacts API

Reported by: Kaoru Hosokawa Owned by: cjolif
Priority: high Milestone: 2.0
Component: DojoX Mobile Version: 1.7.1
Keywords: contactsapp 1.9 Cc: cjolif, Eric Durocher
Blocked By: Blocking:

Description (last modified by cjolif)

PhoneGap provides a set of APIs for accessing the contacts data of your mobile device. This task is to develop a Dojo Store (eg, dojo.store.contacts) which wraps the PhoneGap contacts API. This will be used by mobile applications together with PhoneGap.

Attachments (1)

dojox_MobileContacts.zip (7.4 KB) - added by Hikaru Tamura 7 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 Changed 7 years ago by cjolif

Cc: cjolif added
Description: modified (diff)
Keywords: contactsapp added

Would be very useful for the contact app. We should keep an eye as well on HTML5 contact API.

comment:2 Changed 7 years ago by Kaoru Hosokawa

We have started to design the API for contacts store. Here is a sample of how you would access the contacts.

// ...

function(ready, mobileContacts){
    ready(function(){
				
// First you create a new mobileContacts
        var contacts = new mobileContacts();

// Then you add a contact with his/her attributes.
	contacts.add({displayName : "Test User",
                      name : {familyName : "User", givenName : "Test"},
                      phoneNumbers:[{type:"home", value:"000-555-8888", pref:true}]
        });


// This is how you would retrieve all the contacts. Here, by default, the display name is searched.  
        var d = contacts.query("Test User");

// You get back a Deferred object which you can loop to get the actual contact.
        d.then(function(c){
            for(var i=0; i<c.length; i++){
                alert("Display Name = " + c[i].displayName +
                      " id =" + c[i].id +
                      " phoneNumbers=" + c[i].phoneNumbers.value);
            }
        });
    });

// ...

We have the following methods, too.

  • get(id) - this returns a contact object identified by id.
  • put(object), add(object) - these add a contact object to the store.
  • remove(id) - this deletes the object identified by id.

Comments welcome!

The question I have is how should we call it? dojox.store.mobileContacts? dojox.phonegap.store.contacts?

comment:3 Changed 7 years ago by cjolif

At some point I would say that the underlying implementation will move from PhoneGap API to HTML5 Device contacts API (or we will provide plugins for both). Also at some point it will not just be available on mobile but also on desktop. So I would favor dojox/store/Contacts (as a class it should start with a capital letter) as it will better scale in the future?

At some point we might extract the actual PhoneGap implementation to a plugin and provide an HTML5 plugin as well with a mechanism for the user to choose which one to use.

I have no specific remarks on the API which seems to nicely follow dojo/store.

Changed 7 years ago by Hikaru Tamura

Attachment: dojox_MobileContacts.zip added

comment:4 Changed 7 years ago by Hikaru Tamura

[IBM CCLA] I attached dojox_MobileContacts.zip . This is a patch for this ticket.

comment:5 Changed 7 years ago by cjolif

thanks, some remarks:

comment:6 Changed 7 years ago by cjolif

Cc: Eric Durocher added

comment:7 Changed 7 years ago by ykami

Milestone: 1.81.9
Owner: changed from ykami to cjolif
Status: newassigned

comment:8 Changed 7 years ago by Colin Snover

Milestone: 1.92.0

Current plan is that we are going from 1.8 to 2.0, so bulk reassigning and removing the 1.9 milestone so nobody tries to use it.

comment:9 Changed 7 years ago by Colin Snover

Keywords: 1.9 added

comment:10 Changed 7 years ago by cjolif

for now I have committed a refactored version of this in the future contact app demo. Let's work from there and upgrade it when fully ready (https://github.com/cjolif/dojo-contacts-app/commit/dfdf36c156cffa415647296f33b477af804bcaf2).

comment:11 Changed 5 years ago by cjolif

Something like that has been done part of dcordova project (​https://github.com/ibm-js/dcordova/blob/master/deviceReady.js) which might be a candidate for dojo 2 so closing this.

comment:12 Changed 5 years ago by cjolif

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.