MCKapur
MCKapur

Reputation: 9157

Facebook Connect Logging In Issues

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:@"[email protected]"] 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]) {
   NSArray *permissions = [[NSArray alloc] initWithObjects:
                    @"user_likes", 
                    @"read_stream",
                    nil];
  [facebook authorize:permissions];
   [permissions release];
    }

   NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self   selector:@selector(makeVisibleButtons) userInfo:nil repeats:NO];
      }

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 {
  return [self.facebook handleOpenURL:url]; 
NSLog(@"handleOpenURL");

   }

- (void)fbDidLogin {

  NSLog(@"log in");
  NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
  [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
  [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
   [defaults synchronize];

    }

I don't understand why. Especially if it was working before. Do you have any ideas?

Upvotes: 0

Views: 354

Answers (1)

Dinesh Raja
Dinesh Raja

Reputation: 8501

Facebook API having SSO(Single Sign On). So It will ask the user to login for only one time. This login is valid till that login tokens are expired. Check your code itself that you are storing your token and expiration time in NSUserDefaults. This will help the API to login again. If you want to make sure your app login functionality is working or not, then delete your app from simulator and again run it. It will ask your login credentials for the first time only. Hope you undertand.

Upvotes: 2

Related Questions