-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Get contacts related to an account #5
Comments
Hi! Thank you for the suggestion. What would be the use case, concretely? One thing to note is that |
The use case is, to get a list of contacts having
With this I can get all the contacts I own and all the visible ones. My idea was, If an account is
|
Ah, that makes sense. The plugin doesn't yet support querying/searching, but you can always filter after the fact. For example: final contacts = (await FlutterContacts
.getContacts())
.where((c) => c.accounts.any((a) => a.type == 'com.myapp'))
.toList(); That said there's no option to include non-visible contacts on Android. We could just add one so that you could write: final contacts = (await FlutterContacts
.getContacts(includeNonVisibleOnAndroid: true))
.where((c) => c.accounts.any((a) => a.type == 'com.myapp'))
.toList(); Would that work for you? I guess one issue with that approach is that you'd get the properties from all raw accounts, not just your account. |
Hi, yes that would work for me and yes, with that approach it is much easier to read all contacts (not only the own ones) with flutter. Maybe you can put a hint to the documentation to use the includeNonVisibleOnAndroid with care. For the IOS side I found the CNContainer class, do you know if there is a relation to the Android-Accounts ? |
Hmm, possibly! Thanks for flagging. I'll give it a try and if it indeed is the equivalent of raw contacts, I'll update the API so that In summary:
|
Added |
With includeNonVisibleOnAndroid=true all contacts will be returned, that is working. But unfortunately I cannot filter for a specific account as they are not filled in the result because the awesome getQuick method does not provide them. A question is how to check on the flutter side if the returned contact was originally a visible one in case the contact's account does not belongs to me ? After testing I was somtime wondering, maybe I found an issue After saving a contact, it will be returned as follow,
If I am not wrong, this leads to a selection by the rawId (idIsRawContactId), but due to returnUnifiedContacts=true, the id in the returned contact is filled with the UnifiedContactsId
One thing regarding contacts and unified contacts
From my knowledge it's the unified contact (android: ContactsContract.Contacts) which cannot be added in android Maybe I can provide some code from my previous proof of concept ? |
You can't use contacts = (await FlutterContact.getContacts(withProperties: true, includeNonVisibleOnAndroid: true))
.where((c) => c.accounts.any((a) => a.type == 'com.myapp'))
.toList();
Currently, you can't easily do that. You could fetch once with
Correct. But why is that an issue? The
You're right! But I didn't want to simply mimic how Android works, or how iOS work, since they're different. Instead I tried to make an API that's most compatible with both platforms. Ultimately we do want to be able to update/insert/delete raw contacts too, it's just that I haven't figured out all the details yet. For example, if you change the name in a raw contact, what are you going to do with the name in the other raw contacts? With unified contacts, it's much simpler since you can update the entire contact at once.
Please do! Any help is welcome :) And feel free to open a pull request if that's easier. |
@joachimvalente You can take a look to the attached patch file that already has the deletion and last modification timestamp (See my feature request #8), but these changes are for now android specific and may not work with IOS :-( And yes, you are right an API should be as much as possible decoupled from the native side. |
It would be nice to have a possibility to get all contacts that are assigned to an account.
Like this:
The text was updated successfully, but these errors were encountered: