Skip to content

Instantly share code, notes, and snippets.

@anujb
Created March 13, 2013 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anujb/5155283 to your computer and use it in GitHub Desktop.
Save anujb/5155283 to your computer and use it in GitHub Desktop.
ABAddressBook Check
if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0))
{
var status = ABAddressBook.GetAuthorizationStatus();
if (status == ABAuthorizationStatus.Denied || status == ABAuthorizationStatus.Restricted) {
// no address book
} else {
if (this.addressBook == null)
this.addressBook = new ABAddressBook();
if (status == ABAuthorizationStatus.NotDetermined) {
this.addressBook.RequestAccess ((success, e) => {
if (!success) {
this.addressBook.Dispose();
this.addressBook = null;
} else {
// approved
}
});
} else {
// already approved
}
}
} else {
// no check needed
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment