2016-05-30 61 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