Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
EinfachHans committed Oct 20, 2020
0 parents commit 1d90d01
Show file tree
Hide file tree
Showing 20 changed files with 860 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: [einfachhans] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
44 changes: 44 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Bug report
about: Report a bug to help us improve
title: "(bug):"
labels: triage
assignees: ''

---

<!--
IMPORTANT: PLEASE READ
WARNING: Failure to follow the issue template guidelines below will result in the issue being immediately closed.
-->
# Bug Report

**Current Behavior:**
<!-- A clear and concise description of what the bug is. -->

**Expected Behavior:**
<!-- Describe what the behavior should be without the bug. -->

**Steps to reproduce:**
<!-- If you are able to illustrate the bug with an example, please provide steps to reproduce. -->

**Screenshots:**
<!-- If applicable, add screenshots to help explain your problem. -->

**Environment information:**
<!-- Please supply full details of your development environment including: -->
- Cordova CLI version
- `cordova -v`
- Cordova platform version
- `cordova platform ls`
- Plugins & versions installed in project (including this plugin)
- `cordova plugin ls`
- Dev machine OS and version, e.g.
- OSX
- `sw_vers`
- Windows 10
- `winver`

**Additional information**
<!-- Add any other context about the problem here. -->
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Feature request
about: Suggest an idea for this project
title: "(feat):"
labels: triage
assignees: ''

---

<!--
WARNING: Failure to follow the issue template guidelines below will result in the issue being immediately closed.
Only feature requests should be opened here.
-->

# Feature request
<!--
Feature requests should include as much detail as possible:
- A descriptive title
- A description of the problem you're trying to solve, including why you think this is a problem
- An overview of the suggested solution
- Use case: why should this be implemented?
- If the feature changes current behavior, reasons why your solution is better
- Relevant links, e.g.
- Stack Overflow post illustrating a solution
- Code within a Github repo that illustrates a solution
- Native API documentation for proposed feature
-->
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store
.gradle
.settings
.idea
.iml
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Changelog

## 1.0.0
- Initial Release
35 changes: 35 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "cordova-plugin-contacts-x",
"version": "1.0.0",
"description": "Cordova Plugins for managing contacts",
"cordova": {
"id": "cordova-plugin-contacts-x",
"platforms": [
"android",
"ios"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/EinfachHans/cordova-plugin-contacts-x.git"
},
"keywords": [
"ecosystem:cordova",
"cordova-android",
"cordova-ios",
"contacts",
"contacts-x",
"contactsx"
],
"author": "EinfachHans",
"license": "MIT",
"main": "./src/typescript/index.js",
"types": "./src/typescript/index.d.ts",
"bugs": {
"url": "https://github.com/EinfachHans/cordova-plugin-contacts-x/issues"
},
"scripts": {
"doctoc": "doctoc readme.md --github --title '**Table of Content**' --maxlevel 2"
},
"homepage": "https://github.com/EinfachHans/cordova-plugin-contacts-x#readme"
}
44 changes: 44 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-plugin-contacts-x" version="1.0.0" xmlns="http://apache.org/cordova/ns/plugins/1.0">
<name>ContactsX</name>
<description>Cordova Plugins for managing contacts</description>

<repo>https://github.com/EinfachHans/cordova-plugin-contacts-x</repo>
<issue>https://github.com/EinfachHans/cordova-plugin-contacts-x/issues</issue>

<license>MIT</license>

<js-module name="ContactsX" src="www/contactsX.js">
<clobbers target="window.ContactsX"/>
</js-module>
<platform name="android">
<config-file parent="/*" target="res/xml/config.xml">
<feature name="ContactsX">
<param name="android-package" value="de.einfachhans.ContactsX.ContactsX"/>
</feature>
</config-file>

<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.READ_CONTACTS" />
</config-file>

<source-file src="src/android/ContactsX.java" target-dir="src/de/einfachhans/ContactsX"/>
<source-file src="src/android/ContactsXErrorCodes.java" target-dir="src/de/einfachhans/ContactsX"/>
</platform>
<platform name="ios">
<config-file parent="/*" target="config.xml">
<feature name="ContactsX">
<param name="ios-package" value="ContactsX"/>
</feature>
</config-file>
<header-file src="src/ios/ContactsX-Bridging-Header.h" />
<source-file src="src/ios/ContactsX.swift" />
<source-file src="src/ios/ContactX.swift" />

<config-file target="*-Info.plist" parent="NSContactsUsageDescription">
<string>This app requires access to the contacts to manage them.</string>
</config-file>

<dependency id="cordova-plugin-add-swift-support" version="2.0.2"/>
</platform>
</plugin>
181 changes: 181 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# ContactsX Cordova Plugin
![Maintenance](https://img.shields.io/maintenance/yes/2020)
[![npm version](https://badge.fury.io/js/cordova-plugin-contacts-x.svg)](https://badge.fury.io/js/cordova-plugin-contacts-x)

This [Cordova](https://cordova.apache.org) Plugin is for managing Contacts. Why use this Plugin and not the ["Official" one](https://github.com/apache/cordova-plugin-contacts).
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 -->
[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG_global.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LMX5TSQVMNMU6&source=url)

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.
<!-- END DONATE -->

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Content**

- [Install](#install)
- [Requirements](#requirements)
- [Android](#android)
- [iOS](#ios)
- [Environment Variables](#environment-variables)
- [iOS](#ios-1)
- [Usage](#usage)
- [Failure Callbacks](#failure-callbacks)
- [Error Codes](#error-codes)
- [Api](#api)
- [hasPermission](#haspermission)
- [requestPermission](#requestpermission)
- [find](#find)
- [Changelog](#changelog)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# 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](https://github.com/akofman/cordova-plugin-add-swift-support).

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:
```xml
<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:
```ts
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:

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

The `code` is one of the [Error Codes](#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

```js
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

```js
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

```js
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](CHANGELOG.md)
Loading

0 comments on commit 1d90d01

Please sign in to comment.