Prevent duplicate entries on Parse.com?

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..

Answers


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


Need Your Help

Render partial view with dynamic model in Razor view engine and ASP.NET MVC 3

asp.net-mvc razor asp.net-mvc-3

When I try to render a partial view whose model type is specified as:

li won't float correctly in IE

html css internet-explorer css-float

I have a very peculiar problem across the IE board (ignoring IE6).

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.