2016-05-30 73 views
0

我可能有一个非常愚蠢的问题。我在SpriteKit游戏上工作,我希望用户能够在Facebook和Twitter上分享他们的Highscores。 帖子应该包含文字和图片。 的代码,我与Twitter,但不是与Facebook的作品,我不知道为什么.. 这里是Facebook的一部分:在SpriteKit上制作Facebook帖子游戏

#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]; 

回答

1
  1. 如果FB的应用程序安装,你不能共享的预填充文本
  2. 为了解决这个问题,我们可以去FBSDKSharKit.Install FBSDK pod文件。

    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() 
    } 
    
  3. 有关使用ShareKit的详细说明,请查看我的其他answer

+0

该死的,我刚刚发现预填文本是Facebook的平台政策。不管怎样,谢谢你。 – Wirkungsquantum