How to integrate Facebook With Parse
Parse.com tutorial will not help you provide complete workable Facebook solution.
Following are the easiest Steps to integrate Facebook Using Parse
Set up a Facebook app, if you haven't already.
Add your application's Facebook Application ID on your Parse application's settings page.
Follow Facebook's instructions for getting started with the Facebook SDK to create an app linked to the Facebook SDK. Once you get to Step 6, stop after linking the Facebook SDK project and configuring the Facebook app ID. You can use our guide to attach your Parse users to Facebook accounts when logging in.
Go to you app build.gradle file and copy follwing in dependencies
compile fileTree(dir: 'libs', include: 'ParseFacebookUtilsV4-1.9.2.jar')
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
- Go to your manifest file and copy the following in application tag
<meta-data
Android: name="com. Facebook. SDK. ApplicationId"
android:value="#facebook_app_id"/>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="@string/app_name" />
- Now go to your Application class and initilize Facebook util by using following line
ParseFacebookUtils.initialize(context);
- Copy the following code in the activty from where you want to login to facebook
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
ParseFacebookUtils.onActivityResult(requestCode, resultCode, data);
}
- Finally Copy the following code in the activity from where you want to login to facebook
ParseFacebookUtils.logInWithReadPermissionsInBackground(Dashboard.this, null, new LogInCallback() {
@Override
public void done(ParseUser user, ParseException err) {
if (user == null) {
Log.d("MyApp", "Uh oh. The user cancelled the Facebook login.");
} else if (user.isNew()) {
Log.d("MyApp", "User signed up and logged in through Facebook!");
} else {
Log.d("MyApp", "User logged in through Facebook!");
}
}});
Enjoy