capacitor-community / contacts

Contacts Plugin for Capacitor

Home Page:https://capacitor-community.github.io/contacts/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing middleName in displayName on IOS

molobala opened this issue · comments

Describe the bug

The plugin does not add middleName in contact displayName

To Reproduce
Steps to reproduce the behavior:

  1. Create new capacitor project
  2. Add this plugin
  3. Fetch contact list and display diaplayName
  4. You will see the displayName does not include middleName for contacts where it exists

Expected behavior
The displayName should includegivenName,middleName, and famillyName

Screenshots

Desktop (please complete the following information):

Smartphone (please complete the following information):

  • Device: iPhone12
  • OS: iOS14.2
  • Browser safari

Additional context
Change line 68 in Plugin.swift to "displayName": "\(contact.givenName) \(contact.middleName) \(contact.familyName)", should fix the issue.

@molobala will check if android & ios have a middle name field. Thx for the additional context. That helps.

We have a big need for givenName and familyName fields. The only work around for this library is to split at the first occurrence of a space in the display name. Any updates on when this will be available?

I think it would be way better to let the user handle the concatenation. So return give name, middle name and family name all separated. In our case, we would like to fill a form where all three are separated fields.

So I just tried to setup everything locally but ran into several issues @Idrimi:

  • Files does not seem to be formatted at any time (ez fix)
  • Plugin.swift,h,m has been renamed and Xcode is unable to find them (ez fix)
  • Capacitor Plugin cannot be found in Xcode (cannot find the problem here.. :/ )

EDIT: I got it working and because I am working on #49 I will create a PR soon with additional changes to the codebase, further discussion in there about that changes.

commented

A new major of this plugin just got released as a beta version. The plugin is refactored quite a bit. Among others, the API and TypeScript definitions got improved.

It also ships with a name object (docs) with different name properties. On both Android and iOS it will also return a name.display that essentially concatenates the different name fields, with the help of native helpers of Android and iOS.

Check out the newly added docs here: https://capacitor-community.github.io/contacts

Mind you that the new version (v3 and v4) are currently still in beta. However, the beta is tested quite extensively and fairly stable. If you're willing to test it out in your project, it would be much appreciated!