Reputation: 1217
I recently updated all my pods
and swift language to Swift 5
in my project and got a ton of error messages which I have slowly addressed.
I am however struggling with this one, the Facebook GraphRequest
was working perfectly before, in particular this error message is on the version
parameter of the GraphRequest
.
And if I remove the version
parameter I then get this error:
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
I have come across this FB documentation that shows an example of how to use it, but I am struggling to understand how that is used also? is this meant to be a separate file?
https://developers.facebook.com/docs/swift/graph/
Upvotes: 4
Views: 2757
Reputation: 109
Try this for Swift 5:
let graphRequest = GraphRequest(graphPath: "me", parameters: ["fields": "id, email, name, picture.type(large)"], tokenString: AccessToken.current?.tokenString, version: Settings.defaultGraphAPIVersion, httpMethod: HTTPMethod.get)
Upvotes: 2