FBSDKGraphRequest use of undeclared identifier

烂漫一生 提交于 2020-01-05 14:12:25

问题


Though I have imported FacebookSDK like: #import <FacebookSDK/FacebookSDK.h>, but it says: use of undeclared identifier 'FBSDKGraphRequest'.

The code I wrote is simple:

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                                      initWithGraphPath:@"/{user-id}/albums"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                              id result,
                                              NSError *error) {
            // Handle the result
        }];

Let me know what may I be missing?


回答1:


Since version 4.X Facebook has split the SDK in 3 parts:

Per documentation:

The SDK is now composed of three frameworks, FBSDKCoreKit, FBSDKLoginKit, and FBSDKShareKit.

FBSDKCoreKit provides core SDK functionality such as Graph API Requests, access tokens, and App Insights.

FBSDKLoginKit provides functionality to log people in, and only requires FBSDKCoreKit.

FBSDKShareKit provides functionality to share, and only requires FBSDKCoreKit.

As for your question:

Requests - FBSDKGraphRequest and FBSDKGraphRequestConnection are in FBSDKCoreKit and provide helpers to access the Graph API

So basically you need to import FBSDKCoreKit in your file:

#import <FBSDKCoreKit/FBSDKCoreKit.h>



回答2:


For login into Facebook using new SDK 4.1 You have to add the FBSDKLoginkit and FBSDKCoreKit Frameworks in your project.

Then import the below header files into your ViewController:

#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>

For more information you can refer the facebook official document here or you can refer these answers

  1. First answer
  2. Second answer

Eventhough facebook official document is best.



来源:https://stackoverflow.com/questions/30375046/fbsdkgraphrequest-use-of-undeclared-identifier

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!