First dialog after authenticating fails immediately and closes dialog

前端 未结 6 1861
庸人自扰
庸人自扰 2020-11-30 06:40

I\'m using the latest Facebook SDK on iOS 5. I can use SSO to successfully authenticate the user, and then I attempt to share a link like this:

NSString *app         


        
相关标签:
6条回答
  • 2020-11-30 07:18

    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..

    0 讨论(0)
  • 2020-11-30 07:18

    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. ????

    0 讨论(0)
  • 2020-11-30 07:20

    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]);
        }
    }
    
    0 讨论(0)
  • 2020-11-30 07:21

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

    0 讨论(0)
  • 2020-11-30 07:28

    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];
    }
    
    0 讨论(0)
  • 2020-11-30 07:40

    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.

    0 讨论(0)
提交回复
热议问题