Facebook SSO不登录(isSessionValid一直返回NO) [英] Facebook SSO Not Logging In (isSessionValid returns NO all the time)

查看:143
本文介绍了Facebook SSO不登录(isSessionValid一直返回NO)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Facebook Connect与我的应用程序。一切都设置好了,所有的代码都可以工作。昨天,我可以使用我的应用登录,然后发布内容等功能。我不记得做任何真正的改变。现在,像往常一样,每当我按登录,它会到一个Safari页面,我必须确认我想使用这个应用程序,它说我正在登录谁。如果我按OK,它可以回到应用程序。在这个整个过程中,在应用程序中,Facebook从不登录。记住:只要这个工作,我不要再做任何改变!这是连接如何开始:

   - (IBAction)connectToFacebook {

[loginButton setImage: UIImage imageNamed:@LoginWithFacebookPressed@2x.png] forState:UIControlStateNormal];
facebook = [[Facebook alloc] initWithAppId:@387500177929927andDelegate:self];
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
if([defaults objectForKey:@FBAccessTokenKey]&&&&&&默认对象ForKey:@FBExpirationDateKey]){
facebook.accessToken = [defaults objectForKey:@FBAccessTokenKey
facebook.expirationDate = [defaults objectForKey:@FBExpirationDateKey];
}

if(![facebook isSessionValid]){
[facebook authorize:nil];
}
NSTimer * timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(makeVisibleButtons)userInfo:nil repeats:NO];
[timer setAccessibilityHint:@timer];
}

- (BOOL)应用程序:(UIApplication *)应用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//只是手柄URL可以被调用

返回YES;


}

所以我按一个按钮来调用IBAction为。 NSTimer不相关,只是为了出现一些按钮。现在,这两种方法永远不会被调用(当我登录时):

   - (BOOL)应用程序:(UIApplication *)应用程序openURL:(NSURL *)url 
sourceApplication:(NSString *)sourceApplication注释:(id)注释{
ConnectToFB * connect = [[ConnectToFB alloc] init];
return [connect.facebook handleOpenURL:url];
NSLog(@url);
[连接版本];
}

- (void)fbDidLogin {

NSLog(@登录);

NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@FBAccessTokenKey];
[defaults setObject:[facebook expirationDate] forKey:@FBExpirationDateKey];
[默认同步];
}

应用程序ID是最新的,我的信息plist中的url方案也是最新。这里有什么问题?

解决方案

看到这里[输入链接描述] [1]



[1]:故事链接流程使用SSO facebook - openURL不被调用



您可以在AppDelegate中没有Facebook实例


I am using Facebook Connect with my app. Everything is set up, all the code WAS working. Around yesterday, I could login with my app, then post stuff and other functions. I don't recall making any real changes. Now, as usual, whenever I press login and it goes to a Safari page where I have to confirm that I want to use this app and it says who I am logging in as. If I press ok it goes back to the app. During this whole process, in the app, Facebook never logs in. REMEMBER: JUST YESTERDAY THIS WORKS, I DONT RECALL MAKING ANY CHANGES! Here is how the connection starts:

-(IBAction)connectToFacebook {

  [loginButton setImage:[UIImage imageNamed:@"LoginWithFacebookPressed@2x.png"]  forState:UIControlStateNormal];
  facebook = [[Facebook alloc] initWithAppId:@"387500177929927" andDelegate:self];
  NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
  if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults   objectForKey:@"FBExpirationDateKey"]) {
    facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
    facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
  }

  if (![facebook isSessionValid]) {
    [facebook authorize:nil];
  }    
  NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self  selector:@selector(makeVisibleButtons) userInfo:nil repeats:NO];
  [timer setAccessibilityHint:@"timer"];
}

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  // JUST SO THAT HANDLE URL CAN GET CALLED

 return YES;


}

So I press a button to call this IBAction. The NSTimer is not related, its just for the appearance of some buttons. Now, these two methods never get called (when I log it):

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { 
  ConnectToFB *connect = [[ConnectToFB alloc] init];
  return [connect.facebook handleOpenURL:url]; 
  NSLog(@"url");
  [connect release];
}

- (void)fbDidLogin {

  NSLog(@"log in");

  NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
  [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
  [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
  [defaults synchronize];    
}

The app id is up to date and my url schemes in info plist is also up to date. What is the problem here?

解决方案

See this [enter link description here][1]

[1]: Story link flow using SSO facebook - openURL not being called .

You propably don't have facebook instance in AppDelegate

这篇关于Facebook SSO不登录(isSessionValid一直返回NO)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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