0

I am using Xcode 8 and objective-c. I followed the Facebook guidelines and yet my login button does not switch to a log out button after logging in with my app's Admin user. I'm a bit new to app development so I'm not sure where to look in the Facebook SDK. I read some posts online and they seemed to point to the guidelines (i.e., the issues were solved by following the guidelines closely). I should mention that after logging in again, I get a "you have already authorized {{app}}" message from Facebook with a Cancel and OK button.

Here's the view controller's implementation file:

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

@interface LoginViewController ()
    @property (weak, nonatomic) IBOutlet FBSDKLoginButton *loginButton;
@end

@implementation LoginViewController

-(void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton {

}

- (void)loginButton:(FBSDKLoginButton *)loginButton didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error
    {

    }

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.loginButton.readPermissions = @[@"public_profile", @"email", @"user_friends"];
    FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
    loginButton.center = self.view.center;
    [self.view addSubview:loginButton];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

And the header for the controller view:

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

@interface LoginViewController : UIViewController <FBSDKLoginButtonDelegate>

And the AppDelegate's implementation parts that Facebook indicated to change / add:

- (void)applicationDidBecomeActive:(UIApplication *)application {
    [FBSDKAppEvents activateApp];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[FBSDKApplicationDelegate sharedInstance] application:application
                             didFinishLaunchingWithOptions:launchOptions];
    return YES;
}

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                          openURL:url
                                                sourceApplication:sourceApplication
                                                       annotation:annotation];
}

I basically copied / pasted from Facebook's steps so I'm at a loss as to what to do next. Thanks for any help

DragonMoon
  • 415
  • 1
  • 4
  • 14

1 Answers1

0

Did some more digging and found this solution, which worked for me:

FBSDK Login Error Code: 308 in Objective-C

Note the solution I used is not the highest voted answer in that link. Here are the details for convenience:

Enable keychain sharing in the project (in project-level settings)

Fix Keychain permission issue

Community
  • 1
  • 1
DragonMoon
  • 415
  • 1
  • 4
  • 14