First dialog after authenticating fails immediately and closes dialog

非 Y 不嫁゛ 提交于 2019-11-27 04:24:57

Just an update for everyone, it's finally assigned to somebody at Facebook: https://developers.facebook.com/bugs/168127053284477 - hopefully it will be fixed soon.

Meanwhile, somebody sent a pull request on github with a fix: https://github.com/facebook/facebook-ios-sdk/pull/436

Hope it helps someone, as I was still facing the same bug..

I was also occasionally getting this -999 NSURLDomainError when trying to bring up the facebook post window. I took the strategy of ignoring the error code as Senior mentions in the comments.

The reason I don't feel so bad about this fix is that the FBLoginDialog actually already ignores this error. Check out the code in github:

https://github.com/facebook/facebook-ios-sdk/blob/master/src/FBLoginDialog.m#L85

So to be specific, here's what my webView:didFailLoadWithError method looks like in FBDialog.m now:

- (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];
}

In FBDialog.m, change this:

UIWindow* window = [UIApplication sharedApplication].keyWindow;
if (!window) {
    window = [[UIApplication sharedApplication].windows objectAtIndex:0];
}

To this:

UIWindow* window = [[UIApplication sharedApplication].windows objectAtIndex:0];

Problem solved! For me, at least.

Until facebook patch their SDK, I did'nt find any better solution than this one :

- (void)dialog:(FBDialog *)dialog didFailWithError:(NSError *)error{

    if([error code] == -999){
        DLog(@"Error -999 found re-open webview");

        [facebook dialog:@"apprequests"
               andParams:_dialogParams
             andDelegate:self];

    }else{
        DLog(@"Error opening facebook dialog : %@", [error description]);
    }
}

This has been fixed with the 3.0 SDK, so I'm going to close this question. Solution: upgrade the SDK to 3.0.

I traced it back as far as I think I can in dialog.m, which is line 414--dialog.m is sending the URLRequest for the dialog in a web view, but the web view is apparently getting an error back from Facebook's server.

I tried calling my [facebook dialog:@"feed"...] code after a 10 second delay after authentication, no dice--same error.

So then just for grins, I called my feed code from -dialog:didFailWithError... after checking to see if it was error -999. It works fine from that call. ????

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!