Skip to content

feat: add pickContactField to avoid contacts permissions on Android - #12

Merged
OS-pedrogustavobilro merged 7 commits into
mainfrom
RMET-5201
Nov 23, 2026
Merged

OS-pedrogustavobilro merged 7 commits into
mainfrom
RMET-5201

Conversation

@OS-pedrogustavobilro

@OS-pedrogustavobilro OS-pedrogustavobilro commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

⚠️ 🤖 AI-assisted development with Claude Code, with manual testing done by me.

Adds pickContactField({ field }), which opens the system contact picker for a single kind of information ('phone', 'email' or 'address') and resolves with only the picked value (PickedContactField), not a full Contact. It needs no contacts permission.

  • Android: ACTION_PICK on the data-kind URI of the field, so the contacts app grants temporary read access to just the selected row. No READ_CONTACTS, and no compileSdk bump.
  • iOS: CNContactPickerViewController limited to the requested property, so the user selects one value.
  • Web: throws unimplemented, same as other methods.

Also adds the Android error OS-PLUG-CONT-0021, returned by find, save, remove and pickContact when the permissions they need aren't declared in the app's manifest (uses isPermissionDeclared, like @capacitor/geolocation).

pickContact is unchanged.

Change Type

  • Fix
  • Feature
  • Refactor
  • Breaking Change
  • Documentation
  • Other (CI, chores, etc.)

Rationale / Problems Fixed

Google Play is restricting READ_CONTACTS for apps targeting Android 17 (SDK 37), the Capacitor 9 default: https://support.google.com/googleplay/android-developer/answer/16909972#contacts-permissions

The PR targets main, because while it's technically only necessary for Capacitor 9 (2.x plugin version), there's no breaking changes that keep it from being in Capacitor 8 plugin version (1.x), and it also helps serve ODC customers better.

We could remove the contacts permissions on Capacitor 9 version (breaking change), so that users add them instead of doing the tools:node="remove". I'm not planning on doing that, but let me know if you feel otherwise.

Apps that only need to pick a phone number, email or address can use pickContactField and leave the contacts permissions out of their manifest.

Related ticket: https://outsystemsrd.atlassian.net/browse/RMET-5201

Tests or Reproductions

  • Manually tested with the example app (new pickContactField() button; the saved contact now includes an address).
  • To check that no permission is needed, remove READ_CONTACTS and WRITE_CONTACTS from the example app's manifest as shown in the README.

Platforms Affected

  • Android
  • iOS
  • Web

Notes / Comments

  • One data kind per call, and the result has no contact id (the permission-free picker doesn't expose the one used by find, save and remove).
  • README documents the method, the new error and the Play policy (:::warning is for the Docusaurus pages).
  • The example app changes include a cap migrate run to make it work with Xcode 27.

…missions

Add pickContactField({ field }) that opens the system picker restricted to one kind of information (phone, email or address) and resolves with only the picked value, its label and the contact's display name, as a new PickedContactField. It needs no contacts permission, so apps can drop READ_CONTACTS when they only use this method.

- Android: ACTION_PICK on the data-kind URI of the requested field, on every API level, with no compileSdk bump (Android 17 routes it to the new Contacts Picker)
- iOS: CNContactPickerViewController with displayedPropertyKeys and predicateForSelectionOfProperty, so the user taps a single value
- web: throws unimplemented, like the other methods
- example app: button to try the method, address on the saved contact, and explicit handling of errors that have no code
- pickContact is unchanged

References: https://outsystemsrd.atlassian.net/browse/RMET-5201
Includes UIScene migration to work on Xcode 27
Comment thread README.md

Notes:

- The plugin uses the modern **Contacts framework** (`CNContactStore`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention pickContactField here as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! Done in 0f9478d

@OS-pedrogustavobilro

Copy link
Copy Markdown
Contributor Author

Merging since I got an approval, should there be any concerns let me know post! Thanks!

@OS-pedrogustavobilro
OS-pedrogustavobilro merged commit b74d0f3 into main Nov 23, 2026
8 checks passed
@OS-pedrogustavobilro
OS-pedrogustavobilro deleted the RMET-5201 branch November 23, 2026 18:21
capacitor-bot pushed a commit that referenced this pull request Nov 23, 2026
# [1.1.0](v1.0.1...v1.1.0) (2026-11-23)

### Features

* add pickContactField to avoid contacts permissions on Android ([#12](#12)) ([b74d0f3](b74d0f3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants