【发布时间】:2019-06-17 05:59:57
【问题描述】:
我最近在我的项目中将我所有的 pods 和 swift 语言更新为 Swift 5,并收到大量错误消息,我已经慢慢解决了这些错误消息。
然而,我正在为此苦苦挣扎,Facebook GraphRequest 之前运行良好,特别是此错误消息位于 GraphRequest 的 version 参数上。
如果我删除 version 参数,我会收到此错误:
func fetchFacebookAttributes(fetchFBAttrbComplete: @escaping (Bool, String) -> ()){
let graphRequestConnection = GraphRequestConnection()
let graphRequest = GraphRequest(graphPath: "me", parameters: ["fields": "id, email, name, picture.type(large), first_name, last_name, gender, birthday"], tokenString: AccessToken.current?.tokenString, version: .defaultVersion , httpMethod: .get)
graphRequestConnection.add(graphRequest) { (httpResponse, result) in
switch result {
case .success(response: let response)://handling .success response case
guard let responseDictionary = response.dictionaryValue else { return }
//parse response code here...
case .failed(let error):
print (error)
fetchFBAttrbComplete(false, "")
break
}//end switch
}//end graphRequestConnection
graphRequestConnection.start()//start connection
}//end func
我遇到了这个 FB 文档,其中显示了如何使用它的示例,但我也很难理解它是如何使用的?这是否意味着是一个单独的文件?
【问题讨论】:
-
您是否尝试过将“version”替换为“apiVersion”,如下所述:developers.facebook.com/docs/swift/reference/structs/…?
-
不起作用,当我声明一个新的 GraphRequest 时,它会自动恢复为这些参数,而不是该链接上的参数
let graphReq = GraphRequest(graphPath: String, parameters: [String : Any], tokenString: String?, version: String?, httpMethod: HTTPMethod) -
在这种情况下,您可以使用此方法 FBSDKSettings.graphAPIVersion() 来检索默认的 Graph API 版本