You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
Currently, the Capacitor Contacts Plugin allows fetching contacts with an image field, which contains the contact's image if available. However, there is no direct way to check whether a contact has an image without also retrieving the image field itself. This can lead to unnecessary memory usage and performance overhead when processing a large number of contacts.
Proposed Solution
Add a new optional field to the contact response, called hasImage. This field should be a boolean that indicates whether a contact has an image available, without returning the actual image data.
This would allow developers to:
Efficiently determine if a contact has an image.
Avoid fetching and processing image data unless explicitly required.
Performance: Reduces memory and bandwidth usage by avoiding image data when not needed.
Efficiency: Provides a lightweight alternative for apps that only need to check the presence of an image.
Flexibility: Allows developers to decide later whether to fetch the actual image, based on their application's requirements.
Implementation Details
iOS: Use the CNContactThumbnailImageDataAvailable property in the native code to set the hasImage flag.
Android: Check the photo_uri column in the ContactsContract.Contacts table to determine the presence of an image and return a corresponding boolean value.
Example Usage
Fetching contacts with hasImage:
import{Contacts}from'@capacitor-community/contacts';constgetContacts=async()=>{constresult=awaitContacts.getContacts({fields: ['id','displayName','hasImage'],// Specify fields to include});console.log(result.contacts);};getContacts();
Conclusion
Adding a hasImage flag would make the plugin more efficient and versatile, particularly for use cases where only the presence of an image is relevant. This enhancement aligns with the plugin's goal of providing optimized contact management.
Description
Currently, the Capacitor Contacts Plugin allows fetching contacts with an
image
field, which contains the contact's image if available. However, there is no direct way to check whether a contact has an image without also retrieving theimage
field itself. This can lead to unnecessary memory usage and performance overhead when processing a large number of contacts.Proposed Solution
Add a new optional field to the contact response, called
hasImage
. This field should be a boolean that indicates whether a contact has an image available, without returning the actual image data.This would allow developers to:
Suggested API
Example response:
Benefits
Implementation Details
hasImage
flag.Example Usage
Fetching contacts with hasImage:
Conclusion
Adding a
hasImage
flag would make the plugin more efficient and versatile, particularly for use cases where only the presence of an image is relevant. This enhancement aligns with the plugin's goal of providing optimized contact management.iOS (Swift) Implementation
Android (Kotlin) Implementation
The text was updated successfully, but these errors were encountered: