Facebook SSO不登录(isSessionValid一直返回NO) [英] Facebook SSO Not Logging In (isSessionValid returns NO all the time)
问题描述
- (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屋!