Overwriting vCard (v4.0) with multiple contacts

74 Views Asked by At

I created a javascript that generates a .vcf file containing multiple contacts. This is correctly imported from both Android and iOS. The problem occurs following a new creation of the same file by updating a contact. The entire address book is duplicated instead of replacing the changed contacts. What information/field should I include in the script to allow the address book to be overwritten? Could you kindly give me an example of the data to be entered in the script?

What I tried: Inserted UID field (randomly generated): UID:urn:uuid;XXXXXXXXXXXXXXXXXXX

My code:

            var d = new Date();
            let ora = d.toISOString();
    
            d = ora.replace(/:/g,'');
            d = d.replace(/-/g,'');
            ora = d.substring(0,15);
            ora = ora+"Z";
    
            vCard += "BEGIN:VCARD\nVERSION:3.0\nN:"+TGNuc+" - "+GR+" "+Cognome+" "+Nome+"\nFN:"+GR+" "+Cognome+" "+Nome;
            if (TGNuc && GR){
                vCard += "\nORG:WT_"+TGNuc+"\nROLE:WT_"+TGNuc+"_"+GR;
            }
            else {
                if (TGNuc && !GR){
                    vCard += "\nORG:WT_"+TGNuc+"\nROLE:WT_"+TGNuc;
                }
                else {
                    if(!TGNuc && GR){
                        vCard += "\nORG:WT_"+GR+"\nROLE:WT_"+GR;
                    }
                }
            }
            vCard += "\nUID:urn:uuid:"+UID;
            if (nWApp) {
                vCard += "\nTEL;type=CELL:"+nWApp;
            }

            vCard += "\nREV:"+ora+"\nEND:VCARD\n";
0

There are 0 best solutions below