gpt4 book ai didi

ios - PFFacebookUtils logInInBackgroundWithReadPermissions : block: opens Facebook app instead of using system account

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:58:01 26 4
gpt4 key购买 nike

我已经升级到 ParseFacebookUtilsV4 并且我已经更新了我的登录代码:

[PFFacebookUtils logInInBackgroundWithReadPermissions:FACEBOOK_READ_PERMISSIONS block:^(PFUser *user, NSError *error) {
...
}];

但是,现在我的应用程序暂时切换到 Facebook 应用程序并返回。它使用 native Facebook 应用程序登录,同时在设置中仍然有一个有效的 iOS Facebook 帐户。如何让 PFFacebookUtils v4 在可用时使用系统 Facebook 帐户,并且仅在系统帐户不可用时才回退到 Facebook 应用程序?

最佳答案

来自 ParseFacebookUtilsV4 的头文件

PFFacebookUtils.h

...

/*! @abstract FBSDKLoginManager provides methods for configuring login behavior, default audience and managing Facebook Access Token.

@returns An instance of FBSDKLoginManager that is used by PFFacebookUtils. */

+ (FBSDKLoginManager *)facebookLoginManager;

因此,据推测,PFFacebookutils 使用了“FBSDKLoginManager”声明,让我们看看这是否有效。事实上,让我们将默认设置为“系统帐户”,...代码如下:

[[PFFacebookUtils facebookLoginManager] setLoginBehavior:FBSDKLoginBehaviorSystemAccount];

[PFFacebookUtils logInInBackgroundWithReadPermissions:FACEBOOK_READ_PERMISSIONS block:^(PFUser *user, NSError *error) {
}];

是的,这段代码可以编译,这段代码可以工作,只需确保在调用登录内容之前声明登录行为,最好在初始化代码库、解析、解析 Facebook 实用程序等时在 AppDelegate 中声明。 .

事实上,为了确保这对您有用,我刚刚下载了最新版本的 PARSE iOS SDK,它具有相同的功能。这是您的选项,它来自 Facebook SDK for iOS,它提供 PFFFacebookUtils:

@typedef FBSDKLoginBehavior enum

@abstract Passed to the \c FBSDKLoginManager to indicate how Facebook Login should be attempted.

@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. */

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,
};

关于ios - PFFacebookUtils logInInBackgroundWithReadPermissions : block: opens Facebook app instead of using system account,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32033660/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com