我刚刚更新了手机iOS11.3和Xcode 9.3,Facebook登录就像我的旧SDK调用一样崩溃:
https://pasteboard.co/HeeRDVo.png
我不明白这究竟是什么意思,即使它适用于旧版本。 然后我从该页面应用了Swift SDK, https://developers.facebook.com/docs/swift/graph。
import FacebookCore
let connection = GraphRequestConnection()
connection.add(GraphRequest(graphPath: "/me")) { httpResponse, result in
switch result {
case .success(let response):
print("Graph Request Succeeded: \(response)")
case .failed(let error):
print("Graph Request Failed: \(error)")
}
}
connection.start()
这提供了以下错误日志:
FBSDKLog: starting with Graph API v2.4, GET requests for //me should contain an explicit "fields" parameter
Graph Request Failed: Error Domain=com.facebook.sdk.core Code=8 "(null)" UserInfo={com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=0, com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=400, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=An active access token must be used to query information about the current user., com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=2500, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={
body = {
error = {
code = 2500;
"fbtrace_id" = ____id____;
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
};
};
code = 400;
}}
它说,必须使用有效的访问令牌来查询有关当前用户的信息。
即使在代码块下面,当我制作词典注释行时也会出现相同的错误,因为它们也不起作用。
import FacebookCore
struct MyProfileRequest: GraphRequestProtocol {
struct Response: GraphResponseProtocol {
init(rawResponse: Any?) {
// Decode JSON from rawResponse into other properties here.
}
}
var graphPath = "/me"
var parameters: [String : Any]? = ["fields": "id, name"]
var accessToken = AccessToken.current
var httpMethod: GraphRequestHTTPMethod = .GET
var apiVersion: GraphAPIVersion = .defaultVersion
}
let connection = GraphRequestConnection()
connection.add(MyProfileRequest()) { response, result in
switch result {
case .success(let response):
print("Custom Graph Request Succeeded: \(response)")
print("My facebook id is \(response.dictionaryValue?["id"])")
print("My name is \(response.dictionaryValue?["name"])")
case .failed(let error):
print("Custom Graph Request Failed: \(error)")
}
}
connection.start()
我该怎么做才能解决这个问题?
答案 0 :(得分:11)
最后,我使用下面的方法而不是AppDelegate中的注释open url方法解决了我的问题。希望它能帮助在iOS 11.3中遇到此问题的其他人。
document.addEventListener('touchmove', function(e) {
e.preventDefault();
}, { passive: false });