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 8133647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:40:56+00:00 2026-06-06T09:40:56+00:00

I have a very simple question. In FB tutorial https://developers.facebook.com/docs/mobile/ios/build/ it starts to login

  • 0

I have a very simple question.

In FB tutorial https://developers.facebook.com/docs/mobile/ios/build/ it starts to login inside didFinishLaunchingWithOptions – right after applications’s launch.

I need to login on tap, then wait for a callback and send a message on the FB wall.
I think Hackbook app example design application is too complicated for this purpose.

What is the simplest way to achieve this?

UPD: I’ve followed the Hackbook example, but ViewControllers still didn’t get a callback 🙁

yAppDelegate.h:


    #import 
    #import "FBConnect.h"
    
    @interface yAppDelegate : UIResponder 
    {
        Facebook *facebook;
        
    }
    
    @property (strong, nonatomic) UIWindow *window;
    @property (nonatomic, retain) Facebook *facebook;
    
    @end

yAppDelegate.m:


    #import "yAppDelegate.h"
    #import "yViewController.h"
    
    static NSString* kAppId = @"350435425024264";
    
    @implementation yAppDelegate
    
    @synthesize window = _window;
    @synthesize facebook;
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {    
        yViewController *viewController = [[yViewController alloc] init];
        
        facebook = [[Facebook alloc] initWithAppId:kAppId andDelegate:viewController];
        
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) {
            facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
            facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
        }
        
        return YES;
    }
    
    - (void)applicationDidBecomeActive:(UIApplication *)application {
        [[self facebook] extendAccessTokenIfNeeded];
    }
    
    - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
        return [self.facebook handleOpenURL:url];
    }
    
    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
        return [self.facebook handleOpenURL:url];
    }

yViewController.h:


    #import 
    #import "FBConnect.h"
    
    @interface yViewController : UIViewController 
    {
        NSArray *permissions;
    }
    
    @property (nonatomic, retain) NSArray *permissions;
    
    @end

yViewController.m


    #import "yViewController.h"
    #import "yAppDelegate.h"
    #import "FBConnect.h"
    
    @interface yViewController ()
    @end
    
    @implementation yViewController
    @synthesize permissions;
    
    - (IBAction)buttonPressed:(UIButton *)sender {
        
        NSLog(@"Button pressed!");
        
        permissions = [[NSArray alloc] initWithObjects:@"offline_access", nil];
        
        yAppDelegate *delegate = (yAppDelegate *)[UIApplication sharedApplication].delegate;
        if (![[delegate facebook] isSessionValid]) {
            [[delegate facebook] authorize:permissions];
        } else {
            //[self showLoggedIn];
        }
        NSLog(@"login!!");
        
    }
    
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
    }
    
    - (void)viewDidUnload
    {
        [super viewDidUnload];
        // Release any retained subviews of the main view.
    }
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    }
    
    #pragma mark - FBSessionDelegate Methods
    /**
     * Called when the user has logged in successfully.
     */
    - (void)fbDidLogin {
        NSLog(@"did login");
    }
    
    -(void)fbDidExtendToken:(NSString *)accessToken expiresAt:(NSDate *)expiresAt {
        NSLog(@"token extended");
    }
    
    /**
     * Called when the user canceled the authorization dialog.
     */
    -(void)fbDidNotLogin:(BOOL)cancelled {
        NSLog(@"fbDidNotLogin");
    }
    
    /**
     * Called when the request logout has succeeded.
     */
    - (void)fbDidLogout {
        
        NSLog(@"fbDidLogout");
        
        // Remove saved authorization information if it exists and it is
        // ok to clear it (logout, session invalid, app unauthorized)
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        [defaults removeObjectForKey:@"FBAccessTokenKey"];
        [defaults removeObjectForKey:@"FBExpirationDateKey"];
        [defaults synchronize];
    
    }
    
    /**
     * Called when the session has expired.
     */
    - (void)fbSessionInvalidated {
        
        NSLog(@"fbSessionInvalidated");
        
        [self fbDidLogout];
    }
    
    #pragma mark - FBRequestDelegate Methods
    /**
     * Called when the Facebook API request has returned a response.
     *
     * This callback gives you access to the raw response. It's called before
     * (void)request:(FBRequest *)request didLoad:(id)result,
     * which is passed the parsed response object.
     */
    - (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response {
        //NSLog(@"received response");
    }
    
    /**
     * Called when a request returns and its response has been parsed into
     * an object.
     *
     * The resulting object may be a dictionary, an array or a string, depending
     * on the format of the API response. If you need access to the raw response,
     * use:
     *
     * (void)request:(FBRequest *)request
     *      didReceiveResponse:(NSURLResponse *)response
     */
    - (void)request:(FBRequest *)request didLoad:(id)result {
        NSLog(@"-(void)request");
    }
    
    /**
     * Called when an error prevents the Facebook API request from completing
     * successfully.
     */
    - (void)request:(FBRequest *)request didFailWithError:(NSError *)error {
        NSLog(@"Err message: %@", [[error userInfo] objectForKey:@"error_msg"]);
        NSLog(@"Err code: %d", [error code]);
    }

@end
  • 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-06-06T09:40:59+00:00Added an answer on June 6, 2026 at 9:40 am

    Do it in exactly the same way that the FB tutorial shows, just move the login code into a button event or whatever you want to trigger it.

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

Sidebar

Related Questions

I have a very simple question. I have a program that accepts an integer
I have a very simple question: Is it possible to change the price of
I have a very simple question for which I can't seem to find an
I have a very simple question in C++. What is the equivalent of x
i have a very simple question, actually this is not the question, this is
I have a very simple Office utility question. Open Microsoft word (2003 or 2007),
I have a very simple yes no question: should static methods have same result
I have what may be a very simple question. I want to process a
I have what is most likely a very simple question.. I am designing a
This is a very simple question yet I have little knowledge in Linux and

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.