com.parse

## Class ParseFacebookUtils

- java.lang.Object
- - com.parse.ParseFacebookUtils

    public final class ParseFacebookUtils
    extends Object

Provides a set of utilities for using Parse with Facebook.

Note: `ParseFacebookUtils` requires Facebook Android SDK v4.x.x

To use `ParseFacebookUtils`, you'll need to set up the Facebook SDK:

Add the Facebook SDK: `compile 'com.facebook.android:facebook-android-sdk:4.x.x'`

Add the following to the `<application>` node in your AndroidManifest.xml:

     <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id"/>

Create `facebook_app_id` in your strings.xml with your Facebook App ID

Then you can use `ParseFacebookUtils`:

Initialize `ParseFacebookUtils` in your `Application.onCreate()`:

     public class MyApplication extends Application {
       public void onCreate() {
         Parse.initialize(this);
         ...
         ParseFacebookUtils.initialize(this);
       }
     }

Add `onActivityResult(int, int, android.content.Intent)` to your `Activity.onActivityResult(int, int, android.content.Intent)`:

     public class MyActivity extends Activity {
       protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
         ParseFacebookUtils.onActivityResult(requestCode, resultCode, data);
       }
     }

Lastly, log in with `logInWithReadPermissionsInBackground(android.app.Activity, java.util.Collection)`

### Method Summary

Methods
`static void` `initialize(Context context)` Initializes `ParseFacebookUtils` and `com.facebook.FacebookSdk`.
`static void` `initialize(Context context, int callbackRequestCodeOffset)` Initializes `ParseFacebookUtils` and `com.facebook.FacebookSdk`.
`static boolean` `isLinked(com.parse.ParseUser user)`
`static Task<Void>` `linkInBackground(com.parse.ParseUser user, AccessToken accessToken)` Link an existing Parse user with a Facebook account using authorization credentials that have already been obtained.
`static Task<Void>` `linkInBackground(com.parse.ParseUser user, AccessToken accessToken, com.parse.SaveCallback callback)` Link an existing Parse user with a Facebook account using authorization credentials that have already been obtained.
`static Task<Void>` `linkWithPublishPermissionsInBackground(com.parse.ParseUser user, Activity activity, Collection<String> permissions)` Link an existing Parse user to Facebook with the requested publish permissions.
`static Task<Void>` `linkWithPublishPermissionsInBackground(com.parse.ParseUser user, Activity activity, Collection<String> permissions, com.parse.SaveCallback callback)` Link an existing Parse user to Facebook with the requested publish permissions.
`static Task<Void>` `linkWithPublishPermissionsInBackground(com.parse.ParseUser user, Fragment fragment, Collection<String> permissions)` Link an existing Parse user to Facebook with the requested publish permissions.
`static Task<Void>` `linkWithPublishPermissionsInBackground(com.parse.ParseUser user, Fragment fragment, Collection<String> permissions, com.parse.SaveCallback callback)` Link an existing Parse user to Facebook with the requested publish permissions.
`static Task<Void>` `linkWithReadPermissionsInBackground(com.parse.ParseUser user, Activity activity, Collection<String> permissions)` Link an existing Parse user to Facebook with the requested read permissions.
`static Task<Void>` `linkWithReadPermissionsInBackground(com.parse.ParseUser user, Activity activity, Collection<String> permissions, com.parse.SaveCallback callback)` Link an existing Parse user to Facebook with the requested read permissions.
`static Task<Void>` `linkWithReadPermissionsInBackground(com.parse.ParseUser user, Fragment fragment, Collection<String> permissions)` Link an existing Parse user to Facebook with the requested read permissions.
`static Task<Void>` `linkWithReadPermissionsInBackground(com.parse.ParseUser user, Fragment fragment, Collection<String> permissions, com.parse.SaveCallback callback)` Link an existing Parse user to Facebook with the requested read permissions.
`static Task<com.parse.ParseUser>` `logInInBackground(AccessToken accessToken)` Log in using a Facebook account using authorization credentials that have already been obtained.
`static Task<com.parse.ParseUser>` `logInInBackground(AccessToken accessToken, com.parse.LogInCallback callback)` Log in using a Facebook account using authorization credentials that have already been obtained.
`static Task<com.parse.ParseUser>` `logInWithPublishPermissionsInBackground(Activity activity, Collection<String> permissions)` Log in using Facebook login with the requested publish permissions.
`static Task<com.parse.ParseUser>` `logInWithPublishPermissionsInBackground(Activity activity, Collection<String> permissions, com.parse.LogInCallback callback)` Log in using Facebook login with the requested publish permissions.
`static Task<com.parse.ParseUser>` `logInWithPublishPermissionsInBackground(Fragment fragment, Collection<String> permissions)` Log in using Facebook login with the requested publish permissions.
`static Task<com.parse.ParseUser>` `logInWithPublishPermissionsInBackground(Fragment fragment, Collection<String> permissions, com.parse.LogInCallback callback)` Log in using Facebook login with the requested publish permissions.
`static Task<com.parse.ParseUser>` `logInWithReadPermissionsInBackground(Activity activity, Collection<String> permissions)` Log in using Facebook login with the requested read permissions.
`static Task<com.parse.ParseUser>` `logInWithReadPermissionsInBackground(Activity activity, Collection<String> permissions, com.parse.LogInCallback callback)` Log in using Facebook login with the requested read permissions.
`static Task<com.parse.ParseUser>` `logInWithReadPermissionsInBackground(Fragment fragment, Collection<String> permissions)` Log in using Facebook login with the requested read permissions.
`static Task<com.parse.ParseUser>` `logInWithReadPermissionsInBackground(Fragment fragment, Collection<String> permissions, com.parse.LogInCallback callback)` Log in using Facebook login with the requested read permissions.
`static boolean` `onActivityResult(int requestCode, int resultCode, Intent data)` The method that should be called from the Activity's or Fragment's onActivityResult method.
`static Task<Void>` `unlinkInBackground(com.parse.ParseUser user)` Unlink a user from a Facebook account.
`static Task<Void>` `unlinkInBackground(com.parse.ParseUser user, com.parse.SaveCallback callback)` Unlink a user from a Facebook account.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### isLinked

    public static boolean isLinked(com.parse.ParseUser user)

