0

I need facebook login for my app.when i login through the Facebook it will redirect me to my app and also i need access token to be in console.Anyone can give me the code..i read many links but not getting.how to do this?? I am new to this so,some one can give me the code.please.

Ninja
  • 57
  • 1
  • 8
  • Check out samples coming with Facebook SDK that's all you need. – limon Nov 29 '12 at 06:51
  • Follow these Questions it is helpful : http://stackoverflow.com/questions/13153307/how-to-do-facebook-login-in-ios-6 http://stackoverflow.com/questions/10888582/facebook-login-give-me-already-authorized-this-app-without-automatic-returning-t – Omar Freewan Nov 29 '12 at 06:51
  • What have you tried? What did or didn't work? The documentation for the [Facebook iOS SDK](https://developers.facebook.com/docs/reference/iossdk/) should have all you need. – Michael Mior Nov 29 '12 at 07:11

2 Answers2

0

I don't really know every word you said. However, implementing Facebook login is as simple as importing the SDK and call the openSession() (or something like that). You can get it done in less than 30 minutes by following the Facebook SDK tutorial. It's dead simple.\

    const BOOL succeed = [FBSession openActiveSessionWithPermissions:
                                [[NSArray alloc] initWithObjects:@"publish_stream", @"user_photos", @"user_likes", nil]
                                                           allowLoginUI:YES
                                                      completionHandler:^(FBSession *session, FBSessionState state, NSError *error)
    {// Check state}];

You call to this simple method with your desired permissions. allowLoginUI should be YES so that a dialog will be displayed. You check for the state in your completion handler. If the state is FBSessionStateOpen, you can proceed with your Facebook requests.

There is no need to store Facebook token in the latest SDK.

ABCD
  • 7,914
  • 9
  • 54
  • 90
  • yes it might be simple for you..but i am new to it..i just need a facebook login page,when login there will redirect to my app..now got it.. – Ninja Nov 29 '12 at 06:52
  • What do you mean by redirect to your app? If you login to Facebook, you will be automatically switched back to your iOS app. – ABCD Nov 29 '12 at 06:55
  • thats i mean only..can you help me?? – Ninja Nov 29 '12 at 06:56
  • Look at the the edit. You just need one method to do what you want!!!! – ABCD Nov 29 '12 at 07:08
0

Try this. Drag sdk files to your project, then write following code.

Facebook *faceBook = [[Facebook alloc] initWithAppId:FACEBOOK_APPID];
NSArray* permissions =  [[NSArray arrayWithObjects:
                          @"email",@"publish_stream",@"offline_access", nil] retain];
[faceBook authorize:permissions delegate:self];
Ganee....
  • 302
  • 2
  • 13