Created
March 13, 2013 19:26
-
-
Save anujb/5155283 to your computer and use it in GitHub Desktop.
ABAddressBook Check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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