IOS : com.facebook.sdk error 5

倾然丶 夕夏残阳落幕 提交于 2019-12-23 03:58:30

问题


Am using the last Facebook SDK for IOS but I always get this error : The operation couldn’t be completed. (com.facebook.sdk error 5.) Please do you have any idea about that ? Thank You.

[[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
    if (!error) {
        NSLog(@"%@",user.name);
        //self.emailLabel.text = [user objectForKey:@"email"];
    } else {
        NSLog(@"%@",error.localizedDescription);
    }
}]; 

回答1:


add the following code in AppDelegate File.

- (void)applicationDidBecomeActive:(UIApplication *)application {
    [FBAppEvents activateApp];
    [FBAppCall handleDidBecomeActive];
    [FBSession openActiveSessionWithAllowLoginUI:NO];
}

The graph API calls used to work when I used to do the login & then make any calls. But when I used to re-open the app, the graph API call to get the photos used to fail with error code 5. So, after looking into FBSession class, I found that [FBSession openActiveSessionWithAllowLoginUI:NO]; call would make the session active. And thus the issue got fixed.




回答2:


I have solved this kind of issue by doing this :

[FBSession setActiveSession:session];

Thank you !



来源:https://stackoverflow.com/questions/20520195/ios-com-facebook-sdk-error-5

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