Been a while since I had to deal with AddressBook framework.
I am wondering if there is a way to get some "Add to Addressbook" functionality for free when setting UIActivityViewController.activityItems
to a vCard with something like:
let vCardString = [
"BEGIN:VCARD",
"VERSION:3.0",
"N:Gump;Forrest",
"FN:Forrest Gump",
"ORG:Bubba Gump Shrimp Co.",
"TEL;TYPE=WORK,VOICE:(111) 555-1212",
"END:VCARD"
].joinWithSeparator("\n")
let vCardData = vCardString.dataUsingEncoding(NSUTF8StringEncoding)!
let vCardActivity = NSItemProvider(item: vCardData, typeIdentifier: kUTTypeVCard as String)
// URL, test,
let activityViewController = UIActivityViewController(activityItems: [vCardActivity], applicationActivities: activities)
I want to circumvent going the long way round, especially when supporting iOS 8 and 9: With AddressBook and Contacts framework I would create a person, request permission and present the view controller.
Is there a shorter way, if I "just" want to provide a way to add or share a contact via UIActivityViewController
?
Edit: The above code does not work, speaking of no corresponding iOS
activity for the system's contacts is shown. Evernote takes up and shows an activity with correct name. When added to evernote, the vCard is shown in a note with correct details.