嗨,我在http://developers.facebook.com/上阅读和阅读教程。
关于登录Facebook并发布应用程序的Feed,我的问题是我根本无法登录Facebook。
而且我无法正常工作。令人讨厌,烦人,对此没有明确的教程/说明。
我尝试从我的应用登录,然后打开Safari浏览器,然后该URL就像发疯一样
闪烁
而且我没有收到错误,为什么?
是否有关于登录的CLEAR教程?
它可以在模拟器上很好地运行,但不能在设备上运行。
我目前在Xcode 4.5 Beta上,但在4.4上也无法使用。
我需要帮助!
[CLOSED]
编辑:我已解决问题!我真是愚蠢……我为了登录FB挣扎了7天,
然后我进行了更改(设备上的 Cookies允许),一切正常!
该死的设备只需要一些 cookies 。
最佳答案
我大约2周前才更新到最新的FB sdk。这是我完成的方式:
//FB recommends to put these two in the app delegate in their sample apps but you can place them other places
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSArray *permissions = [NSArray arrayWithObjects:@"publish_actions", nil];
return [FBSession openActiveSessionWithPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
NSLog((@"session.state is %d",session.state));
if(session.state==513){
[AppPrefererences sharedAppPrefererences].faceBookLoggedIn=YES;
NSLog((@"facebookLogin pref has been set to yes from inside appDelegate"));
}
else{
[AppPrefererences sharedAppPrefererences].faceBookLoggedIn=NO;
}
}];
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
// FBSample logic
// We need to handle URLs by passing them to FBSession in order for SSO authentication
// to work.
return [FBSession.activeSession handleOpenURL:url];
}
//Then whereever you want to initiate the log in (i use mine in a tableView)
AppDelegate *appDelegate =(AppDelegate*) [[UIApplication sharedApplication]delegate];
if (![appDelegate openSessionWithAllowLoginUI:NO]) {
[appDelegate openSessionWithAllowLoginUI:YES];
facebookLoginLabel.text=@"Facebook Log Out";
[AppPrefererences sharedAppPrefererences].faceBookEnabled=YES;
}
else{
facebookLoginLabel.text=@"Facebook Log In";
[AppPrefererences sharedAppPrefererences].faceBookLoggedIn=NO;
[FBSession.activeSession closeAndClearTokenInformation];
}
然后,无论您要发布到哪里,都可以这样做:
[FBRequestConnection startForPostStatusUpdate:@"any thing you want to post"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error){}];
而且,也不要忘记设置FBLoginViewDelegate
如果您有任何疑问,请告诉我!希望能帮助到你!
关于ios - Xcode Facebook登录错误已关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12432983/