FBSDKLoginManager
有此級別的更新版本。前往查看 最新版本。

FBSDKLoginManager provides methods for logging the user in and out.

Discussion:

FBSDKLoginManager works directly with [FBSDKAccessToken currentAccessToken] and sets the "currentAccessToken" upon successful authorizations (or sets nil in case of logOut).

You should check [FBSDKAccessToken currentAccessToken] before calling logIn* to see if there is a cached token available (typically in your viewDidLoad).

If you are managing your own token instances outside of "currentAccessToken", you will need to set "currentAccessToken" before calling logIn* to authorize futher permissions on your tokens.

Inherits from:NSObject
Declared in:FBSDKLoginManager.h
資產
defaultAudience

The default audience.

@property (assign, nonatomic) FBSDKDefaultAudience defaultAudience;
Discussion:

You should set this if you intend to ask for publish permissions.

宣告於: FBSDKLoginManager.h
loginBehavior

The login behavior

@property (assign, nonatomic) FBSDKLoginBehavior loginBehavior;
Discussion:

You should only set this if you want an explicit login flow; otherwise, the SDK will automatically determine the best flow available.

宣告於: FBSDKLoginManager.h
類別方式
renewSystemCredentials:

Issues an asychronous renewCredentialsForAccount call to the device's Facebook account store.

參數說明
handler

The completion handler to call when the renewal is completed. This can be invoked on an arbitrary thread.

+ (void)
renewSystemCredentials
void
^
ACAccountCredentialRenewResult
result
NSError
error
handler;
Discussion:

This can be used to explicitly renew account credentials and is provided as a convenience wrapper around [ACAccountStore renewCredentialsForAccount:completion]. Note the method will not issue the renewal call if the the Facebook account has not been set on the device, or if access had not been granted to the account (though the handler wil receive an error).

If the [FBSDKAccessToken currentAccessToken] was from the account store, a succesful renewal will also set a new "currentAccessToken".

宣告於: FBSDKLoginManager.h
執行個體方法
logInWithPublishPermissions:fromViewController:handler:

Logs the user in or authorizes additional permissions.

參數說明
permissions

The optional array of permissions. Note this is converted to NSSet and is only an NSArray for the convenience of literal syntax.

fromViewController

The view controller to present from. If nil, the topmost view controller will be automatically determined as best as possible.

handler

The callback.

- (void)
logInWithPublishPermissions: (NSArray *)permissions
fromViewController: (UIViewController *)fromViewController
handler: (FBSDKLoginManagerRequestTokenHandler)handler;
Discussion:

Use this method when asking for publish permissions. You should only ask for permissions when they are needed and explain the value to the user. You can inspect the result.declinedPermissions to also provide more information to the user if they decline permissions.

If [FBSDKAccessToken currentAccessToken] is not nil, it will be treated as a reauthorization for that user and will pass the "rerequest" flag to the login dialog.

This method will present UI the user. You typically should check if [FBSDKAccessToken currentAccessToken] already contains the permissions you need before asking to reduce unnecessary app switching. For example, you could make that check at viewDidLoad.

宣告於: FBSDKLoginManager.h
logInWithPublishPermissions:handler:
- (void)
logInWithPublishPermissions: (NSArray *)permissions
handler: (FBSDKLoginManagerRequestTokenHandler)handler
__attribute__((deprecated("use logInWithPublishPermissions: fromViewController:handler: instead")));
宣告於: FBSDKLoginManager.h
logInWithReadPermissions:fromViewController:handler:

Logs the user in or authorizes additional permissions.

參數說明
permissions

The optional array of permissions. Note this is converted to NSSet and is only an NSArray for the convenience of literal syntax.

fromViewController

The view controller to present from. If nil, the topmost view controller will be automatically determined as best as possible.

handler

The callback.

- (void)
logInWithReadPermissions: (NSArray *)permissions
fromViewController: (UIViewController *)fromViewController
handler: (FBSDKLoginManagerRequestTokenHandler)handler;
Discussion:

Use this method when asking for read permissions. You should only ask for permissions when they are needed and explain the value to the user. You can inspect the result.declinedPermissions to also provide more information to the user if they decline permissions.

If [FBSDKAccessToken currentAccessToken] is not nil, it will be treated as a reauthorization for that user and will pass the "rerequest" flag to the login dialog.

This method will present UI the user. You typically should check if [FBSDKAccessToken currentAccessToken] already contains the permissions you need before asking to reduce unnecessary app switching. For example, you could make that check at viewDidLoad.

宣告於: FBSDKLoginManager.h
logInWithReadPermissions:handler:
- (void)
logInWithReadPermissions: (NSArray *)permissions
handler: (FBSDKLoginManagerRequestTokenHandler)handler
__attribute__((deprecated("use logInWithReadPermissions: fromViewController:handler: instead")));
宣告於: FBSDKLoginManager.h
logOut

