Facebook SDK 4.0 iOS 不再快速切换到设备上安装的 Facebook APP

Facebook SDK 4.0 iOS no longer fast switches to the Facebook APP installed on the device

我正在升级到 Facebook SDK 4.6,并且我正在根据 Scruptions 示例应用程序使用以下代码实现新的登录流程:

1
2
3
4
5
6
7
8
9
10
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
    [login logInWithReadPermissions:@[self.requiredPermission]
                 fromViewController:self
                            handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
        if ([result.grantedPermissions containsObject:self.requiredPermission]) {
          NSLog (@"Sucess!");
        } else {
            [self dismissViewControllerAnimated:YES completion:NULL];
        }
    }];

在实现此功能后,该应用不再快速转到安装在设备上的 Facebook APP 以请求用户权限,而是在应用内显示一个用户可以登录 Facebook 的网页。

我是否使用了正确的代码?有没有办法让我进入 Facebook APP 并让用户确认那里的权限,就像在 3.x SDK 中一样,因为用户已经登录到 Facebook APP,肯定不会再次登录我的应用程序。


1
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];

尝试从下一个状态设置为 login.loginBehavior

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
typedef NS_ENUM(NSUInteger, FBSDKLoginBehavior)
{
/*!
   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
   the device Settings.
   @note If the account is not available to the app (either not configured by user or
   as determined by the SDK) this behavior 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,
};