gpt4 book ai didi

iOS Facebook SDK 3.1 openActiveSessionWithReadPermissions : Detect when user is not granting access

转载 作者:可可西里 更新时间:2023-11-01 06:16:19 25 4
gpt4 key购买 nike

我需要知道用户在 openActiveSessionWithReadPermissions 执行期间何时未授予 Facebook 访问我的应用程序的权限。 (未授予意味着在“设置”->“Facebook”->“我的应用”下将开关设置为“关闭”。)

这是未授权时的错误:

Error Domain=com.facebook.sdk Code=2 "The operation couldn’t be completed. (com.facebook.sdk error 2.)" UserInfo=0x1fd46780 {com.facebook.sdk:ErrorLoginFailedReason=com.facebook.sdk:ErrorLoginFailedReason}

为了比较,这里是没有网络的错误:

Error Domain=com.facebook.sdk Code=2 "The operation couldn’t be completed. (com.facebook.sdk error 2.)" UserInfo=0x1edf2eb0 {com.facebook.sdk:ErrorLoginFailedReason=com.facebook.sdk:ErrorLoginFailedReason, com.facebook.sdk:ErrorInnerErrorKey=Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo=0x1ed47a20 {NSErrorFailingURLKey=https://api.facebook.com/method/auth.iosauthorizeapp, NSErrorFailingURLStringKey=https://api.facebook.com/method/auth.iosauthorizeapp, NSLocalizedDescription=The Internet connection appears to be offline.}}

是否有一种万无一失的方法来检测用户何时未被授予权限?我是否只在 UserInfo 字典中查找错误代码 2 和一对键/值?

我希望 Facebook 给我们一个 BOOL granted 就像在 ACAccountStoreRequestAccessCompletionHandler 中一样。

最佳答案

@peter-warbo:我没有找到好的解决方案。我正在使用这个:

[FBSession openActiveSessionWithReadPermissions:FACEBOOK_READ allowLoginUI:YES 
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {

// find error for not granted
if(error && error.code == 2) {
NSDictionary *userInfo = error.userInfo;
if(userInfo && userInfo.count == 1) {
[self fallbackLogin];
return;
}
}
[self sessionStateChanged:session state:state error:error];
}];

- (void)fallbackLogin {

// use deprecated
[FBSession openActiveSessionWithPermissions:FACEBOOK_READ allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
}

关于iOS Facebook SDK 3.1 openActiveSessionWithReadPermissions : Detect when user is not granting access,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13619214/

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