Returns:
  `true` if the user is linked to a Facebook account.

#### initialize

    public static void initialize(Context context)

Initializes `ParseFacebookUtils` and `com.facebook.FacebookSdk`.

This should be called in your `Application.onCreate()`.

Parameters:
  `context` - The application context

#### initialize

    public static void initialize(Context context,
                  int callbackRequestCodeOffset)

Initializes `ParseFacebookUtils` and `com.facebook.FacebookSdk`.

This should be called in your `Application.onCreate()`.

Parameters:
  `context` - The application context
  `callbackRequestCodeOffset` - The request code offset that Facebook activities will be called with. Please do not use the range between the value you set and another 100 entries after it in your other requests.

#### onActivityResult

    public static boolean onActivityResult(int requestCode,
                           int resultCode,
                           Intent data)

The method that should be called from the Activity's or Fragment's onActivityResult method.

Parameters:
  `requestCode` - The request code that's received by the Activity or Fragment.
  `resultCode` - The result code that's received by the Activity or Fragment.
  `data` - The result data that's received by the Activity or Fragment.
Returns:
  `true` if the result could be handled.

#### logInInBackground

    public static Task<com.parse.ParseUser> logInInBackground(AccessToken accessToken)

Log in using a Facebook account using authorization credentials that have already been obtained.

Parameters:
  `accessToken` - Authorization credentials of a Facebook user.
Returns:
  A task that will be resolved when logging in is complete.

#### logInInBackground

    public static Task<com.parse.ParseUser> logInInBackground(AccessToken accessToken,
                                              com.parse.LogInCallback callback)

Log in using a Facebook account using authorization credentials that have already been obtained.

Parameters:
  `accessToken` - Authorization credentials of a Facebook user.
  `callback` - A callback that will be executed when logging in is complete.

#### logInWithReadPermissionsInBackground

    public static Task<com.parse.ParseUser> logInWithReadPermissionsInBackground(Activity activity,
                                                                 Collection<String> permissions)

Log in using Facebook login with the requested read permissions.

