Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"$type" not setting correctly #149

Closed
RoastedPecans opened this issue Mar 29, 2019 · 3 comments
Closed

"$type" not setting correctly #149

RoastedPecans opened this issue Mar 29, 2019 · 3 comments

Comments

@RoastedPecans
Copy link

Hey! Great library, the only thing I haven't been able to figure out is why the generated contact card isn't differentiating between HOME/WORK email types and CELL/WORK phone types. An example of my code is below so if I'm doing something wrong it can be pointed out.

        if ($request->has('phone') and $prefPhone) {
            $phone = $request->request->get('phone');
            $vcard->addPhoneNumber($phone, 'PREF;CELL');
            $prefPhone = false;
        }

        if ($request->has('workPhone')) {
            $workPhone = $request->request->get('workPhone');
            if ($prefPhone) {
                $vcard->addPhoneNumber($workPhone, 'PREF;WORK');
            }
            else {
                $vcard->addPhoneNumber($workPhone, 'WORK');
            }
        }

        if ($request->has('email')) {
            $email = $request->request->get('email');
            $vcard->addEmail($email, 'PREF;HOME');
            $prefEmail = false;
        }

        if ($request->has('workEmail')) {
            $workEmail = $request->request->get('workEmail');
            if ($prefEmail) {
                $vcard->addEmail($workEmail, 'PREF;WORK');
            }
            else {
                $vcard->addEmail($workEmail, 'WORK');
            }
        }

The strangest part is that when I inspect the resulting .vcf in TextEdit I can see the correct encodings, for example:

TEL;PREF;CELL:123-456-7891
TEL;WORK:321-654-9872

However, when I try to view the contact file on my Mac and iPhone, the contact card contains both emails + phone numbers, but they're both just labeled as "email" and "phone" respectively. Is this another ridiculous limitation on Apple devices/has anyone else run into this issue or is it a problem on the part of the library somehow?

Thanks!

@flufab
Copy link

flufab commented Jan 12, 2021

I had the same prob and solved it by just adding TYPE= to the param:

$vcard->addPhoneNumber('+000000', 'TYPE=MAIN');

@tpinne
Copy link

tpinne commented Feb 25, 2022

According to the spec https://datatracker.ietf.org/doc/html/rfc6350#section-6.4.1 the TYPE=... is necessary. So I don't know, why it is generated without by the lib and it has to be put in manually to get correctly recognized.

@jeroendesloovere
Copy link
Owner

The current released vCard library supports vCard version 3.
@tpinne the URL shows the scheme for version 4.
That is why there is no TYPE= (I guess)

If you look into the current branches, you will see a v2.0.0 which supports vCard version 4.
Currently still WIP, would be nice if more people could help finalizing it 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants