Get Contact details by Id

Anonymous
2023-01-19T22:50:06.6066667+00:00

Hi,

How can I get the Contact details by its Id? like this:

var contact = await Microsoft.Maui.ApplicationModel.Communication.Contacts.Default.PickContactAsync("contact-id-here");

Thanks,

Jassim

Developer technologies | .NET | .NET MAUI
0 comments No comments
{count} votes

Answer accepted by question author
  1. Anonymous
    2023-01-20T03:18:06.78+00:00

    Hello,

    Here is Contacts source code, MAUI do not have PickContactAsync("contact-id-here"); method.

    But you can get all contacts , then query it by contact Id like following code.

     IEnumerable<Contact> contacts = await Contacts.Default.GetAllAsync();
     Contact contact= contacts.FirstOrDefault<Contact>(contact => contact.Id == "contact-id-here");
    

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.