fluttercommunity / flutter_contacts

Contacts Service - A Flutter plugin to retrieve and manage contacts on Android and iOS devices. Maintainer: @lukasgit
https://pub.dev/packages/contacts_service
MIT License
153 stars 69 forks source link

Add contact isn't working. #3

Closed bucketclan closed 6 years ago

bucketclan commented 6 years ago

I tried to add a contact, but calling the provided function does nothing i.e nothing happens. I am sure that the function inside the package is being called upto the dart code which defines the same.

I making using of this package to get contacts which works perfectly.

clovisnicolas commented 6 years ago

Are you on Android or iOS? Are the FirstName & LastName properties filled when you add the contact ?

bucketclan commented 6 years ago

I am on Android. No, nothing is pre-filled. I wouldn't want it to be pre-filled.

clovisnicolas commented 6 years ago

when you call : await ContactsService.addContact(newContact); the newContact does not have a LastName or FirstName ?

bucketclan commented 6 years ago

Yup. await ContactsService.addContact(new Contact());

clovisnicolas commented 6 years ago

That is the problem, you cannot add an empty contact. In your android contacts app, if you add a new contact, do not enter any information and press "Save", the contact is not added because it does not have any information. I should add it to the readme.

bucketclan commented 6 years ago

Tried await ContactsService.addContact(new Contact(givenName: "h", familyName: "b")); too. Doesn't it open the add contact page of the phone's contact app?

clovisnicolas commented 6 years ago

this is working for me await ContactsService.addContact(new Contact(givenName: "a", familyName: "b")); Can you make sure contact permissions are enabled ? If so, tell me what is your device & android version, i'll try to reproduce the issue

bucketclan commented 6 years ago

The contact permissions are enabled. Android Version: 5.1 Model Number: Moto G

Also can you please let me know, whether the add contacts screen is opened or does it directly add to the contacts?

clovisnicolas commented 6 years ago

It adds the contact directly to your contact list So if you open your contacts app you should be able to see it.

clovisnicolas commented 6 years ago

Just tried on a 5.1.1 tablet it's working fine. Can you try to run the sample, add a contact, fill in the first & last name in the form, save, open the contacts app and see if it's in there ?

bucketclan commented 6 years ago

Tried the sample app, add contacts works well. I really wanted it to open the add contacts screen of the contacts. Thanks for the help and for the package.

shirsh94 commented 4 years ago

Contact contact = Contact(); contact.givenName = 'firstname'; contact.displayName = 'fullname'; contact.phones = [Item(label: "mobile", value: '2222222222')]; contact.company = "company"; ContactsService.addContact(contact);