来自 ParseFacebookUtilsV4 的头文件
PFFacebookUtils.h
...
/*!@abstractFBSDKLoginManager提供了配置登录行为、默认受众和管理 Facebook 访问令牌的方法。
FBSDKLoginManager@returns使用
的一个实例PFFacebookUtils。*/
+ (FBSDKLoginManager *)facebookLoginManager;
因此,据推测,PFFacebookutils 使用了“FBSDKLoginManager”的声明,让我们看看这是否有效。实际上,让我们将默认设置为“系统帐户”,......这是代码:
[[PFFacebookUtils facebookLoginManager] setLoginBehavior:FBSDKLoginBehaviorSystemAccount];
[PFFacebookUtils logInInBackgroundWithReadPermissions:FACEBOOK_READ_PERMISSIONS block:^(PFUser *user, NSError *error) {
}];
是的,这段代码可以编译,这段代码可以工作,只要确保在调用登录内容之前声明登录行为,最好在初始化代码库、Parse、Parse Facebook Utilities 等时在 AppDelegate 中声明。
事实上,为了确保这对你有用,我刚刚下载了 PARSE iOS SDK 的最新版本,它具有相同的功能。这是您的选项,这是来自为 PFFacebookUtils 提供的 iOS 版 Facebook SDK:
@typedef FBSDKLoginBehavior enum
@abstract 传递给 \c FBSDKLoginManager 以指示应如何尝试 Facebook 登录。
@discussion Facebook 登录授权应用程序使用用户的 Facebook 帐户代表用户行事。通常,Facebook 登录将依赖于应用程序外部维护的帐户,由本机 Facebook 应用程序、浏览器或设备本身维护。这避免了用户直接输入他们的用户名和密码的需要,并为用户授权应用程序与 Facebook 交互提供了最安全、摩擦最小的方式。
\c FBSDKLoginBehavior 枚举指定应尝试哪种登录方法。大多数应用程序将使用默认设置,即尝试通过 Facebook 应用程序登录并在需要时回退到浏览器。
如果使用指定的行为无法完成登录,则会调用完成处理程序,并在 \c FBSDKErrorDomain 中出现错误,并且代码为 \c FBSDKLoginUnknownErrorCode。*/
typedef NS_ENUM(NSUInteger, FBSDKLoginBehavior)
{
/*!
@abstract Attempts log in through the native Facebook app. If the Facebook app is
not installed on the device, falls back to \c FBSDKLoginBehaviorBrowser. This is the
default behavior.
*/
FBSDKLoginBehaviorNative = 0,
/*!
@abstract Attempts log in through the Safari browser
*/
FBSDKLoginBehaviorBrowser,
/*!
@abstract Attempts log in through the Facebook account currently signed in through Settings.
If no Facebook account is signed in, falls back to \c FBSDKLoginBehaviorNative.
*/
FBSDKLoginBehaviorSystemAccount,
/*!
@abstract Attemps log in through a modal \c UIWebView pop up
@note This behavior is only available to certain types of apps. Please check the Facebook
Platform Policy to verify your app meets the restrictions.
*/
FBSDKLoginBehaviorWeb,
};