public static void RefreshAddressBook() { if (AddressBook != null) { AddressBook.Dispose(); } AddressBook = new ABAddressBook(); }
public Task <Boolean> RequestPermission() { var tcs = new TaskCompletionSource <Boolean>(); if (UIDevice.CurrentDevice.CheckSystemVersion(6, 0)) { var status = ABAddressBook.GetAuthorizationStatus(); if (status == ABAuthorizationStatus.Denied || status == ABAuthorizationStatus.Restricted) { tcs.SetResult(false); } else { if (addressBook == null) { addressBook = new ABAddressBook(); provider = new ContactQueryProvider(addressBook); } if (status == ABAuthorizationStatus.NotDetermined) { addressBook.RequestAccess( (s, e) => { tcs.SetResult(s); if (!s) { addressBook.Dispose(); addressBook = null; provider = null; } }); } else { tcs.SetResult(true); } } } else { tcs.SetResult(true); } return(tcs.Task); }
public void Dispose() { addressBook.Dispose(); }