diff --git a/frontend/src/pages/CardPage.tsx b/frontend/src/pages/CardPage.tsx index fe12c59..d3f1698 100644 --- a/frontend/src/pages/CardPage.tsx +++ b/frontend/src/pages/CardPage.tsx @@ -55,15 +55,21 @@ export function CardPage() { if (b64 && b64.length < 60000) lines.push(`PHOTO;ENCODING=b;TYPE=${type}:${b64}`); } lines.push('END:VCARD'); + const vcard = lines.join('\r\n'); try { - const blob = new Blob([lines.join('\r\n')], { type: 'text/vcard;charset=utf-8' }); - const url = URL.createObjectURL(blob); - const a = document.createElement('a'); - a.href = url; a.download = `${card.slug}.vcf`; - document.body.appendChild(a); a.click(); a.remove(); - setTimeout(() => URL.revokeObjectURL(url), 1000); - toast('Контакт сохранён ✓'); - } catch { toast('Откройте на телефоне для сохранения'); } + const isIOS = /iP(hone|ad|od)/.test(navigator.userAgent); + if (isIOS) { + window.location.href = 'data:text/vcard;charset=utf-8,' + encodeURIComponent(vcard); + } else { + const blob = new Blob([vcard], { type: 'text/vcard;charset=utf-8' }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; a.download = `${card.slug}.vcf`; + document.body.appendChild(a); a.click(); a.remove(); + setTimeout(() => URL.revokeObjectURL(url), 1000); + } + toast('Открываю карточку контакта…'); + } catch { toast('Не удалось открыть'); } } function toast(msg: string) { const t = document.getElementById('cp-toast'); @@ -120,7 +126,7 @@ export function CardPage() { {card.product_title && (