2017-01-27 51 views
0

我已經嘗試了Open Graph的故事與最新的Facebook SDK的斯威夫特整合,但是我收到一個錯誤「泛型參數‘內容’不能推斷」Facebook的OpenGraphContent上swift3

let object: OpenGraphObject = [ 
    "og:type": "books.book", 
    "og:title": "A Game of Thrones", 
    "og:description": "In the frozen wastes to the north of Winterfell, sinister and supernatural forces are mustering.", 
    "books:isbn": "0-553-57340-3" 
] 
// Create an action 
var action = OpenGraphAction(type: "book.reads") 
action["books:book"] = object 
// Create the content 
var content = OpenGraphShareContent() 
content.action = action 
content.previewPropertyName = "books:book" 
try ShareDialog.show(from: self, content: content) //Here i'm getting "generic parameter 'Content' could not be inferred" 

任何人都知道一個解決方案?

+0

我發現完全相同的問題,但它在我看來這是Facebook建議使用的API? – user3621075

回答

0

從我從commit log可以瞭解到,該模塊不再維護。相反,使用FBSDKShareKit模塊(例如,來自的CocoaPods,與use_frameworks!)。那麼你應該可以做

import FBSDKShareKit 

... 

// Create an object 
let object = FBSDKShareOpenGraphObject.init(properties: [ 
    "og:type": "books.book", 
    "og:title": "A Game of Thrones", 
    "og:description": "In the frozen wastes to the north of Winterfell, sinister and supernatural forces are mustering.", 
    "books:isbn": "0-553-57340-3" 
    ]) 

// Create an action 
let action = FBSDKShareOpenGraphAction.init() 
action.actionType = "books.reads" 
action.setObject(object, forKey: "books:book") 

// Create the content 

let content = FBSDKShareOpenGraphContent.init() 
content.action = action 
content.previewPropertyName = "books:book" 

FBSDKShareDialog.show(from: self, with: content, delegate: self)