简体   繁体   English

Objective-C:“类消息的接收者FBSDKAccessToken是一个前向声明”

[英]Objective-C : “receiver FBSDKAccessToken for class message is a forward declaration”

It is showing this error to me . 它向我显示了此错误。 All I did was download the Facebook SDK with CocoaPods and i'm trying to log in , but can not because of this mistake =( 我所做的就是下载带有CocoaPods的Facebook SDK,但我正尝试登录,但不能因为这个错误=(

FBSDKAccessToken and FBSDKGraphRequest are with this same error... FBSDKAccessToken和FBSDKGraphRequest与此错误相同...

This is my code: 这是我的代码:

#import "TestesViewController.h"
#import "FBSDKCoreKit.h"
#import "FBSDKLoginKit.h"


@implementation TestesViewController

-(void) viewDidLoad {
    [super viewDidLoad];
    FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc]init];
    loginButton.readPermissions = @[@"public_profile", @"email", @"user_friends"];
    loginButton.center = self.view.center;
    [self.view addSubview:loginButton];
}
- (IBAction)loadButton:(id)sender {
    if ([FBSDKAccessToken currentAccessToken]) {
        [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
         startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
             if (!error) {
                 NSLog(@"fetched user:%@", result);
             }
         }];
    }
}
@end

Does changing 是否改变

#import "FBSDKLoginKit.h"
#import "FBSDKCoreKit.h"

to

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

fix the issue? 解决问题? If not, there is likely a problem with the header search paths in your project/workspace. 如果不是这样,则您的项目/工作区中的标题搜索路径可能存在问题。

Here you are using custom loadButton instead of FBSDKLogin button, so I think in order to use your custom FB login button your parameters cannot be nil, you need to provide parameter. 在这里,您使用的是自定义loadButton而不是FBSDKLogin按钮,因此,我认为为了使用自定义FB登录按钮,您的参数不能为nil,需要提供参数。 Moreover, you need to first login user using login manager in order to get access token which would be nil if user had never logged in.Once you get access token you need to store it somewhere, probably in user defaults, so I am removing that part for now.Try changing the code to: 此外,您需要先使用登录管理器登录用户才能获得访问令牌,如果用户从未登录过,访问令牌将为零。一旦获得访问令牌,则需要将其存储在某个位置(可能是用户默认设置),因此我将其删除现在尝试将代码更改为:

    FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
[loginManager logInWithReadPermissions:@[@"email",@"user_birthday",@"public_profile"] fromViewController:nil handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
    // if ([FBSDKAccessToken currentAccessToken]) {
    [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields":@"first_name, last_name, picture.type(large),email"}]
     startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
         if (!error) {
             NSLog(@"fetched user:%@", result);
         }
     }];
    //}
}];

insert this code to your load button part. 将此代码插入您的加载按钮部分。 This is working for me. 这对我有用。 This might work for you. 这可能对您有用。 If you really want to make a custom FB login button, consider Custom FB button 如果您确实要创建自定义FB登录按钮,请考虑“ 自定义FB”按钮

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 class 消息的接收者“**”是前向声明错误。 Swift Static 图书馆使用 Objective-C - Receiver '**' for class message is a forward declaration Error. Swift Static Library use in Objective-C 类消息的接收器类型“WkAlertAction”是前向声明 - Receiver type "WkAlertAction" for class message is a forward declaration 类消息的接收方“ SMClient”是前向声明 - Receiver 'SMClient' for class message is a forward declaration 获取类消息的错误接收器是一个前向声明 - Getting Error Receiver for class message is a forward declaration &#39;接收器类型“CCParticleBatchNode”用于类消息是前向声明&#39; - 'Receiver type “CCParticleBatchNode” for class message is a forward declaration' 类消息的Receiver&#39;ViewController&#39;是appdelegate类中的前向声明错误 - Receiver 'ViewController' for class message is a forward declaration error in appdelegate class Box iOS SDK-类消息的接收方&#39;BoxSearchRequestBuilder&#39;是一个前向声明 - Box iOS SDK - Receiver 'BoxSearchRequestBuilder' for class message is a forward declaration Objective-C - 接收器类型&#39;NSInteger&#39;(又名&#39;long&#39;)不是Objective-C类和接收器类型&#39;NSDecimal&#39;不是Objective-C类 - Objective-C - Receiver type 'NSInteger' (aka 'long') is not an Objective-C class & Receiver type 'NSDecimal' is not an Objective-C class 接收器类型'FBSDKError'(又名'enum FBSDKError')不是Objective-C类 - Receiver type 'FBSDKError' (aka 'enum FBSDKError') is not an Objective-C class 实例消息的接收者类型“ xxx”是前向声明 - Receiver type 'xxx' for instance message is a forward declaration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM