Xamarin ios: ABAddressbook.Create siempre nulo, no puede solicitar acceso

Tengo un problema con la request de acceso a la Libreta de direcciones, porque ABAddressbook.Create siempre es nulo.

Entonces, ¿cómo puedo solicitar el acceso?

NSError err = new NSError (); ABAddressBook ab = ABAddressBook.Create(out err) ab.RequestAccess (delegate {}); //ab always null 

Gracias por la ayuda.

Si es null , algo salió mal y su NSError debería indicarle qué es (por cierto, no es necesario inicializar un parámetro de out ).

En general (iOS6 +), su código debería ser similar a:

 NSError err; var ab = ABAddressBook.Create (out err); if (err != null) { // process error return; } // if the app was not authorized then we need to ask permission if (ABAddressBook.GetAuthorizationStatus () != ABAuthorizationStatus.Authorized) { ab.RequestAccess (delegate (bool granted, NSError error) { if (error != null) { // process error } else if (granted) { // permission now granted -> use the address book } }); } else { // permission already granted -> use the address book } 

Aquí está mi fórmula para lidiar con esta situación.

 private void RequestAddressBookAccess () { NSError error; ABAddressBook addressBook = ABAddressBook.Create (out error); if (error != null || addressBook == null) ShowAddressBookAccessInstructions (); else if (ABAddressBook.GetAuthorizationStatus () != ABAuthorizationStatus.Authorized) { addressBook.RequestAccess (delegate(bool granted, NSError err) { if (granted && err == null) this.InvokeOnMainThread (() => DoStuff (addressBook)); else ShowAddressBookAccessInstructions (); }); } else DoStuff (addressBook); } private void ShowAddressBookAccessInstructions () { UIAlertView alert = new UIAlertView ("Cannot Access Contacts", "Go to Settings -> Privacy -> Contacts and allow this app to access your contacts to use this functionality", null, "Ok", null); alert.Show(); }