Reputation: 31
i probably have a pretty stupid question. I work on a SpriteKit game and i want users to be able to share their Highscores on Facebook and Twitter. The posts should contain a text and an image. The code i have works with Twitter but not with Facebook and i have no clue why.. Here is the Facebook part:
#import <Social/Social.h>
...
SLComposeViewController *facebookSheet = [SLComposeViewController composeViewControllerForServiceType: SLServiceTypeFacebook];
facebookSheet.completionHandler = ^(SLComposeViewControllerResult result) {
switch(result) {
case SLComposeViewControllerResultCancelled:
break;
case SLComposeViewControllerResultDone:
break;
}
};
[facebookSheet setInitialText:[_playerName stringByAppendingString: @" has a new Highscore"]];
[facebookSheet addImage:[UIImage imageNamed:_HighscoreImage]];
UIViewController *controller = self.view.window.rootViewController;
[controller presentViewController:facebookSheet animated: YES completion:nil];
Upvotes: 0
Views: 83
Reputation: 2096
To solve this we can go for FBSDKSharKit.Install FBSDK pod file.
if UIApplication.sharedApplication().canOpenURL(NSURL(string: "fb:")!) {
let content : FBSDKShareLinkContent = FBSDKShareLinkContent()
content.contentURL = NSURL(string: "https://google.com")
content.contentTitle = "Test"
content.contentDescription = "FBSDKShareKit is an alternative to this issue"
content.imageURL = NSURL(string:"https://pixabay.com/static/uploads/photo/2015/10/01/21/39/background-image-967820_960_720.jpg")
let ShareKit: FBSDKShareDialog = FBSDKShareDialog()
ShareKit.fromViewController = self;
ShareKit.shareContent = content
ShareKit.mode = FBSDKShareDialogMode.FeedBrowser
ShareKit.show()
}
For detail description on using ShareKit check my other answer.
Upvotes: 1