Correct vCard format for iOS devices?

前端 未结 2 811
鱼传尺愫
鱼传尺愫 2021-02-05 19:43

In iOS 5 and above, Apple introduced the ABPersonCreatePeopleInSourceWithVCardRepresentation method, which is pretty useful in feeding a vCard to the Address Book a

相关标签:
2条回答
  • 2021-02-05 20:26

    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

    0 讨论(0)
  • 2021-02-05 20:38

    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:user@example.com
    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.

    0 讨论(0)
提交回复
热议问题