Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

@capacitor-community/contacts

Package Overview
Dependencies
Maintainers
40
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capacitor-community/contacts - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0-alpha.0

android/src/main/java/getcapacitor/community/contacts/BiMap.java

328

dist/esm/definitions.d.ts

@@ -0,81 +1,271 @@

import type { PermissionState } from '@capacitor/core';
export interface PermissionStatus {
contacts: PermissionState;
}
export interface ContactsPlugin {
getPermissions(): Promise<PermissionStatus>;
getContacts(): Promise<{
contacts: Contact[];
}>;
saveContact(contact: NewContact): Promise<void>;
checkPermissions(): Promise<PermissionStatus>;
requestPermissions(): Promise<PermissionStatus>;
getContact(options: GetContactOptions): Promise<GetContactResult>;
getContacts(options: GetContactsOptions): Promise<GetContactsResult>;
createContact(options: CreateContactOptions): Promise<CreateContactResult>;
deleteContact(options: DeleteContactOptions): Promise<void>;
pickContact(options: PickContactOptions): Promise<void>;
}
export interface PermissionStatus {
granted: boolean;
export declare enum PhoneType {
Home = "home",
Work = "work",
Other = "other",
Custom = "custom",
Mobile = "mobile",
FaxWork = "fax_work",
FaxHome = "fax_home",
Pager = "pager",
Callback = "callback",
Car = "car",
CompanyMain = "company_main",
Isdn = "isdn",
Main = "main",
OtherFax = "other_fax",
Radio = "radio",
Telex = "telex",
TtyTdd = "tty_tdd",
WorkMobile = "work_mobile",
WorkPager = "work_pager",
Assistant = "assistant",
Mms = "mms"
}
export interface PhoneNumber {
label?: string;
number?: string;
export declare enum EmailType {
Home = "home",
Work = "work",
Other = "other",
Custom = "custom",
Mobile = "mobile"
}
export interface EmailAddress {
label?: string;
address?: string;
export declare enum PostalAddressType {
Home = "home",
Work = "work",
Other = "other",
Custom = "custom"
}
export interface UrlAddress {
label?: string;
url?: string;
export interface Projection {
/**
* @default false
*/
name?: boolean;
/**
* @default false
*/
organization?: boolean;
/**
* @default false
*/
birthday?: boolean;
/**
* @default false
*/
note?: boolean;
/**
* @default false
*/
phones?: boolean;
/**
* @default false
*/
emails?: boolean;
/**
* @default false
*/
urls?: boolean;
/**
* @default false
*/
postalAddresses?: boolean;
/**
* Be careful! This can potentially slow down your query by a large factor.
*
* @default false
*/
image?: boolean;
}
export interface SocialProfile {
label?: string;
profile?: {
username?: string;
service?: string;
urlString?: string;
};
export interface GetContactOptions {
contactId: string;
projection: Projection;
}
export interface PostalAddress {
label?: string;
address?: {
street?: string;
city?: string;
state?: string;
postalCode?: string;
country?: string;
};
export interface GetContactResult {
contact: ContactPayload;
}
export declare enum ContactType {
Person = 0,
Organization = 1
export interface GetContactsOptions {
projection: Projection;
}
export interface Contact {
export interface GetContactsResult {
contacts: ContactPayload[];
}
export interface NamePayload {
display: string | null;
given: string | null;
middle: string | null;
family: string | null;
prefix: string | null;
suffix: string | null;
}
export interface OrganizationPayload {
company: string | null;
jobTitle: string | null;
department: string | null;
}
export interface BirthdayPayload {
day?: number | null;
month?: number | null;
year?: number | null;
}
export interface PhonePayload {
type: PhoneType;
label?: string | null;
isPrimary?: boolean | null;
number: string | null;
}
export interface EmailPayload {
type: EmailType;
label?: string | null;
isPrimary?: boolean | null;
address: string | null;
}
export interface PostalAddressPayload {
type: PostalAddressType;
label?: string | null;
isPrimary?: boolean | null;
street?: string | null;
neighborhood?: string | null;
city?: string | null;
region?: string | null;
postcode?: string | null;
country?: string | null;
}
export interface ImagePayload {
base64String?: string | null;
}
export interface ContactPayload {
contactId: string;
displayName?: string;
phoneNumbers: PhoneNumber[];
emails: EmailAddress[];
photoThumbnail?: string;
organizationName?: string;
organizationRole?: string;
birthday?: string;
/**
* Object holding the name data
*/
name?: NamePayload;
/**
* Object holding the organization data
*/
organization?: OrganizationPayload;
/**
* Birthday
*/
birthday?: BirthdayPayload | null;
/**
* Note
*/
note?: string | null;
/**
* Phones
*/
phones?: PhonePayload[];
/**
* Emails
*/
emails?: EmailPayload[];
/**
* URLs
*/
urls?: (string | null)[];
/**
* Postal Addresses
*/
postalAddresses?: PostalAddressPayload[];
/**
* Image
*/
image?: ImagePayload;
}
/**
* New contact schema.
*
* @see https://developer.apple.com/documentation/contacts/cnmutablecontact
* @see android-link...
*/
export interface NewContact {
contactType?: ContactType;
namePrefix?: string;
givenName?: string;
middleName?: string;
familyName?: string;
nameSuffix?: string;
nickname?: string;
jobTitle?: string;
departmentName?: string;
organizationName?: string;
postalAddresses?: PostalAddress[];
emailAddresses?: EmailAddress[];
urlAddresses?: UrlAddress[];
phoneNumbers?: PhoneNumber[];
birthday?: string;
note?: string;
socialProfiles?: SocialProfile[];
/** Base64 image */
image?: string;
export interface CreateContactOptions {
contact: ContactInput;
}
export interface NameInput {
given?: string | null;
middle?: string | null;
family?: string | null;
prefix?: string | null;
suffix?: string | null;
}
export interface OrganizationInput {
company?: string | null;
jobTitle?: string | null;
department?: string | null;
}
export interface BirthdayInput {
day: number;
month: number;
year?: number;
}
export interface PhoneInput {
type: PhoneType;
label?: string | null;
isPrimary?: boolean;
number: string | null;
}
export interface EmailInput {
type: EmailType;
label?: string | null;
isPrimary?: boolean;
address: string | null;
}
export interface PostalAddressInput {
type: PostalAddressType;
label?: string | null;
isPrimary?: boolean;
street?: string | null;
neighborhood?: string | null;
city?: string | null;
region?: string | null;
postcode?: string | null;
country?: string | null;
}
export interface ContactInput {
/**
* Object holding the name data
*/
name?: NameInput;
/**
* Object holding the organization data
*/
organization?: OrganizationInput;
/**
* Birthday
*/
birthday?: BirthdayInput | null;
/**
* Note
*/
note?: string | null;
/**
* Phones
*/
phones?: PhoneInput[];
/**
* Emails
*/
emails?: EmailInput[];
/**
* URLs
*/
urls?: string[];
/**
* Postal Addresses
*/
postalAddresses?: PostalAddressInput[];
}
export interface CreateContactResult {
contactId: string;
}
export interface DeleteContactOptions {
contactId: string;
}
export interface PickContactOptions {
projection: Projection;
}

@@ -1,11 +0,48 @@

// declare module "@capacitor/core" {
// interface PluginRegistry {
// Contacts: ContactsPlugin;
// }
// }
export var ContactType;
(function (ContactType) {
ContactType[ContactType["Person"] = 0] = "Person";
ContactType[ContactType["Organization"] = 1] = "Organization";
})(ContactType || (ContactType = {}));
export var PhoneType;
(function (PhoneType) {
// Home / Work
PhoneType["Home"] = "home";
PhoneType["Work"] = "work";
// Other / Custom
PhoneType["Other"] = "other";
PhoneType["Custom"] = "custom";
// Phone specific
PhoneType["Mobile"] = "mobile";
PhoneType["FaxWork"] = "fax_work";
PhoneType["FaxHome"] = "fax_home";
PhoneType["Pager"] = "pager";
PhoneType["Callback"] = "callback";
PhoneType["Car"] = "car";
PhoneType["CompanyMain"] = "company_main";
PhoneType["Isdn"] = "isdn";
PhoneType["Main"] = "main";
PhoneType["OtherFax"] = "other_fax";
PhoneType["Radio"] = "radio";
PhoneType["Telex"] = "telex";
PhoneType["TtyTdd"] = "tty_tdd";
PhoneType["WorkMobile"] = "work_mobile";
PhoneType["WorkPager"] = "work_pager";
PhoneType["Assistant"] = "assistant";
PhoneType["Mms"] = "mms";
})(PhoneType || (PhoneType = {}));
export var EmailType;
(function (EmailType) {
// Home / Work
EmailType["Home"] = "home";
EmailType["Work"] = "work";
// Other / Custom
EmailType["Other"] = "other";
EmailType["Custom"] = "custom";
// Email specific
EmailType["Mobile"] = "mobile";
})(EmailType || (EmailType = {}));
export var PostalAddressType;
(function (PostalAddressType) {
// Home / Work
PostalAddressType["Home"] = "home";
PostalAddressType["Work"] = "work";
// Other / Custom
PostalAddressType["Other"] = "other";
PostalAddressType["Custom"] = "custom";
})(PostalAddressType || (PostalAddressType = {}));
//# sourceMappingURL=definitions.js.map
import { registerPlugin } from '@capacitor/core';
const Contacts = registerPlugin('Contacts', {
web: () => import('./web').then(m => new m.ContactsPluginWeb()),
web: () => import('./web').then(m => new m.ContactsWeb()),
});

@@ -5,0 +5,0 @@ export * from './definitions';

import { WebPlugin } from '@capacitor/core';
import type { NewContact } from '.';
import type { ContactsPlugin, PermissionStatus, Contact } from './definitions';
export declare class ContactsPluginWeb extends WebPlugin implements ContactsPlugin {
constructor();
getPermissions(): Promise<PermissionStatus>;
getContacts(): Promise<{
contacts: Contact[];
}>;
saveContact(_: NewContact): Promise<void>;
import type * as Definitions from './definitions';
export declare class ContactsWeb extends WebPlugin implements Definitions.ContactsPlugin {
checkPermissions(): Promise<Definitions.PermissionStatus>;
requestPermissions(): Promise<Definitions.PermissionStatus>;
getContact(): Promise<Definitions.GetContactResult>;
getContacts(): Promise<Definitions.GetContactsResult>;
createContact(): Promise<Definitions.CreateContactResult>;
deleteContact(): Promise<void>;
pickContact(): Promise<void>;
}
declare const Contacts: ContactsPluginWeb;
export { Contacts };
import { WebPlugin } from '@capacitor/core';
export class ContactsPluginWeb extends WebPlugin {
constructor() {
super();
export class ContactsWeb extends WebPlugin {
async checkPermissions() {
throw this.unimplemented('Not implemented on web.');
}
async getPermissions() {
throw this.unimplemented('getPermissions - Not implemented on web.');
async requestPermissions() {
throw this.unimplemented('Not implemented on web.');
}
async getContact() {
throw this.unimplemented('Not implemented on web.');
}
async getContacts() {
throw this.unimplemented('getContacts - Not implemented on web.');
throw this.unimplemented('Not implemented on web.');
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async saveContact(_) {
throw this.unimplemented('saveContact - Not implemented on web.');
async createContact() {
throw this.unimplemented('Not implemented on web.');
}
async deleteContact() {
throw this.unimplemented('Not implemented on web.');
}
async pickContact() {
throw this.unimplemented('Not implemented on web.');
}
}
const Contacts = new ContactsPluginWeb();
export { Contacts };
//# sourceMappingURL=web.js.map

@@ -7,41 +7,84 @@ 'use strict';

// declare module "@capacitor/core" {
// interface PluginRegistry {
// Contacts: ContactsPlugin;
// }
// }
exports.ContactType = void 0;
(function (ContactType) {
ContactType[ContactType["Person"] = 0] = "Person";
ContactType[ContactType["Organization"] = 1] = "Organization";
})(exports.ContactType || (exports.ContactType = {}));
exports.PhoneType = void 0;
(function (PhoneType) {
// Home / Work
PhoneType["Home"] = "home";
PhoneType["Work"] = "work";
// Other / Custom
PhoneType["Other"] = "other";
PhoneType["Custom"] = "custom";
// Phone specific
PhoneType["Mobile"] = "mobile";
PhoneType["FaxWork"] = "fax_work";
PhoneType["FaxHome"] = "fax_home";
PhoneType["Pager"] = "pager";
PhoneType["Callback"] = "callback";
PhoneType["Car"] = "car";
PhoneType["CompanyMain"] = "company_main";
PhoneType["Isdn"] = "isdn";
PhoneType["Main"] = "main";
PhoneType["OtherFax"] = "other_fax";
PhoneType["Radio"] = "radio";
PhoneType["Telex"] = "telex";
PhoneType["TtyTdd"] = "tty_tdd";
PhoneType["WorkMobile"] = "work_mobile";
PhoneType["WorkPager"] = "work_pager";
PhoneType["Assistant"] = "assistant";
PhoneType["Mms"] = "mms";
})(exports.PhoneType || (exports.PhoneType = {}));
exports.EmailType = void 0;
(function (EmailType) {
// Home / Work
EmailType["Home"] = "home";
EmailType["Work"] = "work";
// Other / Custom
EmailType["Other"] = "other";
EmailType["Custom"] = "custom";
// Email specific
EmailType["Mobile"] = "mobile";
})(exports.EmailType || (exports.EmailType = {}));
exports.PostalAddressType = void 0;
(function (PostalAddressType) {
// Home / Work
PostalAddressType["Home"] = "home";
PostalAddressType["Work"] = "work";
// Other / Custom
PostalAddressType["Other"] = "other";
PostalAddressType["Custom"] = "custom";
})(exports.PostalAddressType || (exports.PostalAddressType = {}));
const Contacts$1 = core.registerPlugin('Contacts', {
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ContactsPluginWeb()),
const Contacts = core.registerPlugin('Contacts', {
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ContactsWeb()),
});
class ContactsPluginWeb extends core.WebPlugin {
constructor() {
super();
class ContactsWeb extends core.WebPlugin {
async checkPermissions() {
throw this.unimplemented('Not implemented on web.');
}
async getPermissions() {
throw this.unimplemented('getPermissions - Not implemented on web.');
async requestPermissions() {
throw this.unimplemented('Not implemented on web.');
}
async getContact() {
throw this.unimplemented('Not implemented on web.');
}
async getContacts() {
throw this.unimplemented('getContacts - Not implemented on web.');
throw this.unimplemented('Not implemented on web.');
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async saveContact(_) {
throw this.unimplemented('saveContact - Not implemented on web.');
async createContact() {
throw this.unimplemented('Not implemented on web.');
}
async deleteContact() {
throw this.unimplemented('Not implemented on web.');
}
async pickContact() {
throw this.unimplemented('Not implemented on web.');
}
}
const Contacts = new ContactsPluginWeb();
var web = /*#__PURE__*/Object.freeze({
__proto__: null,
ContactsPluginWeb: ContactsPluginWeb,
Contacts: Contacts
ContactsWeb: ContactsWeb
});
exports.Contacts = Contacts$1;
exports.Contacts = Contacts;
//# sourceMappingURL=plugin.cjs.js.map
var capacitorContacts = (function (exports, core) {
'use strict';
// declare module "@capacitor/core" {
// interface PluginRegistry {
// Contacts: ContactsPlugin;
// }
// }
exports.ContactType = void 0;
(function (ContactType) {
ContactType[ContactType["Person"] = 0] = "Person";
ContactType[ContactType["Organization"] = 1] = "Organization";
})(exports.ContactType || (exports.ContactType = {}));
exports.PhoneType = void 0;
(function (PhoneType) {
// Home / Work
PhoneType["Home"] = "home";
PhoneType["Work"] = "work";
// Other / Custom
PhoneType["Other"] = "other";
PhoneType["Custom"] = "custom";
// Phone specific
PhoneType["Mobile"] = "mobile";
PhoneType["FaxWork"] = "fax_work";
PhoneType["FaxHome"] = "fax_home";
PhoneType["Pager"] = "pager";
PhoneType["Callback"] = "callback";
PhoneType["Car"] = "car";
PhoneType["CompanyMain"] = "company_main";
PhoneType["Isdn"] = "isdn";
PhoneType["Main"] = "main";
PhoneType["OtherFax"] = "other_fax";
PhoneType["Radio"] = "radio";
PhoneType["Telex"] = "telex";
PhoneType["TtyTdd"] = "tty_tdd";
PhoneType["WorkMobile"] = "work_mobile";
PhoneType["WorkPager"] = "work_pager";
PhoneType["Assistant"] = "assistant";
PhoneType["Mms"] = "mms";
})(exports.PhoneType || (exports.PhoneType = {}));
exports.EmailType = void 0;
(function (EmailType) {
// Home / Work
EmailType["Home"] = "home";
EmailType["Work"] = "work";
// Other / Custom
EmailType["Other"] = "other";
EmailType["Custom"] = "custom";
// Email specific
EmailType["Mobile"] = "mobile";
})(exports.EmailType || (exports.EmailType = {}));
exports.PostalAddressType = void 0;
(function (PostalAddressType) {
// Home / Work
PostalAddressType["Home"] = "home";
PostalAddressType["Work"] = "work";
// Other / Custom
PostalAddressType["Other"] = "other";
PostalAddressType["Custom"] = "custom";
})(exports.PostalAddressType || (exports.PostalAddressType = {}));
const Contacts$1 = core.registerPlugin('Contacts', {
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ContactsPluginWeb()),
const Contacts = core.registerPlugin('Contacts', {
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ContactsWeb()),
});
class ContactsPluginWeb extends core.WebPlugin {
constructor() {
super();
class ContactsWeb extends core.WebPlugin {
async checkPermissions() {
throw this.unimplemented('Not implemented on web.');
}
async getPermissions() {
throw this.unimplemented('getPermissions - Not implemented on web.');
async requestPermissions() {
throw this.unimplemented('Not implemented on web.');
}
async getContact() {
throw this.unimplemented('Not implemented on web.');
}
async getContacts() {
throw this.unimplemented('getContacts - Not implemented on web.');
throw this.unimplemented('Not implemented on web.');
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async saveContact(_) {
throw this.unimplemented('saveContact - Not implemented on web.');
async createContact() {
throw this.unimplemented('Not implemented on web.');
}
async deleteContact() {
throw this.unimplemented('Not implemented on web.');
}
async pickContact() {
throw this.unimplemented('Not implemented on web.');
}
}
const Contacts = new ContactsPluginWeb();
var web = /*#__PURE__*/Object.freeze({
__proto__: null,
ContactsPluginWeb: ContactsPluginWeb,
Contacts: Contacts
ContactsWeb: ContactsWeb
});
exports.Contacts = Contacts$1;
exports.Contacts = Contacts;

@@ -48,3 +91,3 @@ Object.defineProperty(exports, '__esModule', { value: true });

}({}, capacitorExports));
})({}, capacitorExports);
//# sourceMappingURL=plugin.js.map
{
"name": "@capacitor-community/contacts",
"version": "2.0.0",
"version": "3.0.0-alpha.0",
"description": "Contacts Plugin for Capacitor",

@@ -16,3 +16,3 @@ "main": "dist/plugin.cjs.js",

],
"author": "Jonathan Gerber",
"author": "",
"license": "MIT",

@@ -33,36 +33,37 @@ "repository": {

"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin && cd ..",
"verify:android": "cd android && ./gradlew clean build test && cd ..",
"verify:web": "npm run build",
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix",
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
"eslint": "eslint . --ext ts",
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
"swiftlint": "node-swiftlint",
"docgen": "docgen --api ContactsPlugin --output-readme README.md --output-json dist/docs.json",
"docgen": "docgen --api ContactsPlugin --output-readme ./docs/api.md",
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
"clean": "rimraf ./dist",
"watch": "tsc --watch",
"prepublishOnly": "npm run build",
"prepare": "npm run build"
"prepublishOnly": "npm run build"
},
"devDependencies": {
"@capacitor/android": "^4.0.0",
"@capacitor/core": "^4.0.0",
"@capacitor/docgen": "^0.0.10",
"@capacitor/ios": "^4.0.0",
"@capacitor/android": "^3.0.0",
"@capacitor/core": "^3.0.0",
"@capacitor/docgen": "^0.0.18",
"@capacitor/ios": "^3.0.0",
"@commitlint/cli": "^17.3.0",
"@commitlint/config-conventional": "^17.3.0",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "^1.0.1",
"@ionic/swiftlint-config": "^1.1.2",
"all-contributors-cli": "^6.20.0",
"eslint": "^7.11.0",
"prettier": "~2.3.0",
"prettier-plugin-java": "~1.0.2",
"husky": "^8.0.2",
"prettier": "~2.2.0",
"prettier-plugin-java": "~1.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.32.0",
"swiftlint": "^1.0.1",
"typescript": "~4.1.5"
"typescript": "~4.0.3"
},
"peerDependencies": {
"@capacitor/core": "^4.0.0"
"@capacitor/core": "^3.0.0"
},

@@ -69,0 +70,0 @@ "prettier": "@ionic/prettier-config",

@@ -1,373 +0,42 @@

<p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p>
<h3 align="center">Contacts</h3>
<p align="center"><strong><code>@capacitor-community/contacts</code></strong></p>
<p align="center">
Capacitor community plugin for fetching contacts.
<img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" />
</p>
<h3 id="home" align="center">Contacts</h3>
<p align="center"><strong><code>@capacitor-community/contacts</code></strong></p>
<p align="center">Capacitor Plugin for accessing Contacts.</p>
<p align="center">
<img src="https://img.shields.io/badge/supported%20capacitor%20versions-v3%20and%20v4-blue?logo=Capacitor&style=flat-square" />
<img src="https://img.shields.io/maintenance/yes/2022?style=flat-square" />
<a href="https://github.com/capacitor-community/contacts/actions?query=workflow%3A%22Test+and+Build+Plugin%22"><img src="https://img.shields.io/github/workflow/status/capacitor-community/contacts/Test%20and%20Build%20Plugin?style=flat-square" /></a>
<a href="https://www.npmjs.com/package/@capacitor-community/contacts"><img src="https://img.shields.io/npm/l/@capacitor-community/contacts?style=flat-square" /></a>
<a href="https://www.npmjs.com/package/@capacitor-community/contacts">
<img src="https://img.shields.io/npm/l/@capacitor-community/contacts?style=flat-square" />
</a>
<br>
<a href="https://www.npmjs.com/package/@capacitor-community/contacts"><img src="https://img.shields.io/npm/dw/@capacitor-community/contacts?style=flat-square" /></a>
<a href="https://www.npmjs.com/package/@capacitor-community/contacts"><img src="https://img.shields.io/npm/v/@capacitor-community/contacts?style=flat-square" /></a>
<a href="https://www.npmjs.com/package/@capacitor-community/contacts">
<img src="https://img.shields.io/npm/dw/@capacitor-community/contacts?style=flat-square" />
</a>
<a href="https://www.npmjs.com/package/@capacitor-community/contacts">
<img src="https://img.shields.io/npm/v/@capacitor-community/contacts?style=flat-square" />
</a>
</p>
## Maintainers
## Purpose
| Maintainer | GitHub | Social | Sponsoring Company |
| ------------------------------------ | -------------------------------------------------------------------------------------------- | ---------------------------- | ------------------ |
| Jonathan Gerber / Byrds & Bytes GmbH | [idrimi](https://github.com/idrimi) / [Byrds & Bytes GmbH](https://github.com/byrdsandbytes) | [byrds.ch](https://byrds.ch) | Byrds & Bytes GmbH |
This plugin enables you to access the native contacts APIs of iOS and Android. It allows you to retrieve, create and delete contacts.
Maintenance Status: Actively Maintained
## Documentation
## Demo
Extensive documentation is available [here](https://capacitor-community.github.io/capacitor-contacts/).
You can find a working Ionic App using the Byrds' Capacitor Contacts plugin here:
https://github.com/byrdsandbytes/capContactsDemo
## Shortcuts
## Prerequisites
- [Documentation homepage](https://capacitor-community.github.io/capacitor-contacts/)
Setup your project with Capacitor. For details check here: https://capacitorjs.com
- [Installation](https://capacitor-community.github.io/capacitor-contacts/#/getting-started/installation)
```sh
cd my-app
npm install --save @capacitor/core @capacitor/cli
```
- [API reference](https://capacitor-community.github.io/capacitor-contacts/#/api)
Initialize Capacitor
```sh
npx cap init
```
Add the platforms you want to use.
```sh
npx cap add android
npx cap add ios
npx cap add electron
```
## Installation
Install:
```sh
npm i --save @capacitor-community/contacts
# or yarn
yarn add @capacitor-community/contacts
# or pnpm
pnpm add @capacitor-community/contacts
```
Sync:
```sh
npx cap sync
```
### iOS
For iOS you need to set a usage description in your info.plist file. (Privacy Setting)
Open xCode search for your info.plist file and press the tiny "+". Add the following entry:
```
Privacy - Contacts Usage Description
```
Give it a value like:
```
"We need access to your contacts in order to do something."
```
### Android Notes
For Android you have to add the permissions in your AndroidManifest.xml. Add the following permissions before the closing of the "manifest" tag.
```xml
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
```
Next import the capContacts class to your MainActivity
```java
// Initializes the Bridge
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
add(Contacts.class);
}});
```
Make sure to import it properly as well.
```java
import ch.byrds.capacitor.contacts.Contacts;
```
**NOTE**: On Android you have to ask for permission first, before you can fetch the contacts. Use the `getPermissions()` method before you try to fetch contacts using `getContacts()`.
## Usage / Examples
You have the following Methods available:
```ts
export interface ContactsPlugin {
getPermissions(): Promise<PermissionStatus>;
getContacts(): Promise<{contacts: Contact[]}>;
saveContact(contact: NewContact): Promise<void>;
}
```
If you're considering to use this plugin you most likely want to retrieve contacts a users contacts:
Import the Plugin in your TS file:
```ts
import { Contacts } from '@capacitor-community/contacts'
```
Next use it and console log the result:
```ts
Contacts.getContacts().then(result => {
console.log(result);
for (const contact of result.contacts) {
console.log(contact);
}
});
```
That's it. Do Whatever you want with the retrieved contacts.
If you're trying to build something like "contacts matching" based on phone numbers, recommends using google [libphonenumber](https://www.npmjs.com/package/google-libphonenumber) based library [awesome-phonenumber](https://www.npmjs.com/package/awesome-phonenumber).
In order to match them properly you need to format them before you can match or store them properly.
### Interfaces
```ts
export interface PermissionStatus {
granted: boolean;
}
export interface Contact {
contactId: string;
displayName?: string;
phoneNumbers: PhoneNumber[];
emails: EmailAddress[];
photoThumbnail?: string;
organizationName?: string;
organizationRole?: string;
birthday?: string;
}
export interface PhoneNumber {
label?: string;
number?: string;
}
export interface EmailAddress {
label?: string;
address?: string;
}
```
## Built With
- Swift 5
- Java
- Angular
- Capacitor
## Authors
- Jonathan Gerber ([idrimi](https://github.com/idrimi))
## License
MIT
## Contributors
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://github.com/Idrimi"><img src="https://avatars0.githubusercontent.com/u/24573405?v=4?s=100" width="100px;" alt=""/><br /><sub><b>idrimi</b></sub></a><br /><a href="https://github.com/capacitor-community/contacts/commits?author=Idrimi" title="Code">πŸ’»</a></td>
<td align="center"><a href="https://github.com/tafelnl"><img src="https://avatars2.githubusercontent.com/u/35837839?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tafel</b></sub></a><br /><a href="https://github.com/capacitor-community/contacts/commits?author=tafelnl" title="Code">πŸ’»</a></td>
<td align="center"><a href="http://ionicframework.com/"><img src="https://avatars3.githubusercontent.com/u/11214?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Max Lynch</b></sub></a><br /><a href="https://github.com/capacitor-community/contacts/commits?author=mlynch" title="Documentation">πŸ“–</a> <a href="#eventOrganizing-mlynch" title="Event Organizing">πŸ“‹</a></td>
<td align="center"><a href="https://github.com/david-garzon-adl"><img src="https://avatars0.githubusercontent.com/u/45822796?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David Javier Garzon Carrillo</b></sub></a><br /><a href="https://github.com/capacitor-community/contacts/commits?author=david-garzon-adl" title="Code">πŸ’»</a></td>
<td align="center"><a href="https://github.com/vhinic"><img src="https://avatars.githubusercontent.com/u/244439?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vladimir HiniΔ‡</b></sub></a><br /><a href="https://github.com/capacitor-community/contacts/commits?author=vhinic" title="Code">πŸ’»</a></td>
<td align="center"><a href="https://t.me/reslear"><img src="https://avatars.githubusercontent.com/u/12596485?v=4?s=100" width="100px;" alt=""/><br /><sub><b>reslear</b></sub></a><br /><a href="https://github.com/capacitor-community/contacts/commits?author=reslear" title="Documentation">πŸ“–</a></td>
<td align="center"><a href="https://marvin.digital/"><img src="https://avatars.githubusercontent.com/u/11534760?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Marvin Heilemann</b></sub></a><br /><a href="https://github.com/capacitor-community/contacts/commits?author=muuvmuuv" title="Code">πŸ’»</a> <a href="https://github.com/capacitor-community/contacts/commits?author=muuvmuuv" title="Documentation">πŸ“–</a></td>
</tr>
</table>
<!-- markdownlint-restore -->
<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
## API
<docgen-index>
* [`getPermissions()`](#getpermissions)
* [`getContacts()`](#getcontacts)
* [`saveContact(...)`](#savecontact)
* [Interfaces](#interfaces)
* [Enums](#enums)
</docgen-index>
<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
### getPermissions()
```typescript
getPermissions() => any
```
**Returns:** <code>any</code>
--------------------
### getContacts()
```typescript
getContacts() => any
```
**Returns:** <code>any</code>
--------------------
### saveContact(...)
```typescript
saveContact(contact: NewContact) => any
```
| Param | Type |
| ------------- | ------------------------------------------------- |
| **`contact`** | <code><a href="#newcontact">NewContact</a></code> |
**Returns:** <code>any</code>
--------------------
### Interfaces
#### PermissionStatus
| Prop | Type |
| ------------- | -------------------- |
| **`granted`** | <code>boolean</code> |
#### Contact
| Prop | Type |
| ---------------------- | ------------------- |
| **`contactId`** | <code>string</code> |
| **`displayName`** | <code>string</code> |
| **`phoneNumbers`** | <code>{}</code> |
| **`emails`** | <code>{}</code> |
| **`photoThumbnail`** | <code>string</code> |
| **`organizationName`** | <code>string</code> |
| **`organizationRole`** | <code>string</code> |
| **`birthday`** | <code>string</code> |
#### PhoneNumber
| Prop | Type |
| ------------ | ------------------- |
| **`label`** | <code>string</code> |
| **`number`** | <code>string</code> |
#### EmailAddress
| Prop | Type |
| ------------- | ------------------- |
| **`label`** | <code>string</code> |
| **`address`** | <code>string</code> |
#### NewContact
New contact schema.
| Prop | Type | Description |
| ---------------------- | --------------------------------------------------- | ------------ |
| **`contactType`** | <code><a href="#contacttype">ContactType</a></code> | |
| **`namePrefix`** | <code>string</code> | |
| **`givenName`** | <code>string</code> | |
| **`middleName`** | <code>string</code> | |
| **`familyName`** | <code>string</code> | |
| **`nameSuffix`** | <code>string</code> | |
| **`nickname`** | <code>string</code> | |
| **`jobTitle`** | <code>string</code> | |
| **`departmentName`** | <code>string</code> | |
| **`organizationName`** | <code>string</code> | |
| **`postalAddresses`** | <code>{}</code> | |
| **`emailAddresses`** | <code>{}</code> | |
| **`urlAddresses`** | <code>{}</code> | |
| **`phoneNumbers`** | <code>{}</code> | |
| **`birthday`** | <code>string</code> | |
| **`note`** | <code>string</code> | |
| **`socialProfiles`** | <code>{}</code> | |
| **`image`** | <code>string</code> | Base64 image |
#### PostalAddress
| Prop | Type |
| ------------- | ------------------------------------------------------------------------------------------------------- |
| **`label`** | <code>string</code> |
| **`address`** | <code>{ street?: string; city?: string; state?: string; postalCode?: string; country?: string; }</code> |
#### UrlAddress
| Prop | Type |
| ----------- | ------------------- |
| **`label`** | <code>string</code> |
| **`url`** | <code>string</code> |
#### SocialProfile
| Prop | Type |
| ------------- | ------------------------------------------------------------------------- |
| **`label`** | <code>string</code> |
| **`profile`** | <code>{ username?: string; service?: string; urlString?: string; }</code> |
### Enums
#### ContactType
| Members |
| ------------------ |
| **`Person`** |
| **`Organization`** |
</docgen-api>
<!-- - [Examples](https://github.com/capacitor-community/contacts-examples) -->

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc