QuisApp / flutter_contacts

MIT License
88 stars 143 forks source link

Updating a contact does not update the socialmedia information correctly #42

Closed ORBITXX closed 2 years ago

ORBITXX commented 2 years ago

Hi,

when I update a contacts socialmedia information using the socialmedia label "custom", the information is not stored correctly on the device. The socialmedia label is changed to "aim" and the the custom label is lost if I fetch the contact after the update. Updating the socialmedia information with other labels seems to be working. The socialmedia usernames are stored correctly and updating other values like the name works fine as well. Setting custom labels on the device contact menu and fetching them with flutter_contacts works as well, thus I assume the issue is caused by the update method. Currently im testing on an Android emulator (Pixel 4, API: 30). Code example is below.

  Contact? contact = await FlutterContacts.openExternalPick();

  if (contact == null) return;
  // We need to fetch contact again with accounts (including the raw id)
  // to be able to update the contact later (required for android)
  contact = await FlutterContacts.getContact(
    contact.id,
    withAccounts: true,
    withProperties: true,
  );

  List<SocialMedia> socialMedias = [
    SocialMedia(
      "test1",
      label: SocialMediaLabel.custom,
      customLabel: "CustomLabel1",
    ),
    SocialMedia(
      "test2",
      label: SocialMediaLabel.jabber,
    ),
  ];

  contact?.socialMedias = socialMedias;

  contact?.update();

  // Output 1:
  print(contact?.socialMedias);

  if (contact == null) return;

  contact = await FlutterContacts.getContact(
    contact.id,
    withAccounts: true,
    withProperties: true,
  );

  // Output 2:
  print(contact?.socialMedias);

Output 1:

[SocialMedia(userName=test1, label=SocialMediaLabel.custom, customLabel=CustomLabel1), SocialMedia(userName=test2, label=SocialMediaLabel.jabber, customLabel=)]

Output 2:

[SocialMedia(userName=test1, label=SocialMediaLabel.aim, customLabel=), SocialMedia(userName=test2, label=SocialMediaLabel.jabber, customLabel=)]
ORBITXX commented 2 years ago

UPDATE

This problem seems to only occure on android devices. On iOS it works fine.

joachim-quis commented 2 years ago

Thanks @ORBITXX for reporting! Will be fixed in the next release.

joachim-quis commented 2 years ago

Fixed in version 1.1.3.