Vishnu
Vishnu

Reputation: 371

How to Share Link on Facebook using FBSDKShareLink?

FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:@"http://en.wikipedia.org/wiki/Facebook"];
NSURL *imageURL =
[NSURL URLWithString:@"http://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Facebook_Headquarters_Menlo_Park.jpg/2880px-Facebook_Headquarters_Menlo_Park.jpg"];

content.contentDescription=@"This is facebook test";
content.contentTitle=@"Hello";
content.imageURL=imageURL;


FBSDKShareButton *shareButton = [[FBSDKShareButton alloc] init];
shareButton.shareContent = content;
shareButton.center = self.view.center;
[self.view addSubview:shareButton];

I used facebook-ios-sdk-3.24.0.pkg and I am using the above code for link sharing on facebook using fbsdksharekit. This code is working fine but after closing the xcode and reopen that xcode6.0 it shows the below error. FBSDKCoreKit/FBSDKCoreKit.h and FBSDKShareKit/FBSDKShareKit.h not found.

i import those frameworks i.e FBSDKCoreKit/FBSDKCoreKit.h and FBSDKShareKit/FBSDKShareKit.h to viewcontroller.m file .

can any one tell me what is the problem.Thanks in advance.

Upvotes: 0

Views: 851

Answers (1)

Kirit Modi
Kirit Modi

Reputation: 23407

Use the Below Code to Share on Facebook, download latest Facebook SDK

    FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
    content.contentURL = [NSURL URLWithString:@"http://en.wikipedia.org/wiki/Facebook"];
    NSURL *imageURL =
    [NSURL URLWithString:@"http://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Facebook_Headquarters_Menlo_Park.jpg/2880px-Facebook_Headquarters_Menlo_Park.jpg"];
    content.contentDescription=@"This is facebook test";
    content.contentTitle=@"Hello";
    content.imageURL=imageURL;
    [FBSDKShareDialog showFromViewController:self withContent:content delegate:nil];

Upvotes: 2

Related Questions