Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6847645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:46:13+00:00 2026-05-27T00:46:13+00:00

I followed this tutorial , and I wrote the following code in FirstViewController.m: –

  • 0

I followed this tutorial, and I wrote the following code in FirstViewController.m:

- (void) logoutButtonClicked {
    [facebook logout:self];
    NSLog(@"OKKKK");

}

- (void) fbDidLogout {
    // Remove saved authorization information if it exists
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if ([defaults objectForKey:@"FBAccessTokenKey"]) {
        [defaults removeObjectForKey:@"FBAccessTokenKey"];
        [defaults removeObjectForKey:@"FBExpirationDateKey"];
        [defaults synchronize];
    }
}



- (void)viewDidLoad
{
    [super viewDidLoad];
    //lab1.text=@"Connecter1";

    facebook = [[Facebook alloc] initWithAppId:@"302811349736566" 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];
    }
    else {
        UIButton *logoutButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        logoutButton.frame = CGRectMake(40, 40, 200, 40);
        [logoutButton setTitle:@"Log Out" forState:UIControlStateNormal];
        [logoutButton addTarget:self action:@selector(logoutButtonClicked)
               forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:logoutButton];


    }


    // Do any additional setup after loading the view from its nib.

}



- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return [facebook handleOpenURL:url]; 
}

- (void)fbDidLogin {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
    [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
    [defaults synchronize];

}

Is it OK to write the code in FirstViewController and not in AppDelegate? When I connect, the logout button does not appear.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:46:14+00:00Added an answer on May 27, 2026 at 12:46 am

    This method should go in the app delegate, not in your FirstViewController class.

    - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return [facebook handleOpenURL:url]; 
    }
    

    Also, to log out of facebook in your app, I believe you need to log out of the actual facebook app on your phone. Otherwise, create your own log out button and delete the cached facebook token.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i followed the ajax solr tutorial, and in step one i wrote this code.
I am a new facebook application deverloper. I followed this tutorial: http://www.adobe.com/devnet/facebook/articles/video_facebook_quick_start.html but I
I followed this tutorial and the source code : http://blog.objectgraph.com/index.php/2010/04/20/encrypting-decrypting-base64-encode-decode-in-iphone-objective-c/ And then, I downloaded
I followed this tutorial exactly and received the following error after trying to upload
I just started to learn Android and I wrote the following code followed a
I followed this tutorial on configuring the Rails plugin ExceptionNotifier. I know that I
I followed this tutorial: https://github.com/EllisLab/CodeIgniter/wiki/PDF-generation-using-dompdf However, I can't seem to set the path right.
I have followed this tutorial which allowed me to create a Silverlight DataGrid that
I've followed this tutorial: http://anandhansubbiah.com/blog/writing-your-first-android-application/ , but no matter what I do, and what
I followed along this tutorial for django's RSS and ATOM feeds and I got

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.