ioscocoa-touchaddressbookabpersonviewcontrolleraddressbookui

ABPersonViewController without access to the addressbook


I am implementing an application in which the user should be able to import a contact from the address book or to provide a contact themselves. I implemented everything using https://github.com/soffes/sspersonviewcontroller . New contacts are added to the address book and everything works really well. I had all the fields and editing capabilities by using ABPersonViewController etc ...

BUT now the client insists that the contact should NOT be stored in the addressbook but in the application and that the user should NEVER be asked to grant access to the address book with the exception of the import.

I got the "import contact into app" working by using a serializer for an ABRecordRef (from https://github.com/nvrooij/Let-s-Share/blob/master/Classes/ABRecordSerializer.h )

But my biggest problem is, that ABNewPersonViewController and ABPersonViewController insist on asking the user for access to the addressbook.

So what i need:

What i already tried: Following How to Use a ABPersonViewController without connecting to AddressBook i set the displayedPerson - but the "grant access popup" still shows up.

From the docs of ABNewPersonViewController and ABPersonViewController i got the impression that subclassing and overriding the getter for the addressbook to return nil in all cases would work and i would wind up with view which has no address book. But somewhere in there (i assume the view itself) the addressbook is created again and i can't get rid of this call.

How you can help_

Any pointers to a re-implementation of ABPersonViewController (including editing capabilities) or any other hints are very welcome.

Any ideas of how to get a create user viewcontroller with all the nice things (country selection, field additions etc) are also highly welcome.

If you think my approach is completely off please also comment. I am always looking for different angles and might have dug too deep into this whole address book disaster.

I wish the controllers for creating and editing contacts would be completely decoupled from the address book and would return a ABRecordRef instead of accessing the addressbook. In my case it would highly simplify my task (a man can dream).

All the best, iosGoblin


Solution

  • I solved/circumvented the problem as follows: I dropped editing capabilities and I created a view controller which resembles ABNewPersonViewController (only some specific fields like name, surename, phone number, address). From the input i creata a ABRecordRef (helpful code at http://www.modelmetrics.com/tomgersic/iphone-programming-adding-a-contact-to-the-iphone-address-book/ ). I serialize this contact into NSUserDefaults using the ABRecordSerializer (link in my question)

    If the user imports a contact I just serialize the contact i get back from the ABPeoplePickerNavigationController into NSUserDefaults.

    If a contact is stored in NSUserDefaults I deserialize and display it.

    Recap:

    All the best, iosGoblin