【问题标题】:Use of undeclared type 'GraphRequestResult' after update of pods更新 pod 后使用未声明的类型“GraphRequestResult”
【发布时间】:2019-06-18 21:00:43
【问题描述】:

我正在使用新的 facebook 图形请求,更新 pod 后出现错误

let graphRequest = GraphRequest(graphPath: kGraphPathMe, parameters: ["fields":"id,email,last_name,first_name,picture"], tokenString: accessToken.tokenString, version: .init(), httpMethod: .get) 

graphRequest.start {(response: HTTPURLResponse?, result: GraphRequestResult<GraphRequest>) in
        switch result {
        case .success(let graphResponse):
            if let dictionary = graphResponse.dictionaryValue {
                completion(FacebookUser(jsonDict: dictionary))
            }
            break
        default:
            print("Facebook request user error")
        }
    }

【问题讨论】:

    标签: ios swift facebook-graph-api


    【解决方案1】:

    检查此代码

            let parameters = ["fields": "email, id, name"]
            let graphRequest = FBSDKGraphRequest(graphPath: "me", parameters: parameters)
    
            _ = graphRequest?.start { [weak self] connection, result, error in
                // If something went wrong, we're logged out
                if (error != nil) {
                    // Clear email, but ignore error for now
                    return
                }
    
                // Transform to dictionary first
                if let result = result as? [String: Any] {
                    // Got the email; send it to Lucid's server
                    guard let email = result["email"] as? String else {
                        // No email? Fail the login
                        return
                    }
                    guard let username = result["name"] as? String else {
                        // No username? Fail the login
                        return
                    }
    
                    guard let userId = result["id"] as? String else {
                        // No userId? Fail the login
                        return
                    }                       
                }
            } // End of graph request
    

    【讨论】:

      猜你喜欢
      • 2016-06-18
      • 2020-01-20
      • 1970-01-01
      • 2019-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多