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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:06:30+00:00 2026-06-15T01:06:30+00:00

I am implementing facebook posting in my app. And add some code to post

  • 0

I am implementing facebook posting in my app. And add some code to post something on facebook account.
My code is as follows.

    - (void)publishStory
{
 NSLog(@"publish story called .......");

 [FBRequestConnection
  startWithGraphPath:@"me/feed"
  parameters:self.postParams
  HTTPMethod:@"POST"
  completionHandler:^(FBRequestConnection *connection,
                      id result,
                      NSError *error) {
   NSString *alertText;
   if (error) {
    alertText = [NSString stringWithFormat:
                 @"error: domain = %@, code = %d",
                 error.domain, error.code];
   } else {
    alertText = [NSString stringWithFormat:
                 @"Posted action, id: %@",
                 [result objectForKey:@"id"]];
   }
   // Show the result in an alert
   [[[UIAlertView alloc] initWithTitle:@"Result"
                               message:alertText
                              delegate:self
                     cancelButtonTitle:@"OK!"
                     otherButtonTitles:nil]
    show];
  }];
}

-(IBAction)cancelButtonAction
{
 [[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
}

-(IBAction)shareButtonAction
{
 // Add user message parameter if user filled it in
 if (![self.postMessageTextView.text isEqualToString:@""]) {
  [self.postParams setObject:self.postMessageTextView.text
                      forKey:@"message"];
 }

 // Ask for publish_actions permissions in context
 if ([FBSession.activeSession.permissions
      indexOfObject:@"publish_actions"] == NSNotFound) {
  // No permissions found in session, ask for it
   [FBSession.activeSession reauthorizeWithPublishPermissions:
   [NSArray arrayWithObjects:@"publish_actions",@"publish_stream", nil]
   defaultAudience:FBSessionDefaultAudienceFriends
   completionHandler:^(FBSession *session, NSError *error) {
    if (!error) {
     // If permissions granted, publish the story
     NSLog(@"not error");
     [self publishStory];
    }
   }];
 } else {
  // If permissions present, publish the story
  NSLog(@"In else condition");
  [self publishStory];
 }
}

this is too much code for , “as ios 6 contains integrated facebook in settings.”
But I want to post like twitter integration in ios.How can we do that

  • 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-15T01:06:31+00:00Added an answer on June 15, 2026 at 1:06 am

    There are two ways for posting.

    1)Post using FBNativeDialog. (inlcude FacebookSDK.framework)
    2)Post via SLComposeViewController.

    Which one you want to use is up to you.You need to add three frameworks named AdSupport.framework,Accounts.framework and Social.framework.
    For using first one you have to include #import “FacebookSDK/FacebookSDK.h” and code for posting is as follows:

         UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"" message:@"" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    
     BOOL displayedNativeDialog = [FBNativeDialogs presentShareDialogModallyFrom:self initialText:@"" image:[UIImage imageNamed:@"iossdk_logo.png"] url:[NSURL URLWithString:@"https://developers.facebook.com/ios"]
      handler:^(FBNativeDialogResult result, NSError *error)
     {
       if (error) {
        alert.message=@"Fail posting due to some error!";
        [alert show];
        /* handle failure */
       } else {
        if (result == FBNativeDialogResultSucceeded) {
         alert.message=@"Posted Successfully!";
         [alert show];
         /* handle success */
        } else {
         /* handle user cancel */
        }
       }}];
    
     if (!displayedNativeDialog) {
      /* handle fallback to native dialog  */
     }
    

    For second one you need #import “Social/Social.h” and the code is as follows:

         SLComposeViewController *fbComposer =
     [SLComposeViewController
      composeViewControllerForServiceType:SLServiceTypeFacebook];
    
    
     if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
     {
      SLComposeViewControllerCompletionHandler __block completionHandler=
      ^(SLComposeViewControllerResult result){
    
       [fbComposer dismissViewControllerAnimated:YES completion:nil];
    
       switch(result){
        case SLComposeViewControllerResultCancelled:
        default:
        {
         NSLog(@"Cancelled.....");
    
        }
         break;
        case SLComposeViewControllerResultDone:
        {
         NSLog(@"Posted....");
         UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Sent"
                                                          message:nil
                                                         delegate:nil
                                                cancelButtonTitle:@"Dismiss"
                                                otherButtonTitles: nil];
         [alert show];
        }
         break;
       }};
    
      [fbComposer addImage:[UIImage imageNamed:@"iossdk_logo.png"]];
      [fbComposer setInitialText:@"The initial text you want to send"];
      [fbComposer addURL:[NSURL URLWithString:@"https://developers.facebook.com/ios"]];
      [fbComposer setCompletionHandler:completionHandler];
      [self presentViewController:fbComposer animated:YES completion:nil];
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When implementing a Facebook Canvas app using an iframe the iframe does a post
I'm implementing Facebook SDK into my App. Following the facebook developers guide, except I
It seems like implementing web-app like twitter/facebook-wall needs 1 huge feeds relational table (+
I'm with some problems implementing my first application with Login with Facebook. The user
I am implementing the Facebook iOS SDK into my app... and find no problems
I am implementing a facebook integration in my ipad app.I am presenting a veiwController
I am implementing a share button on my facebook app ( I don't wanna
I use JSON for implementing Facebook in an app and I'm just making my
I am in the process of implementing Facebook SDK 3.0 in my iOS app.
I'm implementing the Facebook registration widget into our web app, and we've got a

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.