×

Discussion Board

Results 1 to 5 of 5

Hybrid View

  1. #1
    Nokia Developer Champion
    Join Date
    Aug 2008
    Location
    Vadodara, India.
    Posts
    903

    Contact API in WP ?

    Hi,
    In my app, I want to get the contacts stored in "People Hubs" and want to get details of contact like Number, Birthdate, Anniversary , email etc.

    Is this possible ? If yes, can anybody show me APIs or sample code if any ? (I think it should be possible somehow as WhatsApp for WP using such kind of functionality )

    Thanks in advance,

    Chintan Dave.
    Nokia Developer Wiki Moderation team
    World's Greatest Speeches for Windows Phone is now available on WP Marketplace.

  2. #2
    Nokia Developer Champion
    Join Date
    Aug 2008
    Location
    Vadodara, India.
    Posts
    903

    Re: Contact API in WP ?

    I think I got the API for Contact

    http://msdn.microsoft.com/en-us/libr...v=vs.105).aspx

    Any Sample application with code available?
    Nokia Developer Wiki Moderation team
    World's Greatest Speeches for Windows Phone is now available on WP Marketplace.

  3. #3
    Registered User
    Join Date
    Mar 2013
    Location
    Egypt
    Posts
    12

    Re: Contact API in WP ?

    You Can

    This code searches for Contacts start with M

    Change "M" to String.Empty to get all contacts.

    Code:
    Contacts contacts = new Contacts();
    contacts.SearchCompleted += new EventHandler<ContactsSearchEventArgs>(contacts_SearchCompleted);
    
    contacts.SearchAsync(“M”, FilterKind.DisplayName,null);
    and
    Code:
    void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
            	{ 
                ContactList.ItemsSource = e.Results;
    
                /// get first contact
                Contact ContactOne = e.Results.FirstOrDefault();
    
                string firstname = ContactOne.CompleteName.FirstName;
                string lastname = ContactOne.CompleteName.LastName;
    
    string emailaddress = ContactOne.EmailAddresses.FirstOrDefault().EmailAddress;
    string phonenumber = ContactOne.PhoneNumbers.FirstOrDefault().PhoneNumber;
    
                bool isPinnedToStart = ContactOne.IsPinnedToStart; 
            }

  4. #4
    Registered User
    Join Date
    Jan 2013
    Posts
    34

    Re: Contact API in WP ?

    Be careful with FirstOrDefault being used without proper checks. If the enumerable yields no results, in the case of a string, the result will be null and you'll get an exception when referencing the result.

  5. #5
    Nokia Developer Champion
    Join Date
    Aug 2008
    Location
    Vadodara, India.
    Posts
    903

    Re: Contact API in WP ?

    Thanks paulo and mostafa.
    Nokia Developer Wiki Moderation team
    World's Greatest Speeches for Windows Phone is now available on WP Marketplace.

Similar Threads

  1. Replies: 5
    Last Post: 2009-06-23, 12:43
  2. Replies: 3
    Last Post: 2008-12-10, 08:54
  3. Replies: 10
    Last Post: 2008-06-05, 13:36
  4. Replies: 5
    Last Post: 2006-10-12, 13:38
  5. Replies: 3
    Last Post: 2006-10-09, 12:24

Posting Permissions

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