Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Capacitor 3 + improvements #3

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9e83d8a
fix(plugin): contacts without an e-mail address are not being display…
Jul 29, 2020
47e576f
Make the plugin return the identifier as well as the lookupKey of the…
Aug 12, 2020
3a74e04
Fix Bugs, Add phone labels & Images
tnoetzel Nov 2, 2020
9b7e4e0
Handle Picker Cancellation/Dismissal
tnoetzel Dec 11, 2020
51bd0a3
adaptation to Capacitor 3
Mar 24, 2022
1c87342
adaptation to Capacitor 3
Mar 24, 2022
346ebc8
Capacitor 3 adaptation
Mar 25, 2022
49e04b1
Capacitor 3 adaptation
Mar 25, 2022
24b393e
query and return the postal addresses in Android
Mar 26, 2022
290bfd0
query and return the postal addresses in Android and iOS
Mar 26, 2022
c5f2f10
query and return the postal addresses in Android and iOS
Mar 26, 2022
44c6488
update README.md with branch installation instructions
Mar 26, 2022
7b6961e
update README.md with sample data
Mar 26, 2022
2c84cf5
update README.md with iOS plist info
Mar 26, 2022
eebb1a0
add permission check in iOS
Mar 26, 2022
74e9ca9
use Dictionary instead of JSObject
Mar 28, 2022
272ba2a
remove condition when saved call could not be loaded
Mar 28, 2022
f5cbf34
fix a bug when call id was not saved correctly during first load (whe…
Mar 28, 2022
4b8cc36
parse postalAddress' element into JSObject
Apr 3, 2022
5bfc489
parse postalAddress' element into JSObject
Apr 3, 2022
1246a7e
parse postalAddress' element into JSObject
Apr 3, 2022
423e54e
clean up console log
Apr 3, 2022
69f97b8
parse postalAddress' element into JSObject
Apr 3, 2022
97d5673
1.0.0 npm release
Apr 12, 2022
59504d8
update README.md
Apr 12, 2022
dbdd35c
update README.md
Apr 12, 2022
6f55169
update podspec
Apr 12, 2022
72a6abb
update package-lock.json
Apr 12, 2022
cde8a85
update package-lock.json
Apr 12, 2022
cebca72
upgrade to Capacitor 5
calvinckho Dec 15, 2023
f2dc584
update README.md
calvinckho Dec 15, 2023
da1f751
ios 13 instead of 11
calvinckho Dec 15, 2023
8289420
ios 13 instead of 12
calvinckho Dec 18, 2023
5b8ed25
ios 13 instead of 12
calvinckho Dec 18, 2023
5aed986
upgrade to Capacitor 6
calvinckho Apr 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
node_modules
dist
.gradle/
.idea/
build/
*.iml
local.properties
14 changes: 14 additions & 0 deletions CalvinckhoCapacitorContactPicker.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

Pod::Spec.new do |s|
s.name = 'CalvinckhoCapacitorContactPicker'
s.version = '1.0.0'
s.summary = 'Allows users to select one or many contacts from their device.'
s.license = 'MIT'
s.homepage = 'https://github.com/calvinckho/capacitor-contact-picker'
s.author = 'Sean Perkins'
s.source = { :git => 'https://github.com/calvinckho/capacitor-contact-picker', :tag => s.version.to_s }
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '13.0'
s.swift_version = '5.1'
s.dependency 'Capacitor'
end
117 changes: 93 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,111 @@
<img width="150px" src="https://user-images.githubusercontent.com/13732623/63229908-7d8a8100-c1d3-11e9-955e-31aff33d07e1.png">
</p>

# @teamhive/capacitor-contact-picker
# @calvinckho/capacitor-contact-picker

<img src="https://img.shields.io/npm/v/teamhive/capacitor-contact-picker?style=flat-square" />
<img src="https://img.shields.io/npm/v/@calvinckho/capacitor-contact-picker?style=flat-square" />

This package allows you to use the native contact picker UI on Android or iOS for receiving contact information. iOS supports selecting multiple contacts. Android only support single selection. Both platforms will return the same payload structure, where the data exists.
This capacitor plugin allows you to use the native contact picker UI on Android or iOS for single contact selection. Both platforms will return the same payload structure, where the data exists. This project is a fork of [TeamMaestro's plugin](https://github.com/TeamMaestro/capacitor-contact-picker) made for Capacitor 2. The current repo supports Capacitor 5.

## Installation

Install from NPM (release build):
```
npm install @calvinckho/capacitor-contact-picker
```
Install from Github. Make sure you insert the branch name at the end:
```
npm i git+ssh://[email protected]:calvinckho/capacitor-contact-picker#[branch name]
```

### 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:

```
yarn add @teamhive/capacitor-contact-picker
// or
npm i @teamhive/capacitor-contact-picker
Privacy - Contacts Usage Description
```

Give it a value like:

```
"We need access to your contacts in order to do something."
```

Also, on iOS it is a best practice to ask for permission twice. See [here](https://blog.prototypr.io/3-best-practices-for-in-app-permissions-dce7d36544a4).

### Android
Register the plugin class in your `MainActivity.java`:
```java
import com.teamhive.capacitor.ContactPicker;

public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
...
add(ContactPicker.class);
}
}
Add users permission in `AndroidManifest.xml`:
```
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.app">
+ <uses-permission android:name="android.permission.READ_CONTACTS" />
</manifest>
```

## Usage
## Capacitor 3+ Usage
```ts
import { Plugins } from '@capacitor/core';
import { ContactPicker } from '@calvinckho/capacitor-contact-picker';

const { ContactPicker } = Plugins;

async openPicker() {
const res = await ContactPicker.open();
// res.value is an array of contacts
try {
const contact: any = await ContactPicker.open();
/* method returns a JSON contact object or undefined if no contact was selected
sample contact object:
{
"displayName":"John Appleseed",
"contactId":"410FE041-5C4E-48DA-B4DE-04C15EA3DBAC",
"organizationName":"",
"jobTitle":"",
"emailAddresses":[{"type":"work","emailAddress":"[email protected]"}],
"givenName":"John",
"note":"College roommate",
"phoneNumbers":[{"type":"mobile","phoneNumber":"888-555-5512"},{"type":"home","phoneNumber":"888-555-1212"}],
"familyName":"Appleseed",
"postalAddresses":[{"postalCode":"30303","street":"3494 Kuhl Avenue","formattedAddress":"3494 Kuhl Avenue\nAtlanta GA 30303\nUSA","type":"work","state":"GA","city":"Atlanta","country":"USA","isoCountryCode":"us"},{"city":"Atlanta","street":"1234 Laurel Street","formattedAddress":"1234 Laurel Street\nAtlanta GA 30303\nUSA","type":"home","state":"GA","postalCode":"30303","country":"USA","isoCountryCode":"us"}],
"departmentName":"",
"nickname":""
}*/
} catch(err) {
// handle method rejection when permission is not granted
}

```
### Returned Object Properties:
```
export interface Contact {
identifier?: string;
androidContactLookupKey?: string; // Android only
contactId?: string; // iOS only
givenName?: string;
familyName?: string;
nickname?: string;
fullName?: string;
jobTitle?: string;
departmentName?: string;
organizationName?: string;
note?: string;
emailAddresses: [{
type: String,
emailAddress: String,
}]
phoneNumbers: [{
type: String,
phoneNumber: String,
}]
postalAddresses: [{
type: String,
formattedAddress: String,
street: String,
pobox: String, // Android only
neighborhood: String, // Android only
city: String,
state: String,
postalCode: String,
country: String,
isoCountryCode: String, // iOS only
subAdministrativeArea: String, // iOS only
subLocality: String, // iOS only
}]
}
```
13 changes: 0 additions & 13 deletions TeamhiveCapacitorContactPicker.podspec

This file was deleted.

Binary file not shown.
Binary file removed android/.gradle/5.6.4/fileChanges/last-build.bin
Binary file not shown.
Binary file removed android/.gradle/5.6.4/fileHashes/fileHashes.bin
Binary file not shown.
Binary file removed android/.gradle/5.6.4/fileHashes/fileHashes.lock
Binary file not shown.
Empty file.
Binary file not shown.
2 changes: 0 additions & 2 deletions android/.gradle/buildOutputCleanup/cache.properties

This file was deleted.

Binary file removed android/.gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Empty file.
Binary file removed android/.idea/caches/build_file_checksums.ser
Binary file not shown.
116 changes: 0 additions & 116 deletions android/.idea/codeStyles/Project.xml

This file was deleted.

21 changes: 0 additions & 21 deletions android/.idea/gradle.xml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading