locked
saving contact object in metro apps

    Question

  • I am creating a contact object at runtime in a metro app and would like to save the object back..like done in phone apps. tried using contactpickerUI but get an error on calling addcontact....

    appreciate your help on this.

    var

    addContactResult = Windows.ApplicationModel.Contacts.Provider.ContactPickerUI().addContact(myContact.id, myContact);

    switch

    (addContactResult) {

                       

    caseWindows.ApplicationModel.Contacts.Provider.AddContactResult.added:

    ............

    gets an error on above line

    0x800a13ef - JavaScript runtime error: Windows.ApplicationModel.Contacts.Provider.ContactPickerUI: type is not constructible

    any idea the reason for it.

    also like contact application on phone does metro apps stores the contact in people app or its own storage area.


    thanks & regards chandresh soni



    Tuesday, September 18, 2012 6:28 AM

All replies

  • Have you looked at this sample (Contact Picker App):

    http://code.msdn.microsoft.com/windowsapps/Contact-Picker-App-sample-fc6677a1


    Dave Paquette @Dave_Paquette www.davepaquette.com

    Tuesday, September 18, 2012 5:54 PM
  • yes I did but could not understand how contactPickerUI gets the control. I tried get the hold of contactPickerUI on a new blank javascript project. in my project I have default.html and default.js (standard files) and in default.js I add below code but unfortunately on ready event does not fire.

    (

    function() {

       

    "use strict";

       

    varcontactPickerUI;

       

    varpage = WinJS.UI.Pages.define("/default.html", {

            processed:

    function(element, uri) {

               

    // During an initial activation this event is called before the system splash screen is torn down.


            },

            ready:

    function(element, options) {

               

    // During an initial activation this event is called after the system splash screen is torn down.


               

    // Do any initialization work that is not related to getting the initial UI setup.


                contactPickerUI = options.contactPickerUI;

            },

            unload:

    function() {

               

            }

        });

    })();

    any idea how to get the contactPickerUI so that I could call its addContract method to add new contacts. appreciate your help again


    thanks & regards chandresh soni

    Thursday, September 20, 2012 11:39 AM