Parameters:
  `activity` - The activity which is starting the login process.
  `permissions` - The requested permissions.
Returns:
  A task that will be resolved when logging in is complete.

#### logInWithReadPermissionsInBackground

    public static Task<com.parse.ParseUser> logInWithReadPermissionsInBackground(Activity activity,
                                                                 Collection<String> permissions,
                                                                 com.parse.LogInCallback callback)

Log in using Facebook login with the requested read permissions.

Parameters:
  `activity` - The activity which is starting the login process.
  `permissions` - The requested permissions.
  `callback` - A callback that will be executed when logging in is complete.

#### logInWithPublishPermissionsInBackground

    public static Task<com.parse.ParseUser> logInWithPublishPermissionsInBackground(Activity activity,
                                                                    Collection<String> permissions)

Log in using Facebook login with the requested publish permissions.

Parameters:
  `activity` - The activity which is starting the login process.
  `permissions` - The requested permissions.
Returns:
  A task that will be resolved when logging in is complete.

#### logInWithPublishPermissionsInBackground

    public static Task<com.parse.ParseUser> logInWithPublishPermissionsInBackground(Activity activity,
                                                                    Collection<String> permissions,
                                                                    com.parse.LogInCallback callback)

Log in using Facebook login with the requested publish permissions.

Parameters:
  `activity` - The activity which is starting the login process.
  `permissions` - The requested permissions.
  `callback` - A callback that will be executed when logging in is complete.

#### logInWithReadPermissionsInBackground

    public static Task<com.parse.ParseUser> logInWithReadPermissionsInBackground(Fragment fragment,
                                                                 Collection<String> permissions)

Log in using Facebook login with the requested read permissions.

Parameters:
  `fragment` - The fragment which is starting the login process.
  `permissions` - The requested permissions.
Returns:
  A task that will be resolved when logging in is complete.

#### logInWithReadPermissionsInBackground

    public static Task<com.parse.ParseUser> logInWithReadPermissionsInBackground(Fragment fragment,
                                                                 Collection<String> permissions,
                                                                 com.parse.LogInCallback callback)

Log in using Facebook login with the requested read permissions.

Parameters:
  `fragment` - The fragment which is starting the login process.
  `permissions` - The requested permissions.
  `callback` - A callback that will be executed when logging in is complete.

#### logInWithPublishPermissionsInBackground

    public static Task<com.parse.ParseUser> logInWithPublishPermissionsInBackground(Fragment fragment,
                                                                    Collection<String> permissions)

Log in using Facebook login with the requested publish permissions.

Parameters:
  `fragment` - The fragment which is starting the login process.
  `permissions` - The requested permissions.
Returns:
  A task that will be resolved when logging in is complete.

#### logInWithPublishPermissionsInBackground

    public static Task<com.parse.ParseUser> logInWithPublishPermissionsInBackground(Fragment fragment,
                                                                    Collection<String> permissions,
                                                                    com.parse.LogInCallback callback)

Log in using Facebook login with the requested publish permissions.

Parameters:
  `fragment` - The fragment which is starting the login process.
  `permissions` - The requested permissions.
  `callback` - A callback that will be executed when logging in is complete.

#### linkInBackground

    public static Task<Void> linkInBackground(com.parse.ParseUser user,
                              AccessToken accessToken)

Link an existing Parse user with a Facebook account using authorization credentials that have already been obtained.

Parameters:
  `accessToken` - Authorization credentials of a Facebook user.
Returns:
  A task that will be resolved when linking is complete.

#### linkInBackground

    public static Task<Void> linkInBackground(com.parse.ParseUser user,
                              AccessToken accessToken,
                              com.parse.SaveCallback callback)

Link an existing Parse user with a Facebook account using authorization credentials that have already been obtained.

Parameters:
  `accessToken` - Authorization credentials of a Facebook user.
  `callback` - A callback that will be executed when linking is complete.

#### linkWithReadPermissionsInBackground

    public static Task<Void> linkWithReadPermissionsInBackground(com.parse.ParseUser user,
                                                 Activity activity,
                                                 Collection<String> permissions)

Link an existing Parse user to Facebook with the requested read permissions.

