0.0.1 • Published 1 year ago
@laravelka/capacitor-contacts v0.0.1
@laravelka/capacitor-contacts
Capacitor plugin for accessing and managing device contacts.
Install
npm install @laravelka/capacitor-contacts
npx cap syncAPI
getContacts()
getContacts() => Promise<{ contacts: Contact[]; }>Returns: Promise<{ contacts: Contact[]; }>
requestPermissions()
requestPermissions() => Promise<PermissionStatus>Returns: Promise<PermissionStatus>
Interfaces
Contact
| Prop | Type |
|---|---|
id | string |
displayName | string |
phoneNumbers | PhoneNumber[] |
email | string |
photoThumbnail | string |
PhoneNumber
| Prop | Type |
|---|---|
label | string |
number | string |
PermissionStatus
| Prop | Type |
|---|---|
granted | boolean |
Usage
import { Contacts } from '@laravelka/capacitor-contacts';
// Request permissions
const requestPermissions = async () => {
const permission = await Contacts.requestPermissions();
return permission.granted;
};
// Get contacts
const getContacts = async () => {
const hasPermission = await requestPermissions();
if (!hasPermission) {
throw new Error('Permission denied');
}
const { contacts } = await Contacts.getContacts();
return contacts;
};Platform Support
- ✅ Android
- ✅ iOS
- ❌ Web (coming soon)
License
MIT
Contributing
See CONTRIBUTING.md
0.0.1
1 year ago