Logs the user out

- (void) logOut;
Discussion:

This calls [FBSDKAccessToken setCurrentAccessToken:nil] and [FBSDKProfile setCurrentProfile:nil].

宣告於: FBSDKLoginManager.h
Typedefs
FBSDKDefaultAudience enum

Passed to open to indicate which default audience to use for sessions that post data to Facebook.

typedef NS_ENUM(NSUInteger, FBSDKDefaultAudience) {
FBSDKDefaultAudienceFriends = 0,
FBSDKDefaultAudienceOnlyMe,
FBSDKDefaultAudienceEveryone,
};
常數簡介
FBSDKDefaultAudienceFriends

Indicates that the user's friends are able to see posts made by the application

FBSDKDefaultAudienceOnlyMe

Indicates that only the user is able to see posts made by the application

FBSDKDefaultAudienceEveryone

Indicates that all Facebook users are able to see posts made by the application

Discussion:

Certain operations such as publishing a status or publishing a photo require an audience. When the user grants an application permission to perform a publish operation, a default audience is selected as the publication ceiling for the application. This enumerated value allows the application to select which audience to ask the user to grant publish permission for.

宣告於: FBSDKLoginManager.h
FBSDKLoginBehavior enum

Attempts login through a modal UIWebView pop up

This behavior is only available to certain types of apps. Please check the Facebook Platform Policy to verify your app meets the restrictions.

typedef NS_ENUM(NSUInteger, FBSDKLoginBehavior) {
FBSDKLoginBehaviorNative = 0,
FBSDKLoginBehaviorBrowser,
FBSDKLoginBehaviorSystemAccount,
FBSDKLoginBehaviorWeb,
};
Discussion:

Facebook Login authorizes the application to act on behalf of the user, using the user's Facebook account. Usually a Facebook Login will rely on an account maintained outside of the application, by the native Facebook application, the browser, or perhaps the device itself. This avoids the need for a user to enter their username and password directly, and provides the most secure and lowest friction way for a user to authorize the application to interact with Facebook.

The \c FBSDKLoginBehavior enum specifies which log in method should be attempted. Most applications will use the default, which attempts a login through the Facebook app and falls back to the browser if needed.

If log in cannot be completed using the specificed behavior, the completion handler will be invoked with an error in the \c FBSDKErrorDomain and a code of \c FBSDKLoginUnknownErrorCode.

宣告於: FBSDKLoginManager.h
FBSDKLoginManagerRequestTokenHandler

Describes the call back to the FBSDKLoginManager

typedef void (^FBSDKLoginManagerRequestTokenHandler)(
FBSDKLoginManagerLoginResult *result,
NSError *error);
宣告於: FBSDKLoginManager.h
NS_ENUM

Passed to open to indicate which default audience to use for sessions that post data to Facebook.

typedef NS_ENUM(NSUInteger, FBSDKDefaultAudience) {
FBSDKDefaultAudienceFriends = 0,
FBSDKDefaultAudienceOnlyMe,
FBSDKDefaultAudienceEveryone,
};
常數簡介
FBSDKDefaultAudienceFriends

Indicates that the user's friends are able to see posts made by the application

Discussion:

Certain operations such as publishing a status or publishing a photo require an audience. When the user grants an application permission to perform a publish operation, a default audience is selected as the publication ceiling for the application. This enumerated value allows the application to select which audience to ask the user to grant publish permission for.

宣告於: FBSDKLoginManager.h
NS_ENUM

Attempts login through a modal UIWebView pop up

This behavior is only available to certain types of apps. Please check the Facebook Platform Policy to verify your app meets the restrictions.

typedef NS_ENUM(NSUInteger, FBSDKLoginBehavior) {
FBSDKLoginBehaviorNative = 0,
FBSDKLoginBehaviorBrowser,
FBSDKLoginBehaviorSystemAccount,
FBSDKLoginBehaviorWeb,
};
Discussion:

Facebook Login authorizes the application to act on behalf of the user, using the user's Facebook account. Usually a Facebook Login will rely on an account maintained outside of the application, by the native Facebook application, the browser, or perhaps the device itself. This avoids the need for a user to enter their username and password directly, and provides the most secure and lowest friction way for a user to authorize the application to interact with Facebook.

The \c FBSDKLoginBehavior enum specifies which log in method should be attempted. Most applications will use the default, which attempts a login through the Facebook app and falls back to the browser if needed.

If log in cannot be completed using the specificed behavior, the completion handler will be invoked with an error in the \c FBSDKErrorDomain and a code of \c FBSDKLoginUnknownErrorCode.

宣告於: FBSDKLoginManager.h