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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:53:59+00:00 2026-05-31T19:53:59+00:00

UPDATE: I’ve realized that the below problem only occurs if the user has already

  • 0

UPDATE: I’ve realized that the below problem only occurs if the user has already given Facebook access to my app, and then reinstals my app. The first time the user selects the Facebook button in my app, it goes to the Facebook app to get authentication, but since the authentication status is still saved in the Facebook app, it returns immediately to my app without explanation to the user, and the postToFacebookWall method fails.

UPDATE 2: I ended up implementing the solution found here: How to authorize user through a DIALOG with the NEW Facebook Connect iOS API? and avoided the Facebook app. Safari is better because at least the user gets a message saying that they will be logging in. However the Feed Dialogue still fails the first time as before.


I’m having what must be a common problem, but I haven’t been able to find the solution yet. Note that my app is restricted to iOS 5 and above.

I have an app with a Facebook button for posting to a users wall. When the button is pressed, the app will check to see if the user has already given permission to the app to post to the wall. If they have, a view pops up with a Feed Dialog with the wall post information. If they haven’t, Safari will be opened and the user will be allowed to login. After logging in they will be taken back to the app and the Feed Dialog view will pop up.

This works on the Simulator, and on my device, if the Facebook app is not installed. If the Facebook app is installed, the user is taken to the Facebook app, but then immediately returned to the original app, without allowing the user to do anything. The Feed Dialog pops up, but it is completely blank and dismisses automatically. Pressing the Facebook button again will bring up the Feed Dialog view as it is supposed to once the user has given permission to the app to post to their wall.

I pretty much followed the instructions found here:
http://developers.facebook.com/docs/mobile/ios/build/#implementsso

and here:
http://developers.facebook.com/docs/reference/dialogs/feed/

In the AppDelegate I have the following code:

- (void)loginToFacebook
{
    // Set up facebook
    self.facebook = [[Facebook alloc] initWithAppId:@"YOUR_APP_ID" andDelegate:self];

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    if ([defaults objectForKey:@"FBAccessTokenKey"] 
        && [defaults objectForKey:@"FBExpirationDateKey"]) {
        self.facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
        self.facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
    }

    if (![self.facebook isSessionValid]) {
        [self.facebook authorize:nil];
    }
}

// This is an FBSessionDelegate protocol method
// that gets called after a successful login
- (void)fbDidLogin 
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:[self.facebook accessToken] forKey:@"FBAccessTokenKey"];
    [defaults setObject:[self.facebook expirationDate] forKey:@"FBExpirationDateKey"];
    [defaults synchronize];

    [[NSNotificationCenter defaultCenter] postNotificationName:@"POST_TO_FACEBOOK_WALL" object:nil];
}

// This is a UIApplicationDelegate protocol method
// It is called when safari is dismissed
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication annotation:(id)annotation 
{
    return [self.facebook handleOpenURL:url]; 
}

The only difference between this and the sample code is that I added an NSNotification that is picked up by my view controller, where I have the following code:

    - (void)facebookButtonPressed:(UIControl*)sender 
    {
        Facebook *facebook = [(AppDelegate*)[[UIApplication sharedApplication] delegate] facebook];

        if (![facebook isSessionValid])
        {
            // Login to facebook if not already logged in
            [(AppDelegate*)[[UIApplication sharedApplication] delegate] loginToFacebook];
        }
        else 
        {
            [self postToFacebookWall];
        }

    }

    - (void)postToFacebookWall
    {
        Facebook *facebook = [(AppDelegate*)[[UIApplication sharedApplication] delegate] facebook];

        /*Facebook Application ID*/
        // TODO: Get this either from the AppDelegate facebook property or the info plist
        NSString *client_id = @"YOUR_APP_ID";

        NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
  kAppId, @"app_id",
  @"http://developers.facebook.com/docs/reference/dialogs/", @"link",
  @"http://fbrell.com/f8.jpg", @"picture",
  @"Facebook Dialogs", @"name",
  @"Reference Documentation", @"caption",
  @"Using Dialogs to interact with users.", @"description",
  nil];

        [facebook dialog:@"feed" andParams:params andDelegate:self];
    }

Does anyone know how to fix my issue? (Also, in case it isn’t clear, YOUR_APP_ID is replaced with my app id in my code).

  • 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-31T19:54:00+00:00Added an answer on May 31, 2026 at 7:54 pm

    I ended up solving my questions by implementing the two solutions found here:

    https://stackoverflow.com/a/5683454/472344

    https://stackoverflow.com/a/9137887/472344

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

Sidebar

Related Questions

Update: Solved, with code I got it working, see my answer below for the
Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
Update I want to have an expression (XPath, or Regex Expression, similar) that can
Update 2: thanks again to @deepak-azad, I managed to solve my problem : here
Update : Properly initialising string with char string[sizeof buffer - 1] has solved the
UPDATE: Sorry I was wrong with my assumption of the problem. Its due to
Update: The multiple device screen dimensions is a red herring - the problem is
* UPDATE: *I've already answered my question. But you can still give me advise
UPDATE maybe changing the Bitmap size in the new Activity may fix the problem
Update: -[NSIndexPath row]: message sent to deallocated instance 0x895fe70 When I run my app

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.