Reputation: 1316
I'm creating app where I will be using Firebase messaging service. Messaging is working fine, but now I wish to make it happen between two users.
I believe I need to provide a authentication for each user then search for their connections(their friends via their social network connections or their mail ids).
I managed to create Google+ authentication in my app using Auth.GOOGLE_SIGN_IN_API and AppInvite.API, but connecting to other users in firebase had no clue, then I went through these links Udacity tutorial and Codelabs tutorial and the Firebase guides. (The tutorials explained the same thing and every one authenticated using the email provider, and not via the Google+ signin. And as a matter fact when I initially tried Google+ signin via these procedures, it didnt work, but email provider is working.)
Anyways email provider is also good for me as of now but still don't have a clue how to connect two users thriugh Firebase. I connected two users, its showing in my Firebase authentication console but how to connect two user one to one?
Any clues??
Upvotes: 0
Views: 1160
Reputation: 600126
To make a connection between two users in a social network, typically one of them has to enter some "secret" details about the other user. Most common is that you have to enter the email address of your friend and then the system will show you that it has a record matching that email address.
You could implement such a system on Firebase by having a list of email addresses with their corresponding uid:
userLookup
"ari@stackoverflow,com": "uidOfAri"
"[email protected]": "uidOfPuf"
Now when I type your email address, I can find your UID (and thus connect with you).
To secure the above, you'd only grant read access on specific users:
{
"rules": {
"userLookup": {
"$user": {
".read": true
}
}
}
}
With this structure you can read each specific user, but you cannot search the list of users. So I can only find your uid
(and thus connect) if I know your complete email address.
Upvotes: 1