Xamarin Essentials getting Full contacts

Prak 1 Reputation point
2021-01-29T04:33:58.243+00:00

I am using Xamarin Essentials (1.6.0) in my project. I am able get contacts from Android and Iphone but it is only giving me Displayname, Phonenumbers and Emails. Is there any way I can get full address stored in contacts as well?

Any help appreciated.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,297 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JessieZhang-MSFT 7,706 Reputation points Microsoft Vendor
    2021-01-29T08:10:06.083+00:00

    Hello,

    Welcome to our Microsoft Q&A platform!

    Please try to update your Xamarin.Essentials nuget to the latest version (1.6.1), then when we use the following code,we can get the full contact .

    try  
    {  
        var contact = await Contacts.PickContactAsync();  
    
        if(contact == null)  
            return;  
    
        var id = contact.Id;  
        var namePrefix = contact.NamePrefix;  
        var givenName = contact.GivenName;  
        var middleName = contact.MiddleName;  
        var familyName = contact.FamilyName;  
        var nameSuffix = contact.NameSuffix;  
        var displayName = contact.DisplayName;  
        var phones = contact.Phones; // List of phone numbers  
        var emails = contact.Emails; // List of email addresses  
    }  
    catch (Exception ex)  
    {  
        // Handle exception here.  
    }  
    

    And when we click into the source code of Contact of Xamarin.Essentials, we will find that nuget Xamarin.Essentials has expose the following fields for us:

    61704-image.png

    For more details, you can check: https://learn.microsoft.com/en-us/xamarin/essentials/contacts?tabs=android

    Best Regards,

    Jessie Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.