Read file contacts agenda iPhone using Xamarin

8

How do I read the contact list in the iPhone phonebook using Xamarin?

I need to read the contacts list from the iPhone calendar. I do not know how to do it and I did not find material in Portuguese about it. Can anyone help me with this?

    
asked by anonymous 20.01.2014 / 00:39

1 answer

9

1 - Instantiate an ABAddressBook.

using(var addressBook = new ABAddressBook ()){ … }

2 - Call GetPeopleWithName, passing the name of the contact to search for. This method returns an array of ABPerson objects.

var people = addressBook.GetPeopleWithName ("John Doe");
people.ToList ().ForEach (
       p => Console.WriteLine ("{0} {1} - ", p.FirstName, p.LastName));

Along with GetPeopleWithName, ABAddressBook we have the GetPeople method. Using Linq, the result can be filtered based on some criteria, as shown:

var people = addressBook.GetPeople ();
people.ToList ().FindAll (p => p.LastName == "Smith").ForEach (
       p => Console.WriteLine ("{0} {1}", p.FirstName, p.LastName));

Source: link

    
20.01.2014 / 03:15