I'm developing a feature in my app to help users find friends who are registered and are in the contact list on the phone. Something like what instagram does here:
Does firebase have any way to synchronize and compare contacts? I think that comparing each phone contact with each database contact will not be very efficient in terms of performance.
Does firebase have any way to synchronize and compare contacts?
It does not. You should create your own system for that.
I think that comparing each phone contact with each database contact will not be very efficient in terms of performance.
Is not. In fact, is quite simple and efficient since Firebase SDK provides a method that can help you simply verify if a user exist or not in the database, this method is called exists().
For more informations, please also see my answer from this post.
Related
I want to create a Contact Provider so I can populate it from our database and let our business workforce to have all the customer data. That's the "easy" part.
But what I need is to isolate those contacts and avoid them to be cloned disallowing the people to copy/clone them and loosing track of that information.
Is there a way to do that? I haven't found a way to do that and I think the only way is to show the contacts in a custom Contact app. The problem with that solution is that it wouldn't be possible to know who's calling.
Is there a way to do that?
On an Android device, there will be roughly zero lines of code that knows anything about a custom ContentProvider that you create. If you do not want to share data from that provider, do not offer any UI to allow people to share data from that provider, and do not export the provider to third-party apps.
I haven't found a way to do that and I think the only way is to show the contacts in a custom Contact app
You needed to write that anyway. There are ~2 billion Android devices. None of them will have a Contacts-style app that knows anything about some custom ContentProvider that you create.
The problem with that solution is that it wouldn't be possible to know who's calling.
Correct. After all, the devices' call managers do not know anything about your custom ContentProvider.
Now, it could be that by "create a Contact Provider", you really meant "not create a Contact Provider". In this case, the "it" in "I can populate it from our database and let our business workforce to have all the customer data" might mean the standard Android ContactsContract ContentProvider. In this case, the Contacts app and in-call screens and everything else that works with contacts will work with your contacts. However, this is a system-supplied ContentProvider, exported to third-party apps, with documentation and so on. There are thousands of apps, both pre-installed and available via the Play Store and elsewhere, that can work with ContactsContract. You have no means of stopping that, and you have no means of preventing those apps from doing whatever it is that they want with this data.
IOW, you cannot satisfy "I want the Contacts app to have my contacts" and "I do not want the Contacts app to have my contacts" at the same time.
i have a question regarding - how contacts are synced between your android app and server to retreive particular contacts just like whatsapp? Can anyone help me out here?
You basically need to add permission to read the device contacts and then you'll have access to them. There's a guide here: https://developer.android.com/training/contacts-provider/retrieve-names.html
since contact is a shared data. you have to to use content providers to update conact. Refer this http://developer.android.com/guide/topics/providers/content-provider-basics.html
We are building an android app that needs to synchronize phone contacts with people already registered on the app. We are using firebase
To do this, we'd like to retrieve a list of existing users based on their phone numbers.
I have managed to retrieve users based on their phone number with ref.orderByChild("phone").equalTo($phoneNumber)
But I am wondering if there is a way of passing a list of phone numbers, instead of querying for each phone number one at a time ?
Something like this:
ref.orderByChild("phone").isIn([phone1, phone2, phone3])
I am just beginning to learn Firebase but I love the concept :)
Thanks a lot for your answers!
Firebase doesn't have or or in operators on its queries.
The closest you can come with with the startAt and endAt functions, to select a range. But that doesn't work for your use-case.
Normally when people are asking for this type of operation, there is a relation between all the pieces that they're trying to combine in a query. For example in your case, the use-case is likely something like: "get the name for all contacts in the user's address book".
In such a situation there are a few options:
monitor each contact with a separate query
embed the necessary metadata for each contact into the user's address book
Option 2 is the cheapest way to get the information, because you only need to read the address book. But it comes at the cost of data duplication, which more relationally trained developers are unused to. See this answer for a coughgreatcough example of such denormalization: Firebase data structure and url
Option 1 is not nearly as expensive as you may expect, since Firebase will open a socket connection only once and then perform all additional queries over that same connection.
I have a requirement like, I can be able to find the people who are using a particular app from my contacts. It is much similar like Whatsapp contacts syncing.
Whatsapp contacts is so fast & very accurate. What is the logic for it?
I'm not sure of their exact logic, but a way that I have seen it done before is as follows...
Access the phone's contacts (duh)
Get the contact that you want to add as a "friend" in your app.
Cross reference that contact's phone number with the user information that you have stored in your application's database
If that phone number exists in your database of users, then you've got a match and you can process things however you'd like from there.
That's one way of doing it, but I don't know if that's exactly how WhatsApp does it. Hope this helps!
I need to add new contacts dynamically from my application.
I list all the phone accounts with the AccountManager getAccounts method but I get accounts like weather, stock, etc.
How can I get only contact accounts ?
There's actually no good way to do this by using the API, the method we found to be most accurate was to think backwards: which accounts are used for storing contacts?
It's a bit crude, but it gives pretty good results (cache the list and you don't need to do it every time).
// Pseudo-code
for contact in RawContacts
uniqueAccountTypes.put(contact.account)
for accountType in uniqueAccountTypes
uniqueAccountsWithContacts.putAll(accountManager.getAccountsByType(accountType))
I don't have access a copy of the contacts database right now, so the code above might be slightly off, but the concept should be clear. Let me know if I should clarify further.
Had a similar situation.
After a little search found this method of AccountManager:
getAccountsByTypeAndFeatures();
here if you set parameter features as "service_mail" , "service_talk" etc, you will get accounts supporting e-mail and chat, hence these accounts will support contacts also.
UPDATE
"service_ah" will give the account device is linked to.