Make Facebook post from your iphone , ipad using ios programming from application

Leave a Comment
Make facebook post from your iphone.  First of all add social framework in your project which is given in below snapshot.


devangViewController.h


#import <UIKit/UIKit.h>
#import <Social/Social.h>
@interface devangViewController : UIViewController
- (IBAction)fbpost:(id)sender;
@end

devangViewController.m

#import "devangViewController.h"
#import <Social/Social.h>
@interface devangViewController ()
@end
@implementation devangViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)fbpost:(id)sender {
   
    if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
        SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
       
        [controller setInitialText:@"FIRST APPLICATION POST BY www.studyoverflow.org"];
        [self presentViewController:controller animated:YES completion:Nil];
    }
}
@end
Now just run your application you will get this pop up message. here it is giving two options like "o.k" and settings. If you are not signed in than go to your device preference-> general setting -> facebook->
sign in. when you press O.K you will not allow to post without sign in. If you are doing this in simulator may be not allow you with out internet or wifi so try to test on device.

If you have any doubts than please just leave comment on it or mail me on devang9978@gmail.com.....I will give you possible help....

0 comments:

Post a Comment