React-native-contacts: openContactForm familyName and givenName does not work

Created on 19 May 2018  路  10Comments  路  Source: morenoh149/react-native-contacts

Hi everyone,

I'm currently testing react-native-contacts with Android (7.0) and try to use the openContactForm() method. It works perfectly (Thanks!) except for the familyName and givenName :(
They are not displayed in the contacts app.
I also tried to use "firstName" and "lastName" but they also didn't worked.

Best regards
Andreas

bug no-issue-activity

Most helpful comment

on android versions below 8 try displayName see https://github.com/rt2zz/react-native-contacts/blob/master/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsManager.java#L268
I'll revisit if this is still a strict requirement

All 10 comments

See https://github.com/rt2zz/react-native-contacts#example-contact-record

on Android versions below 8 the entire display name is passed in the givenName field. middleName and familyName will be ""

Please doublecheck you are coding against these assumptions.

If you still have a problem please share your exact code snippet and any adb logs.

If the readme could be improved please provide suggestions or PR.

Relevant source region https://github.com/rt2zz/react-native-contacts/blob/master/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsManager.java#L225

I am facing the same Issue, My code -
contact object -

let addContact = {
                familyName: "Makhija",
                givenName: "Varun",

              phoneNumbers: [{
                    label: "mobile",
                    number: "1234567890"
                }],
            }

code to show contact form -

addContact(addContact){
Contacts.openContactForm(addContact, (err) => {
        if (err) console.log(err);

      })
}    

on android versions below 8 try displayName see https://github.com/rt2zz/react-native-contacts/blob/master/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsManager.java#L268
I'll revisit if this is still a strict requirement

@morenoh149 Thank you for your reply, I am trying on android 8, i have tried using the displayName for below 8, with no luck.

Can you please help me out with this.

I think this is a general Android bug isn't it? At least it is not working for me with Android 8.1 as well, other fields works without any problem.

I found one error in ContactsManager.java at line 223:
name.put(ContactsContract.Contacts.Data.MIMETYPE, ContactsContract.CommonDataKinds.Identity.CONTENT_ITEM_TYPE);

I guess this should be ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE. But it was not working for me with that as well.

+1, also running into this issue.

the same problem, has someone found a solution ?

check language's device, pls

Only displayName worked, android version 10.

This issue is stale, please provide more information about the status

Was this page helpful?
0 / 5 - 0 ratings