简体   繁体   English

iOS FacebookSDK请求对话框错误

[英]IOS FacebookSDK apprequests dialog error

I'm trying to find solution for my problem during two days. 我正在尝试在两天内为我的问题找到解决方案。 And I want to say what I'm sure what I've read all resource where you could give me a links =) The problem is. 我想说什么,我确定我已经阅读了所有可以给我链接的资源=)问题是。 I'm using FacebookSDK 3.1 for iOS. 我正在使用iOS的FacebookSDK 3.1。 And trying to make apprequests dialog... The code is simple 并尝试创建请求对话框...代码很简单

session =[[FBSession alloc]initWithAppID:@"XXXXXXXXXXXX" permissions:nil urlSchemeSuffix:@"xxxxxxxxxxxx" tokenCacheStrategy:nil];
    [FBSession setActiveSession:session];
      [self ShowSessionState:session.state];
      NSLog(@"Acces token data: %@",[session accessToken]);  

      [session openWithCompletionHandler:^(FBSession *psession, FBSessionState status, NSError *error) {
         // NSLog(@"I'm in");

         Facebook * facebook = [[Facebook alloc] initWithAppId:@"XXXXXXXXXXXX" urlSchemeSuffix:@"xxxxxxxxx" andDelegate:nil];

                 [facebook setAccessToken:FBSession.activeSession.accessToken];
                 [facebook setExpirationDate:FBSession.activeSession.expirationDate];

                 [facebook dialog:@"apprequests" andDelegate:nil];

           }];

And all what I see.. just Frame with error - Api Error Code:110; 和所有我看到的..只是有错误的框架-Api错误代码:110; Api Error Description: invalid user Id; Api错误说明:无效的用户ID; Error message: Missing user cookie (to validate session user). 错误消息:缺少用户cookie(以验证会话用户)。 But the authorization is successful... I have a valid accessToken.. can get my friends or my own FB data. 但是授权成功了。我有一个有效的accessToken ..可以获取我的朋友或自己的FB数据。

As I said I've read a lot of resources.... And really the many people have same problem, but I don't found any useful solution for this problem. 正如我说的,我已经阅读了很多资源。。。。的确有很多人有同样的问题,但是我没有找到任何有用的解决方案。 So help me, please. 请帮帮我。

I'm found a solution, maybe it will help somebody else . 我找到了一个解决方案, 也许会对其他人有所帮助 Actually it looks like exorcism but works) So the problem is: If you logged in facebook from safary or Facebook app, webview doesn't save any cookie... so you need make you logging from webview. 实际上,它看起来像是驱魔,但是有效。因此,问题是:如果您从Safari或Facebook应用程序登录Facebook,则webview不会保存任何cookie ...因此您需要使您从webview登录。 You can do it with FBConnect package (read more in google). 您可以使用FBConnect软件包(在Google中了解更多)来做到这一点。 In Facebook.m file you need change code like this: 在Facebook.m文件中,您需要这样的更改代码:

[self authorizeWithFBAppAuth:YES safariAuth:YES];

to

[self authorizeWithFBAppAuth:NO safariAuth:NO]; 

In that case when you will use 在这种情况下,您将使用

[facebook authorize:permissions];  

The login come always in webview and you can use any dialogs like apprequests etc. The one more problem)) Login Dialog doesn't appear? 登录名总是出现在webview中,您可以使用诸如apprequests等之类的任何对话框。还有一个问题)) 登录对话框没有出现? It's one more Facebook bug)) To solve this you just need make a delay when call it: 这是另外一个Facebook错误))要解决此问题,您只需在调用它时稍加延迟即可:

[self performSelector:@selector(showFBLoginDialog) withObject:nil afterDelay:1];

- (void)showFBLoginDialog {
    NSArray *permissions = [[NSArray alloc] initWithObjects:
                            @"offline_access",
                            @"publish_actions",
                            @"read_stream",
                            @"user_photos",
                            @"email",
                            @"publish_stream",
                            @"user_likes",
                            @"user_about_me", nil];
    [facebook authorize:permissions];    
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM