MLFacebookUtils Class Reference

Inherits from NSObject
Declared in MLFacebookUtils.h

Overview

The MLFacebookUtils class provides utility functions for using Facebook authentication with MLUsers.

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

Interacting With Facebook

+ initializeFacebookWithApplicationLaunchOptions:

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

Declared In

MLFacebookUtils.h

+ facebookLoginManager

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

+ (nullable FBSDKLoginManager *)facebookLoginManager

Return Value

An instance of FBSDKLoginManager that is used by MLFacebookUtils.

Declared In

MLFacebookUtils.h

Logging In

+ logInInBackgroundWithReadPermissions:block:

Asynchronously logs in a user using Facebook with read permissions.

+ (void)logInInBackgroundWithReadPermissions:(NSArray ML_GENERIC ( NSString *) *)permissions block:(nullable MLUserResultBlock)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: ^(MLUser *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 MLUser.

Declared In

MLFacebookUtils.h

+ logInInBackgroundWithPublishPermissions:block:

Asynchronously logs in a user using Facebook with publish permissions.

+ (void)logInInBackgroundWithPublishPermissions:(NSArray ML_GENERIC ( NSString *) *)permissions block:(nullable MLUserResultBlock)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: ^(MLUser *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 MLUser.

Declared In

MLFacebookUtils.h

+ logInInBackgroundWithAccessToken:block:

Asynchronously logs in a user using given Facebook Acess Token.

+ (void)logInInBackgroundWithAccessToken:(FBSDKAccessToken *)accessToken block:(nullable MLUserResultBlock)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: ^(MLUser *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 MLUser.

Declared In

MLFacebookUtils.h

Linking Users

+ linkUserInBackground:withReadPermissions:block:

Asynchronously links Facebook with read permissions to an existing MLUser.

+ (void)linkUserInBackground:(MLUser *)user withReadPermissions:(NSArray ML_GENERIC ( NSString *) *)permissions block:(nullable MLBooleanResultBlock)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 MLUser. It will also save any unsaved changes that were made to the user.

Declared In

MLFacebookUtils.h

+ linkUserInBackground:withPublishPermissions:block:

Asynchronously links Facebook with publish permissions to an existing MLUser.

+ (void)linkUserInBackground:(MLUser *)user withPublishPermissions:(NSArray ML_GENERIC ( NSString *) *)permissions block:(nullable MLBooleanResultBlock)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 MLUser. It will also save any unsaved changes that were made to the user.

Declared In

MLFacebookUtils.h

+ linkUserInBackground:withAccessToken:block:

Asynchronously links Facebook Access Token to an existing MLUser.

+ (void)linkUserInBackground:(MLUser *)user withAccessToken:(FBSDKAccessToken *)accessToken block:(nullable MLBooleanResultBlock)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 MLUser. It will also save any unsaved changes that were made to the user.

Declared In

MLFacebookUtils.h

+ unlinkUserInBackground:block:

Unlinks the MLUser from a Facebook account asynchronously.

+ (void)unlinkUserInBackground:(MLUser *)user block:(nullable MLBooleanResultBlock)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

MLFacebookUtils.h

Getting Linked State

+ isLinkedWithUser:

Whether the user has their account linked to Facebook.

+ (BOOL)isLinkedWithUser:(nullable MLUser *)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

MLFacebookUtils.h