gpt4 book ai didi

ios - Facebook iOS SDK 请求权限 publish_actions,但用户需要再次输入密码

转载 作者:行者123 更新时间:2023-11-29 12:28:28 25 4
gpt4 key购买 nike

我项目中使用的是Facebook iOS SDK 3.8,现在升级到3.22。

在请求“publish_actions”权限时发生了一件奇怪的事情,即用户需要重新输入她的帐户和密码。而在以前的版本中,“重新登录”部分将被跳过。我想知道 Facebook SDK 中的逻辑是否发生变化,或者我必须更改 session 处理过程。关于这个问题有什么想法吗?

我以前申请“publish_actions”权限的方式是:

 [activeSession openWithBehavior: FBSessionLoginBehaviorForcingWebView
completionHandler:^(FBSession *session,
FBSessionState state, NSError *error) {
[session reauthorizeWithPermissions:@[@"publish_actions"]
isRead:NO
behavior:FBSessionLoginBehaviorForcingWebView
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
}

我也试过了

[FBSession.activeSession requestNewPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
__block NSString *alertText;
__block NSString *alertTitle;
_reauthorizeInProgress = YES;
if (!error) {
if ([FBSession.activeSession.permissions
indexOfObject:@"publish_actions"] == NSNotFound){
// Permission not granted, tell the user we will not publish
alertTitle = @"Permission not granted";
alertText = @"Your action will not be published to Facebook.";
[[[UIAlertView alloc] initWithTitle:alertTitle
message:alertText
delegate:self
cancelButtonTitle:@"OK!"
otherButtonTitles:nil] show];
} else {
// Permission granted, publish the OG story

}

} else {
// There was an error, handle it
// See https://developers.facebook.com/docs/ios/errors/
}
}];

最佳答案

此行为是 Facebook 的默认设置。文档https://developers.facebook.com/docs/facebook-login/ios/v2.2说:

The Disadvantage of WebView is:

People have to fill in their login credentials every time they go through the login flow.

在FBSession.m文件中,我更改了方法中的代码

- (void)retryableAuthorizeWithPermissions:(NSArray *)permissions
defaultAudience:(FBSessionDefaultAudience)defaultAudience
integratedAuth:(BOOL)tryIntegratedAuth
FBAppAuth:(BOOL)tryFBAppAuth
safariAuth:(BOOL)trySafariAuth
fallback:(BOOL)tryFallback
isReauthorize:(BOOL)isReauthorize
canFetchAppSettings:(BOOL)canFetchAppSettings

并且在请求另一个权限时不要删除cookie,替换

   // To avoid surprises, delete any cookies we currently have.
[FBUtility deleteFacebookCookies];

    // To avoid surprises, delete any cookies we currently have.
if(!isReauthorize){
[FBUtility deleteFacebookCookies];
}

我同意修改SDK源码不是一个好主意,但我应该在用户体验的一致性和代码风格之间做一些平衡。 ;(

关于ios - Facebook iOS SDK 请求权限 publish_actions,但用户需要再次输入密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28402388/

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