2017-08-08 39 views
0

我正在嘗試在我的測驗應用中實施Facebook共享。內容是應用程序商店鏈接和測驗得分。它在模擬器中正常工作,但在設備顯示不同,並沒有顯示我的描述。這裏是我的代碼無法在Facebook上添加標題和說明分享

func ShareFB() { 
    let fbVC = SLComposeViewController(forServiceType: SLServiceTypeFacebook) 
    fbVC?.setInitialText("Hey! I scored \(String(describing: UserDefaults.standard.string(forKey: "TOTAL_SCORE")!)) in Test. This is really interesting! You can also try.") 
    fbVC?.add(URL(string: "https://itunes.apple.com/us/app/test-app/i?ls=1&mt=8")) 
    fbVC?.add(UIImage(named: "AppIcon")) 
    present(fbVC!, animated: true) { _ in 

    } 
} 

還安裝模擬器和設備的屏幕截圖。 Screenshot of Simulator

Screenshot of device

+0

這是從Facebook的錯誤。如果您在您的設備上安裝應用程序,則不會顯示任何類型的文本。 –

+0

首先從設備中刪除應用程序,然後檢查 –

+0

好的,但這不是正確的方法。 – Ramanan

回答

0

你爲什麼不使用UIActivityController這樣的功能?

let shareItems = [ 
     "Hey! I scored \(String(describing: UserDefaults.standard.string(forKey: "TOTAL_SCORE")!)) in Test. This is really interesting! You can also try.", 
     URL(string: "https://itunes.apple.com/us/app/test-app/i?ls=1&mt=8"), 
     UIImage(named: "AppIcon")] //Add the items you want to share in this array 

    let activityViewController = UIActivityViewController(activityItems: shareItems, applicationActivities: nil) 

    self.present(activityViewController, animated: true, completion: nil) 

編輯:

檢查了這一點: https://stackoverflow.com/a/30020929/5716829

+0

遐我試過,但得到相同的結果。沒有在設備上顯示我的描述。 – Ramanan

+0

我編輯了答案。 – PGDev

0

現在你不能同時共享圖像,文字和網址在Facebook中。也Facebook現在不允許預填充文本

+0

好的,但我想知道一件事,在遊戲應用程序中他們如何分享最高分數?感謝您的回答 – Ramanan

+1

他們使用Scores/Achievements API,或者他們爲每個結果創建單獨的URL,這些URL用於提供正確的OG元數據以在標題/描述/縮略圖中顯示結果... – CBroe

0

根據Facebook的2.3政策規定,由於違反政策,您不能共享預先填寫的內容。 Facebook不允許您與用戶未輸入的任何內容共享預先填寫的用戶消息參數。

如果你想在Facebook上分享內容,那麼用戶必須在Facebook提示信息對話框中寫入/輸入自己。

欲瞭解更多信息,請訪問:https://developers.facebook.com/docs/apps/review/prefill

相關問題