पाठ 20 / 29
Contacts Picker API
Contacts Picker API का उपयोग करके user permission के साथ device contacts को access करें।
Contact Access Permission
Contacts Picker API users को अपने app को contact information पढ़ने के लिए permission देने देता है। Users चुनते हैं कि कौन से contacts को share करना है, privacy maintain करते हुए।
Contacts को access करें
Device contacts को user selection के साथ access करने के लिए Contacts Picker API का उपयोग करें।
const contactsButton = document.getElementById('select-contact');
contactsButton.addEventListener('click', async () => {
try {
const [contact] = await navigator.contacts.select(['name', 'email'], { multiple: false });
console.log('Selected contact:', contact);
} catch (err) {
console.error('Contacts Picker error:', err);
}
});
Output:
User can select contacts from device; app receives selected contact info.