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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:17:35+00:00 2026-05-30T09:17:35+00:00

I am making and app that you modify images and then you could upload

  • 0

I am making and app that you modify images and then you could upload it to Twitter, Facebook, etc… My problem it’s with Facebook. also fbDidLogin never called. I Follow allot of tutorials to this and search allot and try allot of solutions and nothing.

Because i don’t know if the user will export the photo to Facebook I login it only when its necessary I leave the code. I hope someone can help me.

What I need it’s to publish my image that I create into the users wall

//<FBSessionDelegate, FBDialogDelegate, FBRequestDelegate>

- (void)publishFacebook:(UIImage *)img {

    [self loginFacebook];
    NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                        img, @"picture", @"Testing...", @"caption",
                                        nil];
    [_facebook requestWithGraphPath:@"me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self];
    NSLog(@"Image posted");
}

- (void)loginFacebook {

    if (_facebook == nil) {
        _facebook = [[Facebook alloc] initWithAppId:kAppId 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 arrayWithObjects:@"email", @"offline_access", @"publish_stream", nil];
        [_facebook authorize:permissions];
        [defaults synchronize];
    }
}

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

}

And in my app delegate

// Pre 4.2 support
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return [[_viewController facebook] handleOpenURL:url]; 
}

// For 4.2+ support
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    return [_viewController.facebook handleOpenURL:url]; 
}

It go to the Facebook app, and it request all the permissions etc.. and IT said in the console “Image Published” but if I stay in Facebook app without accepting or declining, just stay there it execute the upload image…

If in the Facebook App I accept all the permissions it return to my normal app. The app Delegate methods are return normal values a webpage of Facebook with a really long string.

What could I do?

Thanks

  • 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-30T09:17:37+00:00Added an answer on May 30, 2026 at 9:17 am

    Try this code…

        -(void)buttonPressed:(id)sender{ //start the facebook action by clicking any button
        facebook = [[Facebook alloc] initWithAppId:@"YOUR_APP_ID" 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{
        [self postWall];
        }
        // Pre 4.2 support
        - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
            return [facebook handleOpenURL:url]; 
        }
    // after 4.2 support
        - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
      sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
        return [facebook handleOpenURL:url]; 
    }
        - (void)fbDidLogin {
            NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
            [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
            [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
            [defaults synchronize];
            [self postWall];
        }
        -(void)postWall{
    
              NSString *filePath = [[NSBundle mainBundle] pathForResource:@"image" ofType:@"jpg"];
    NSData *imageData = [NSData dataWithContentsOfFile:filePath];
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"Test message", @"message", imageData, @"source", nil];
    [facebook requestWithGraphPath:@"me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self];
    
            NSLog(@"Image posted");
        }
    -(void)fbDidNotLogin:(BOOL)cancelled{
        if (cancelled) {
            UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"Could not Login" message:@"Facebook Cannot login for your application" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
            [alertView show];
        }
    }
    

    Check out did you put delegate to FBsessionDelegate,FBRequestDelegate in your controller File.Try to run your facebook in your app itself and NOT in SAFARI.To do that check this link. Facebook Implementation within app (without opening in safari or native app)

    EDITED:
    Changed code with postWall method and added fbDidNotLoginMethod.This is the correct one.

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

Sidebar

Related Questions

Im making an app that shows images from a Tumblr account. It loads the
im making an app that interacs with a webservie which then gets data from
So im making an app that creates events by filling in a form then
i'm making app that the main page include TableView but i want when i
I am making app that takes a screenshot of a URL requested by the
Im making an app that should let the user see video from the camera
I am making an app that records a destination (a city, state, country, town,
I'm making an app that is requesting data from a Web Service (implementing Soap).
I am making an app that has both a bottom bar and a top
I am making an app that will play sound on events but I can't

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.