FBRequest requestForMe startWithCompletionHandler方法在设备上无法工作 [英] FBRequest requestForMe startWithCompletionHandler method not working on device

查看:107
本文介绍了FBRequest requestForMe startWithCompletionHandler方法在设备上无法工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经遵循Facebook开发者网站上关于将Facebook SDK 3.1整合到iOS 6中的所有方向。我的代码在iPhone 6.0模拟器上完美运行(用户可以登录到Facebook),但是当我在iPhone上运行应用程序时,函数[FBRequest requestForMe] startWithCompletionHandler]不生成响应。根据Facebook开发者网站,它应该是成功的或返回一个错误,但它没有。应用程序只是坐在那里等待一个从来没有来的响应。我的代码如下:

   - (void)populateUserDetails {
if(FBSession.activeSession.isOpen){
[[FBRequest requestForMe] startWithCompletionHandler:
^(FBRequestConnection * connection,NSDictionary< FBGraphUser> * user,NSError * error){
if(!error){
NSLog在);
} else {
NSLog(@error:%@,error);
}
}];
} else {
NSLog(@no active session);
}
}

使用断点,我确定activeSession始终打开,所以startWithCompletionHandler:方法实际上被调用。也许这是一个构建问题,因为它在模拟器上运行良好?任何想法?

解决方案

回答我自己的问题:转到您的Facebook应用页面,确保0自动插入您的App Store ID。我已经将我的软件包ID设置为正确的值(您也必须这样做),但是一夜之间,Facebook自动将App Store ID值设置为0.一旦我删除了该值,一切都会工作。


I have followed all the directions from the Facebook Developer website about integrating Facebook SDK 3.1 into iOS 6. My code runs perfectly on the iPhone 6.0 Simulator (user can log into Facebook), but when I run the app on my iPhone, the function [FBRequest requestForMe] startWithCompletionHandler] doesn't generate a response. According to the Facebook Developer website, it should either be successful or return an error, but it does neither. The app just sits there waiting for a response that never comes. My code is below:

- (void)populateUserDetails {
    if (FBSession.activeSession.isOpen) {
        [[FBRequest requestForMe] startWithCompletionHandler:
         ^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
             if (!error) {
                NSLog(@"logged in");
             } else {
                 NSLog(@"error: %@", error);
             }
         }];
    } else {
       NSLog(@"no active session");
    }
}

Using breakpoints, I determined that the activeSession is always open, so the startWithCompletionHandler: method is actually called. Maybe it's a build problem since it runs fine on the Simulator? Any ideas?

解决方案

Answered my own question: go to your Facebook app page and make sure that a "0" value hasn't been inserted automatically for your App Store ID. I had already set my bundle ID to the correct value (which you also have to do), but overnight, Facebook automatically set the App Store ID value to 0. Everything worked as soon as I removed that value.

这篇关于FBRequest requestForMe startWithCompletionHandler方法在设备上无法工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