PFFacebookUtils Class Reference

Inherits from NSObject
Declared in PFFacebookUtils.h

Overview

The PFFacebookUtils class provides utility functions for using Facebook authentication with PFUsers.

Warning: This class supports official Facebook iOS SDK v4.0+ and is available only on iOS.

Interacting With Facebook

+ initializeFacebookWithApplicationLaunchOptions:

Initializes Parse Facebook Utils.

+ (void)initializeFacebookWithApplicationLaunchOptions:(nullable NSDictionary *)launchOptions

Parameters

launchOptions

The launchOptions as passed to [UIApplicationDelegate application:didFinishLaunchingWithOptions:].

Discussion

You must provide your Facebook application ID as the value for FacebookAppID in your bundle’s plist file as described here: https://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/

Warning: You must invoke this in order to use the Facebook functionality in Parse.

Declared In

PFFacebookUtils.h

+ facebookLoginManager

FBSDKLoginManager provides methods for configuring login behavior, default audience and managing Facebook Access Token.

+ (FBSDKLoginManager *)facebookLoginManager

Return Value

An instance of FBSDKLoginManager that is used by PFFacebookUtils.

Declared In

PFFacebookUtils.h

Logging In

+ logInInBackgroundWithReadPermissions:

Asynchronously logs in a user using Facebook with read permissions.

+ (BFTask PF_GENERIC ( PFUser *) *)logInInBackgroundWithReadPermissions:(nullable NSArray PF_GENERIC ( NSString *) *)permissions

Parameters

permissions

Array of read permissions to use.

Return Value

The task that has will a have result set to PFUser if operation succeeds.

Discussion

This method delegates to the Facebook SDK to authenticate the user, and then automatically logs in (or creates, in the case where it is a new user) a PFUser.

Declared In

PFFacebookUtils.h

+ logInInBackgroundWithReadPermissions:block:

Asynchronously logs in a user using Facebook with read permissions.

+ (void)logInInBackgroundWithReadPermissions:(nullable NSArray PF_GENERIC ( NSString *) *)permissions block:(nullable PFUserResultBlock)block

Parameters

permissions

Array of read permissions to use.

block

The block to execute when the log in completes. It should have the following signature: ^(PFUser *user, NSError *error).

Discussion

This method delegates to the Facebook SDK to authenticate the user, and then automatically logs in (or creates, in the case where it is a new user) a PFUser.

Declared In

PFFacebookUtils.h

+ logInInBackgroundWithPublishPermissions:

Asynchronously logs in a user using Facebook with publish permissions.

+ (BFTask PF_GENERIC ( PFUser *) *)logInInBackgroundWithPublishPermissions:(nullable NSArray PF_GENERIC ( NSString *) *)permissions

Parameters

permissions

Array of publish permissions to use.

Return Value

The task that has will a have result set to PFUser if operation succeeds.

Discussion

This method delegates to the Facebook SDK to authenticate the user, and then automatically logs in (or creates, in the case where it is a new user) a PFUser.

Declared In

PFFacebookUtils.h

+ logInInBackgroundWithPublishPermissions:block:

Asynchronously logs in a user using Facebook with publish permissions.

+ (void)logInInBackgroundWithPublishPermissions:(nullable NSArray PF_GENERIC ( NSString *) *)permissions block:(nullable PFUserResultBlock)block

Parameters

permissions

Array of publish permissions to use.

block

The block to execute when the log in completes. It should have the following signature: ^(PFUser *user, NSError *error).

Discussion

This method delegates to the Facebook SDK to authenticate the user, and then automatically logs in (or creates, in the case where it is a new user) a PFUser.

Declared In

PFFacebookUtils.h

+ logInInBackgroundWithAccessToken:

Asynchronously logs in a user using given Facebook Acess Token.

+ (BFTask PF_GENERIC ( PFUser *) *)logInInBackgroundWithAccessToken:(FBSDKAccessToken *)accessToken

Parameters

accessToken

An instance of FBSDKAccessToken to use when logging in.

Return Value

The task that has will a have result set to PFUser if operation succeeds.

Discussion

This method delegates to the Facebook SDK to authenticate the user, and then automatically logs in (or creates, in the case where it is a new user) a PFUser.

Declared In

PFFacebookUtils.h

+ logInInBackgroundWithAccessToken:block:

Asynchronously logs in a user using given Facebook Acess Token.

+ (void)logInInBackgroundWithAccessToken:(FBSDKAccessToken *)accessToken block:(nullable PFUserResultBlock)block

Parameters

accessToken

An instance of FBSDKAccessToken to use when logging in.

block

The block to execute when the log in completes. It should have the following signature: ^(PFUser *user, NSError *error).

Discussion

This method delegates to the Facebook SDK to authenticate the user, and then automatically logs in (or creates, in the case where it is a new user) a PFUser.

Declared In

PFFacebookUtils.h

Linking Users

+ linkUserInBackground:withReadPermissions:

Asynchronously links Facebook with read permissions to an existing PFUser.

+ (BFTask PF_GENERIC ( NSNumber *) *)linkUserInBackground:(PFUser *)user withReadPermissions:(nullable NSArray PF_GENERIC ( NSString *) *)permissions

Parameters

user

User to link to Facebook.

permissions

Array of read permissions to use when logging in with Facebook.

Return Value

The task that will have a result set to @YES if operation succeeds.

Discussion

This method delegates to the Facebook SDK to authenticate the user, and then automatically links the account to the PFUser. It will also save any unsaved changes that were made to the user.

Declared In

PFFacebookUtils.h

+ linkUserInBackground:withReadPermissions:block:

Asynchronously links Facebook with read permissions to an existing PFUser.

+ (void)linkUserInBackground:(PFUser *)user withReadPermissions:(nullable NSArray PF_GENERIC ( NSString *) *)permissions block:(nullable PFBooleanResultBlock)block

Parameters

user

User to link to Facebook.

permissions

Array of read permissions to use.

block

The block to execute when the linking completes. It should have the following signature: ^(BOOL succeeded, NSError *error).

Discussion

This method delegates to the Facebook SDK to authenticate the user, and then automatically links the account to the PFUser. It will also save any unsaved changes that were made to the user.

Declared In

PFFacebookUtils.h

+ linkUserInBackground:withPublishPermissions:

Asynchronously links Facebook with publish permissions to an existing PFUser.

+ (BFTask PF_GENERIC ( NSNumber *) *)linkUserInBackground:(PFUser *)user withPublishPermissions:(NSArray PF_GENERIC ( NSString *) *)permissions

Parameters

user

User to link to Facebook.

permissions

Array of publish permissions to use.

Return Value

The task that will have a result set to @YES if operation succeeds.

Discussion

This method delegates to the Facebook SDK to authenticate the user, and then automatically links the account to the PFUser. It will also save any unsaved changes that were made to the user.

Declared In

PFFacebookUtils.h

+ linkUserInBackground:withPublishPermissions:block:

Asynchronously links Facebook with publish permissions to an existing PFUser.

+ (void)linkUserInBackground:(PFUser *)user withPublishPermissions:(NSArray PF_GENERIC ( NSString *) *)permissions block:(nullable PFBooleanResultBlock)block

Parameters

user

User to link to Facebook.

permissions

Array of publish permissions to use.

block

The block to execute when the linking completes. It should have the following signature: ^(BOOL succeeded, NSError *error).

Discussion

This method delegates to the Facebook SDK to authenticate the user, and then automatically links the account to the PFUser. It will also save any unsaved changes that were made to the user.

Declared In

PFFacebookUtils.h

+ linkUserInBackground:withAccessToken:

Asynchronously links Facebook Access Token to an existing PFUser.

+ (BFTask PF_GENERIC ( NSNumber *) *)linkUserInBackground:(PFUser *)user withAccessToken:(FBSDKAccessToken *)accessToken

Parameters

user

User to link to Facebook.

accessToken

An instance of FBSDKAccessToken to use.

Return Value

The task that will have a result set to @YES if operation succeeds.

Discussion

This method delegates to the Facebook SDK to authenticate the user, and then automatically links the account to the PFUser. It will also save any unsaved changes that were made to the user.

Declared In

PFFacebookUtils.h

+ linkUserInBackground:withAccessToken:block:

Asynchronously links Facebook Access Token to an existing PFUser.

+ (void)linkUserInBackground:(PFUser *)user withAccessToken:(FBSDKAccessToken *)accessToken block:(nullable PFBooleanResultBlock)block

Parameters

user

User to link to Facebook.

accessToken

An instance of FBSDKAccessToken to use.

block

The block to execute when the linking completes. It should have the following signature: ^(BOOL succeeded, NSError *error).

Discussion

This method delegates to the Facebook SDK to authenticate the user, and then automatically links the account to the PFUser. It will also save any unsaved changes that were made to the user.

Declared In

PFFacebookUtils.h

Unlinking Users

+ unlinkUserInBackground:

Unlinks the PFUser from a Facebook account asynchronously.

+ (BFTask PF_GENERIC ( NSNumber *) *)unlinkUserInBackground:(PFUser *)user

Parameters

user

User to unlink from Facebook.

Return Value

The task, that encapsulates the work being done.

Declared In

PFFacebookUtils.h

+ unlinkUserInBackground:block:

Unlinks the PFUser from a Facebook account asynchronously.

+ (void)unlinkUserInBackground:(PFUser *)user block:(nullable PFBooleanResultBlock)block

Parameters

user

User to unlink from Facebook.

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Declared In

PFFacebookUtils.h

Getting Linked State

+ isLinkedWithUser:

Whether the user has their account linked to Facebook.

+ (BOOL)isLinkedWithUser:(PFUser *)user

Parameters

user

User to check for a facebook link. The user must be logged in on this device.

Return Value

YES if the user has their account linked to Facebook, otherwise NO.

Declared In

PFFacebookUtils.h