Git Product home page Git Product logo

cordova-plugin-contacts-x's Introduction

ContactsX Cordova Plugin

Maintenance npm version

This Cordova Plugin is for managing Contacts. Why use this Plugin and not the "Official" one. Well, first: it's deprectated and no more work will be done there. Second (and more important): it uses a deprecated Library in iOS.

This Plugin is in active development!

Donate

This and other Open-Source Cordova Plugins are developed in my free time. To help ensure this plugin is kept updated, new features are added and bugfixes are implemented quickly, please donate a couple of dollars (or a little more if you can stretch) as this will help me to afford to dedicate time to its maintenance. Please consider donating if you're using this plugin in an app that makes you money, if you're being paid to make the app, if you're asking for new features or priority bug fixes.

Table of Content

Install

Requirements

  • cordova >= 9.0.0
  • cordova-android >= 9.0.0
  • ios >= 9

Android

iOS

This Plugin is developed in Swift and automaticaly adds the Plugin to Support Swift.

I developed it, testing with [email protected].

Environment Variables

iOS

The iOS platform defines:

  • NSContactsUsageDescription: This app requires access to the contacts to manage them.

You can easily change it, by configure your config.xml by:

<edit-config file="*-Info.plist" mode="merge" target="NSContactsUsageDescription">
    <string>your text</string>
</edit-config>

Usage

The plugin is available via a global variable named window.ContactsX. A TypeScript definition is included out of the Box. You can import it like this:

import ContactsX from 'cordova-plugin-contacts-x';

Failure Callbacks

If an Error appeared this Plugin returns an Object in the failureCallback, that always has the following Structure:

{
  "code": 0,
  "message": "Some additional Info"
}

The code is one of the Error Codes and always present, while the message can be empty. This is mostly something like an Exception Message.

Error Codes

The following Error Codes can be fired by this Plugin:

  • UnsupportedAction
  • WrongJsonObject
  • PermissionDenied
  • UnknownError

They can be accessed over window.ContactsX.ErrorCodes and are present in the TypeScript definition too of course.

Api

The list of available methods for this plugin is described below.

hasPermission

Parameters:

  • Success Callback
  • Error Callback
window.ContactsX.hasPermission(function(success) {
  console.log(success);
}, function (error) {
  console.error(error);
});

SuccessType:

This Method returns an Object with the following field:

  • read (boolean) has read permission

Quirks

The plan is to be able to add a write Permission in future, when i add more features. Apple only has one Permission, so in iOS read (and in future write) will be the same value.

requestPermission

Request Contact Permission

Parameters:

  • Success Callback
  • Error Callback
window.ContactsX.requestPermission(function(success) {
  console.log(success);
}, function (error) {
  console.error(error);
});

SuccessType:

Same SuccessType as hasPermission()

find

Find Contacts

Parameters:

  • Success Callback
  • Error Callback
window.ContactsX.find(function(success) {
  console.log(success);
}, function (error) {
  console.error(error);
});

SuccessType:

This Method returns an Array of Contacts with the following fields:

  • id (string) - a unique identifier
  • displayName (string) - Android only
  • firstName (string)
  • middleName (string)
  • familyName (string)
  • phoneNumbers (string[])

Changelog

The full Changelog is available here

cordova-plugin-contacts-x's People

Contributors

einfachhans avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.