Correct vCard format for iOS devices?
Asked Answered
J

3

13

In iOS 5 and above, Apple introduced the ABPersonCreatePeopleInSourceWithVCardRepresentation method, which is pretty useful in feeding a vCard to the Address Book and getting back the ABRecordRefs for the persons created.

However, the Apple vCard seems to be (at least a bit) different from a standard vCard, as I have found out while trying to add standard vCards to the Address Book. Is there a page somewhere detailing what the Apple-format for a vCard should be?

Thanks!

Jenellejenesia answered 17/12, 2012 at 11:21 Comment(4)
Which .vcf files had problems for you, i.e. any specific fields, etc? The only thing I found at the moment is that vCard file size should be less than 256Kb.Sultry
@NickolayO. mostly the PHOTO field. seems like it expects a combination of formatting between vcard 2.1 and vcard 3.0.Jenellejenesia
Could you attach sample vcard file? (PS. doc says: Address Book supports vCard version 3.0.)Chairborne
As @ahmet said - if you could attach the .vcf file you've tried that would help :)Insolence
I
11

The ABPersonCreatePeopleInSourceWithVCardRepresentation docs state that vCard version 3 is the supported protocol. Unfortunately if you're having troubles with a standard vCard I'm not sure how to help - I did a fair bit of searching (that bounty is good motivation :P) and wasn't able to find any further information.

I don't have my iPhone on me to test, but this guy claims to have successfully imported the following, v2.1 vCard on an iPhone 4 using a QR scanner app (which might be using the API in question). The 3.0 spec is a superset of the 2.1 spec - can you try this vCard and let me know if it works?

BEGIN:VCARD
VERSION:2.1
N:;Company Name
FN:Company Name
ORG:Company Name
TEL;WORK;VOICE;PREF:+16045551212
TEL;WORK;FAX:+16045551213
ADR;WORK;POSTAL;PARCEL;DOM;PREF:;;123 main street;vancouver;bc;v0v0v0;canada
EMAIL;INTERNET;PREF:[email protected]
URL;WORK;PREF:http://www.example.com/
NOTE:http://www.example.com/
CATEGORIES:BUSINESS,WORK
UID:A64440FC-6545-11E0-B7A1-3214E0D72085
REV:20110412165200
END:VCARD

You can read the official 3.0 spec here and here.

As a last ditch solution, there are plenty of vCard parsers out there - it's a dead simple protocol. You could just take any of these (or write one yourself) and manually add the contact to the Address Book using ABPersonCreatePeopleInSourceWithVCardRepresentation.

Insolence answered 12/1, 2013 at 7:0 Comment(2)
@aaronsnoswell, are you aware of similar Apple documentation pertaining to vCard 4.0?Apelles
CATEGORIES:BUSINESS,WORK cannot serialization you have any solutionHoldfast
M
1

I've created a backwards compatible VCard class, that generates .vcf files. But for iOS devices < iOS 8, the class exports to .ics files (VCards are then wrapped in a VCalendar file) because thats the only way to get things working on older iOS versions!

Used by thousands of people! Check it out on GitHub

Mayst answered 31/5, 2016 at 7:45 Comment(0)
I
0

Since iOS 9 / iPadOS 9 / watchOS 2.0 / macOS 10.11 you should use the Contacts framework instead with the formatter class CNContactVCardSerialization documented at

https://developer.apple.com/documentation/contacts/cncontactsuserdefaults

Unfortunately, i no longer see a mention of the vCard version(s) that are supported.

Implausible answered 19/11, 2021 at 10:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.