"You are already logged in yourApp" when logging in using FBSDK 4.7.1

I followed Facebook with my own tutorial for logging in to FB on iOS (Objective-C), but every time I log in - after the initial permission, the authorization screen - I get the notorious "You already allowed this application" webview.

I read a ton of posts, but I couldn't figure it out, therefore, (re). I find this rather strange, because the application is absolutely nothing but the template input code. This behavior occurs both in the simulator and in real devices.

This webview may not seem to shake

This application is for iOS 9.0, and I am using FBSDK 4.7.1 (installed via CocoaPods):

pod 'FBSDKLoginKit', '~> 4.6'

The code itself is pretty conditional, here is my AppDelegate.m:

#import "AppDelegate.h"
#import <FBSDKCoreKit/FBSDKCoreKit.h>

@interface AppDelegate ()

@end

@implementation AppDelegate

- (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];
}
@end

and my ViewController.m:

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

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
    loginButton.readPermissions = @[@"public_profile", @"email", @"user_friends"];
    [loginButton setLoginBehavior:FBSDKLoginBehaviorSystemAccount]; // No difference

    loginButton.center = self.view.center;
    [self.view addSubview:loginButton];
}

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

@end

And a screenshot of Info.plist:

Info.plist

, :

2015-11-24 11:50:42.855 lixo[26941:389756] -canOpenURL: failed for URL: "fbauth2:/" - error: "(null)"
2015-11-24 11:50:42.860 lixo[26941:389756] -canOpenURL: failed for URL: "fbauth2:/" - error: "(null)"

, , , LSApplicationQueriesSchemes Info.plist.

, ?

+4
3

!

Facebook SDK facebook Facebook ( ), Safari. Facebook Safari, .

, iphone Facebook, Facebook SDK , Safari; , Safari cookie, cookie Safari .

Facebook, - .

EDIT -

iOS 10. - Tiois

-1

. , API. , :

+(BOOL) accessTokenIsLocalyValid
{
    return [FBSDKAccessToken currentAccessToken] && [[NSDate date] compare:[FBSDKAccessToken currentAccessToken].expirationDate] == NSOrderedAscending;
}

, [FBSDKAccessToken refreshCurrentAccessToken:].

0

Check if there is a current session before logging in with FBSDKLoginManager.

if ([FBSDKAccessToken currentAccessToken]) 
 {
      NSLog(@"Token is available : %@",[[FBSDKAccessToken currentAccessToken]tokenString]);
      // Now get details using graphpath. 
 } else {
     // login with permissions using FBSDKLoginManager and get details using graphpath in completion

 }
0
source

Source: https://habr.com/ru/post/1617240/


All Articles