Parameters:
  `user` - The Parse user to link with.
  `activity` - The activity which is starting the login process.
  `permissions` - The requested permissions.
Returns:
  A task that will be resolved when linking is complete.

#### linkWithReadPermissionsInBackground

    public static Task<Void> linkWithReadPermissionsInBackground(com.parse.ParseUser user,
                                                 Activity activity,
                                                 Collection<String> permissions,
                                                 com.parse.SaveCallback callback)

Link an existing Parse user to Facebook with the requested read permissions.

Parameters:
  `user` - The Parse user to link with.
  `activity` - The activity which is starting the login process.
  `permissions` - The requested permissions.
  `callback` - A callback that will be executed when linking is complete.

#### linkWithPublishPermissionsInBackground

    public static Task<Void> linkWithPublishPermissionsInBackground(com.parse.ParseUser user,
                                                    Activity activity,
                                                    Collection<String> permissions)

Link an existing Parse user to Facebook with the requested publish permissions.

Parameters:
  `user` - The Parse user to link with.
  `activity` - The activity which is starting the login process.
  `permissions` - The requested permissions.
Returns:
  A task that will be resolved when linking is complete.

#### linkWithPublishPermissionsInBackground

    public static Task<Void> linkWithPublishPermissionsInBackground(com.parse.ParseUser user,
                                                    Activity activity,
                                                    Collection<String> permissions,
                                                    com.parse.SaveCallback callback)

Link an existing Parse user to Facebook with the requested publish permissions.

Parameters:
  `user` - The Parse user to link with.
  `activity` - The activity which is starting the login process.
  `permissions` - The requested permissions.
  `callback` - A callback that will be executed when linking is complete.

#### linkWithReadPermissionsInBackground

    public static Task<Void> linkWithReadPermissionsInBackground(com.parse.ParseUser user,
                                                 Fragment fragment,
                                                 Collection<String> permissions)

Link an existing Parse user to Facebook with the requested read permissions.

Parameters:
  `user` - The Parse user to link with.
  `fragment` - The fragment which is starting the login process.
  `permissions` - The requested permissions.
Returns:
  A task that will be resolved when linking is complete.

#### linkWithReadPermissionsInBackground

    public static Task<Void> linkWithReadPermissionsInBackground(com.parse.ParseUser user,
                                                 Fragment fragment,
                                                 Collection<String> permissions,
                                                 com.parse.SaveCallback callback)

Link an existing Parse user to Facebook with the requested read permissions.

Parameters:
  `user` - The Parse user to link with.
  `fragment` - The fragment which is starting the login process.
  `permissions` - The requested permissions.
  `callback` - A callback that will be executed when linking is complete.

#### linkWithPublishPermissionsInBackground

    public static Task<Void> linkWithPublishPermissionsInBackground(com.parse.ParseUser user,
                                                    Fragment fragment,
                                                    Collection<String> permissions)

Link an existing Parse user to Facebook with the requested publish permissions.

Parameters:
  `user` - The Parse user to link with.
  `fragment` - The fragment which is starting the login process.
  `permissions` - The requested permissions.
Returns:
  A task that will be resolved when linking is complete.

#### linkWithPublishPermissionsInBackground

    public static Task<Void> linkWithPublishPermissionsInBackground(com.parse.ParseUser user,
                                                    Fragment fragment,
                                                    Collection<String> permissions,
                                                    com.parse.SaveCallback callback)

Link an existing Parse user to Facebook with the requested publish permissions.

Parameters:
  `user` - The Parse user to link with.
  `fragment` - The fragment which is starting the login process.
  `permissions` - The requested permissions.
  `callback` - A callback that will be executed when linking is complete.

#### unlinkInBackground

    public static Task<Void> unlinkInBackground(com.parse.ParseUser user)

Unlink a user from a Facebook account. This will save the user's data.

Parameters:
  `user` - The user to unlink.
Returns:
  A task that will be resolved when unlinking has completed.

#### unlinkInBackground

    public static Task<Void> unlinkInBackground(com.parse.ParseUser user,
                                com.parse.SaveCallback callback)

Unlink a user from a Facebook account. This will save the user's data.

Parameters:
  `user` - The user to unlink.
  `callback` - A callback that will be executed when unlinking is complete.