capacitor-community / capacitor-community/contacts
projection is returning more fields than expected
- Dominant language
- Java
- Stars
- 144
- Forks
- 75
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
According to the docs [here](https://capacitor-community.github.io/contacts/#/guide-retrieving-contacts?id=about-projection), if we use:
```typescript
const {contacts} = await Contacts.getContacts({
projection: {
name: true // <======
}
});
```
It will only return two properties: contactId and name. This is not what is happening, I am receiving more fields, phones.
Example:
```
[
{
"contactId": "1",
"name": {
"display": "Juan Perez",
"given": "Juan",
"family": "Perez"
},
"phones": [
{
"type": "mobile",
"number": "(809) 333-2222"
},
{
"type": "custom",
"label": "Flote",
"number": "(849) 333-2222"
}
]
},
]
```
The same thing is happening with the `pickContact()` method. Example:
```typescript
const result = await Contacts.pickContact({
projection: {
name: true
}
});
```
**Platforms**
- Android
iOS seems to be fine, but maybe you can re-validate the issue on iOS to be sure is not happening.
**To Reproduce**
Steps to reproduce the behavior:
1. Install the latest version of the plugin
2. Call `getContacts()` method with a projection with only **name**
3. Call `pickContact()` method with a projection with only **name**
**Expected behavior**
Contacts should have only a **name** object, no more than that.
Example:
```
[
{
"contactId": "1",
"name": {
"display": "Juan Perez",
"given": "Juan",
"family": "Perez"
},
},
]
```
**Screenshots**
None.
**Smartphone (please complete the following information):**
- Device: Android Emulator Nexus 6
- OS: API 31 Android 12
**Additional context**
None.
Contributor guide
Research direction
Start by inspecting the Android handling of the getContacts() and pickContact() entry points, focusing on how the name-only projection is applied. Reproduce the issue with projection set to name on Android, then verify that both methods return only contactId and name while preserving the documented iOS behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java, typescript
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100