Skip to content

Alternative to the Capacitor Community Contacts plugin

Need a robust contacts management solution for your Capacitor app? While the Capacitor Community Contacts plugin provides basic contact functionality for iOS and Android, developers seeking enhanced features, web support, and professional maintenance should consider the Capawesome Contacts plugin. This modern alternative offers comprehensive contact management with cross-platform compatibility and enterprise-grade reliability.

Introduction

The Capacitor Community Contacts plugin has served as a foundational solution for developers requiring native contact access in their Capacitor applications. It provides essential functionality for retrieving, creating, and deleting contacts across iOS and Android platforms. However, as applications become more sophisticated and development teams require more comprehensive solutions, the limitations of community-maintained plugins become apparent.

The Capawesome Contacts plugin addresses these limitations by providing a professionally maintained, feature-rich alternative that extends beyond basic contact management. With support for web platforms, advanced filtering, contact groups, and modern API design, it represents the next evolution in Capacitor contact management solutions.

Differences to Capawesome Contacts

The Capawesome Contacts plugin offers several advantages over the Capacitor Community Contacts plugin:

Cross-Platform Support: Unlike the community plugin that only supports iOS and Android, Capawesome Contacts also includes web support, allowing users to pick contacts in web applications.

Enhanced API Design: The plugin features a modern, promise-based API with comprehensive TypeScript definitions, making development more intuitive and less error-prone.

Professional Maintenance: As part of the Capawesome ecosystem, the plugin receives regular updates, security patches, and compatibility improvements with new Capacitor versions.

Advanced Features: Beyond basic CRUD operations, the plugin supports contact groups, photo management, pagination, filtering, and native contact picker integration.

Enterprise Support: Professional support and consulting services are available for teams requiring assistance with implementation or customization.

Migration from Capacitor Community Contacts

Migrating from the Capacitor Community Contacts plugin involves updating your installation and adapting your API calls to the new plugin structure.

Installation

Begin by removing the existing Capacitor Community Contacts dependency and installing the Capawesome alternative. To install the Capawesome Contacts plugin, please refer to the Installation section in the plugin documentation.

Create a contact

Contact creation patterns are streamlined in the Capawesome plugin with advanced type definitions for email addresses, phone numbers, and more.

Capacitor Community Contacts:

import { Contacts } from '@capacitor-community/contacts';

const createContact = async () => {
  const result = await Contacts.createContact({
    contact: {
      name: {
        given: 'John',
        family: 'Doe'
      },
      phones: [{
        type: 'mobile',
        number: '+1234567890'
      }],
      emails: [{
        type: 'work',
        address: 'john.doe@example.com'
      }]
    }
  });
  return result.contactId;
};

Capawesome Contacts:

import { Contacts, EmailAddressType, PhoneNumberType } from '@capawesome-team/capacitor-contacts';

const createContact = async () => {
  await Contacts.createContact({
    contact: {
      givenName: 'John',
      familyName: 'Doe',
      phoneNumbers: [{
        value: '+1234567890',
        type: PhoneNumberType.Mobile
      }],
      emailAddresses: [{
        value: 'john.doe@example.com',
        type: EmailAddressType.Work
      }]
    }
  });
};

Retrieve a contact

The Capawesome Contacts plugin offers a lot more options for retrieving contacts, including filtering and pagination. The API is designed to be more intuitive and efficient:

Capacitor Community Contacts:

import { Contacts } from '@capacitor-community/contacts';

const getContact = async (contactId: string) => {
  const { contact } = await Contacts.getContact({ contactId });
  return contact;
};

Capawesome Contacts:

import { Contacts } from '@capawesome-team/capacitor-contacts';

const getContacts = async () => {
  const { contacts } = await Contacts.getContacts({
    fields: ['id', 'givenName', 'familyName', 'phoneNumbers', 'emailAddresses'],
    limit: 100, // Limit the number of contacts retrieved
    offset: 0, // Offset for pagination
  });
  return contacts;
};

const getContactById = async (contactId: string) => {
  const { contact } = await Contacts.getContactById({ id: contactId });
  return contact;
};

Update a contact

Contact updates are not directly supported in the Capacitor Community Contacts plugin, requiring a delete and recreate pattern. This has the disadvantage of losing any existing contact IDs or associations. The Capawesome plugin simplifies this with a single method for updating contacts:

Capacitor Community Contacts:

import { Contacts } from '@capacitor-community/contacts';

const updateContact = async (contactId: string) => {
  // First, delete the existing contact
  await Contacts.deleteContact({ contactId });
  // Then, create a new contact with the updated information
  await Contacts.createContact({
    contact: {
      name: {
        given: 'Jane',
        family: 'Smith'
      }
    }
  });
};

Capawesome Contacts:

import { Contacts } from '@capawesome-team/capacitor-contacts';

const updateContact = async (contactId: string) => {
  await Contacts.updateContactById({
    id: contactId,
    contact: {
      givenName: 'Jane',
      familyName: 'Smith'
    }
  });
};

Delete a contact

Contact deletion is straightforward in both plugins, making it easy to remove contacts when needed:

Capacitor Community Contacts:

import { Contacts } from '@capacitor-community/contacts';

const deleteContact = async (contactId: string) => {
  await Contacts.deleteContact({ contactId });
};

Capawesome Contacts:

import { Contacts } from '@capawesome-team/capacitor-contacts';

const deleteContact = async (contactId: string) => {
  await Contacts.deleteContactById({ id: contactId });
};

Pick a contact

The contact picker functionality is enhanced in the Capawesome plugin, allowing for more flexible selection options:

Capacitor Community Contacts:

import { Contacts } from '@capacitor-community/contacts';

const pickContact = async () => {
  const { contact } = await Contacts.pickContact();
  return contact;
};

Capawesome Contacts:

import { Contacts } from '@capawesome-team/capacitor-contacts';

const pickContacts = async () => {
  const { contacts } = await Contacts.pickContacts({
    fields: ['id', 'givenName', 'familyName', 'phoneNumbers', 'emailAddresses'],
    multiple: false
  });
  return contacts[0];
};

Conclusion

Transitioning to the Capawesome Contacts plugin offers immediate improvements in functionality, reliability, and scalability. With enhanced API design, cross-platform support, and professional maintenance, it ensures robust contact management as your application grows. The migration is simple, with most features mapping directly to improved equivalents, while advanced capabilities like web support and contact groups prepare your app for future needs.

To stay updated with the latest updates, features, and news about Capawesome, Capacitor, and Ionic ecosystem, subscribe to the Capawesome newsletter and follow us on X (formerly Twitter).

If you need assistance with migrating from the Capacitor Community Contacts plugin or implementing the Capawesome Contacts plugin, the Capawesome team is available to help you transition smoothly to this reliable alternative. Just contact us to get started.