Get Contact details by Id

Jassim Al Rahma 1,086 Reputation points
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

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
903 questions
No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 41,651 Reputation points Microsoft Employee
    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