Reputation: 5858
I am building an android app with Facebook login, once logged, it'll save information from Facebook to Parse like Facebook ID, name and profile picture. Is there a way to make a column unique so that it can only have 1 kind of FB ID? or check if FB ID exist in my User table? I know it might seem like a very general request, but I've been googling for hours and can't find any specific solution..
Upvotes: 0
Views: 564
Reputation: 3467
I've already faced this problem in iOS, and seems that Android can be solved in the same way. So, you can mix the FB API with the parse function
ParseFacebookUtils.logIn(String facebookId, String accessToken, Date expirationDate, LogInCallback callback)
relying to facebook app you can obtain the facebookId, accessToken ( i think that for the expirationDate you can set a far date, like what i've done for iOS )
Another solution is:
ParseFacebookUtils.logIn(Arrays.asList(Permissions.User.EMAIL),
this, new LogInCallback() {
@Override
public void done(ParseUser user, ParseException err) {
Do your stuff...
}
});
it should automatically detect if an user with that facebook id already exist in your _User table or not ( i can confirm this on iOS, you can check if the user is new or still exist with user.isNew()
). If you need you could also save the retrieved facebookId in a separated field, but i think you could avoid it for this scope
Hope it helps
Upvotes: 1