简体   繁体   English

Facebook对话框失败并显示错误:无法完成操作。 (NSURLErrorDomain错误-999。)

[英]Facebook dialog failed with error: The operation couldn’t be completed. (NSURLErrorDomain error -999.)

I am using the facebook api for ios and i am using facebook dialogs to post. 我正在使用facebook api for ios,我正在使用facebook对话框发布。

The basic idea is that i have a button to post that calls a method and ask if you are logged in to post right away or to perform the log in and then post. 基本的想法是,我有一个发布的按钮调用方法,并询问您是否立即登录发布或执行登录然后发布。 When the second scenario occurs i can't post right after log in to facebook so i have to tap the button and call the method again so i can post. 当第二种情况发生时,我无法在登录到Facebook后立即发布,所以我必须点击按钮并再次调用该方法,以便我可以发布。

The error that facebook sends me says: The operation couldn't be completed. facebook发给我的错误说: 操作无法完成。 (NSURLErrorDomain error -999.) (NSURLErrorDomain错误-999。)

I have read here in stack about it and it says: 我已经在这里阅读了它,它说:

According to "Foundation Constants Reference", error code -999 means "NSURLErrorCancelled". 根据“Foundation Constants Reference”,错误代码-999表示“NSURLErrorCancelled”。

Description: 描述:

Returned when an asynchronous load is canceled. 取消异步加载时返回。 A Web Kit framework delegate will receive this error when it performs a cancel operation on a loading resource. Web Kit框架委托在对加载资源执行取消操作时将收到此错误。 Note that an NSURLConnection or NSURLDownload delegate will not receive this error if the download is canceled. 请注意,如果取消下载,NSURLConnection或NSURLDownload委托将不会收到此错误。 Available in iOS 2.0 and later. 适用于iOS 2.0及更高版本。 Declared in NSURLError.h. 在NSURLError.h中声明。

The question is why facebook is sending me this and how can i solve it? 问题是为什么facebook会发送给我这个,我该如何解决?

If more code is necessary i can put it. 如果需要更多代码,我可以把它。

Thanks in advance. 提前致谢。

The way I fixed this was I changed FBDialog.m to ignore error code -999 like this 我解决这个问题的方法是我改变FBDialog.m以忽略错误代码-999

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
// 102 == WebKitErrorFrameLoadInterruptedByPolicyChange
NSLog(@"FBDialog webView didFailLoadWithError:%@ %d",error.domain,error.code);
if ([error.domain isEqualToString:@"NSURLErrorDomain"] && error.code == -999)
    return;

if ([error.domain isEqualToString:@"WebKitErrorDomain"] && error.code == 102)
    return;

[self dismissWithError:error animated:YES];
}

What's interesting is that FBLoginDialog was already ignoring both error code 102 and -999 whereas FBDialog was only ignoring 102. See for yourself: https://github.com/facebook/facebook-ios-sdk/blob/master/src/FBLoginDialog.m#L85 有趣的是FBLoginDialog已经忽略了错误代码102和-999而FBDialog只忽略了102.请亲自看看: https//github.com/facebook/facebook-ios-sdk/blob/master/src/FBLoginDialog。 M#L85

I don't know if this is the best solution, but I feel slightly more confident about it since another piece of the Facebook sdk code already ignores the same error. 我不知道这是否是最好的解决方案,但我对此感到有点自信,因为另一篇Facebook sdk代码已经忽略了同样的错误。

Well, the good news is that peeps at Facebook agree with your fix: 嗯,好消息是Facebook上的窥视同意你的修复:

(in response to FB bug #168127053284477) (回应FB bug#168127053284477)


  - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
     // 102 == WebKitErrorFrameLoadInterruptedByPolicyChange
-    
  
 
  
  
    if (!([error.domain isEqualToString:@"WebKitErrorDomain"] && error.code == 102)) { 
  
+ // -999 == "Operation could not be completed", note -999 occurs when the user clicks away before
+ // the page has completely loaded, if we find cases where we want this to result in dialog failure
+ // (usually this just means quick-user), then we should add something more robust here to account
+ // for differences in application needs
+ if (!(([error.domain isEqualToString:@"NSURLErrorDomain"] && error.code == -999) ||
+ ([error.domain isEqualToString:@"WebKitErrorDomain"] && error.code == 102))) {
           [self dismissWithError:error animated:YES];
         }
     }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ionic无法加载网页,并显示以下错误:操作无法完成。 (NSURLErrorDomain错误-999。) - ionic failed to load webpage with error: The operation couldn’t be completed. (NSURLErrorDomain error -999.) 该操作无法完成。 (MKErrorDomain错误4) - The operation couldn’t be completed. (MKErrorDomain error 4) 该操作无法完成。 (com.facebook.sdk.core错误3.) - The operation couldn’t be completed. (com.facebook.sdk.core error 3.) 该操作无法完成。 (可可错误1560.) - The operation couldn’t be completed. (Cocoa error 1560.) 该操作无法完成。 (com.facebook.sdk.login错误301。) - The operation couldn’t be completed. (com.facebook.sdk.login error 301.) 无法保存到数据存储:无法完成操作。 (可可错误133020.) - Failed to save to data store: The operation couldn’t be completed. (Cocoa error 133020.) “这项行动无法完成。 (可可错误512.)“ - “The operation couldn’t be completed. (Cocoa error 512.)” 收到错误消息“操作无法完成。 (com.facebook.sdk错误5。)',当从iphone在Facebook上发布视频时 - Getting error 'The operation couldn’t be completed. (com.facebook.sdk error 5.)' when Posting video on facebook from iphone Facebook身份验证错误-操作无法完成 - Facebook authentication error - The operation couldn’t be completed 位置管理器错误:操作无法完成。 (kCLErrorDomain错误0。) - Location Manger Error: The operation couldn’t be completed. (kCLErrorDomain error 0.)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM