react-native-contacts
react-native-contacts copied to clipboard
isStarred is not working
Thanks for the library!
Android, "react": "18.2.0", "react-native-contacts": "^7.0.8",
const newContactPhone = () => {
Contacts.addContact({
familyName: 'test',
givenName: 'test',
isStarred: true,
}).then(contact => {
console.log(contact, 'CONTACTPHONE');
});
};
LOG {"company": null, "department": null, "displayName": "test test", "emailAddresses": [], "familyName": "test", "givenName": "test", "hasThumbnail": false, "imAddresses": [], "isStarred": false, "jobTitle": null, "middleName": "", "note": null, "phoneNumbers": [], "postalAddresses": [], "prefix": null, "rawContactId": "4765", "recordID": "4766", "suffix": null, "thumbnailPath": "", "urlAddresses": []} CONTACTPHONE
How is it?
looks like the starred option is never unpacked on android
import android.provider.ContactsContract.ContactOptionsColumns
https://developer.android.com/reference/android/provider/ContactsContract.ContactOptionsColumns#STARRED
@ReactMethod
public void addContact(ReadableMap contact, Promise promise) {
if (contact == null) {
promise.reject("New contact cannot be null.");
return;
}
String givenName = contact.hasKey("givenName") ? contact.getString("givenName") : null;
String middleName = contact.hasKey("middleName") ? contact.getString("middleName") : null;
String familyName = contact.hasKey("familyName") ? contact.getString("familyName") : null;
String prefix = contact.hasKey("prefix") ? contact.getString("prefix") : null;
...
https://github.com/morenoh149/react-native-contacts/blob/0258847f17b116bf38a343f2ac339606f4c76f9c/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsManager.java#L602
Hello! I might have a similar issue to address here. I noticed that the isStarred
property though present on the example contact record is not showing on the Contact
interface provided by the library:
export interface Contact {
recordID: string;
backTitle: string;
company: string|null;
emailAddresses: EmailAddress[];
displayName: string;
familyName: string;
givenName: string;
middleName: string;
jobTitle: string;
phoneNumbers: PhoneNumber[];
hasThumbnail: boolean;
thumbnailPath: string;
postalAddresses: PostalAddress[];
prefix: string;
suffix: string;
department: string;
birthday: Birthday;
imAddresses: InstantMessageAddress[]
note: string;
}
Is there a reason for this? Has this property been recently unsupported? Is it because this property is only supposed to be available on Android devices?
Thanks!
@ayelenguini its just an oversight. When we first wrote the example we did not support typescript. Ts annotations were added later by another author. isStarred should be added to the ts definition but we should also check that they are properly set when creating a new contact.
@morenoh149 and what about when requesting the contact list itself? would this property be available on the return object? is it only available on android?
@ayelenguini it's probably missing when requesting the contact list itself as well
This issue is stale, please provide more information about the status