“您已经授权了您的应用”当使用FBSDK 4.7.1登录时 [英] "You have already authorized yourApp" when logging in using FBSDK 4.7.1

查看:302
本文介绍了“您已经授权了您的应用”当使用FBSDK 4.7.1登录时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注iOS中FB登录的



此应用程序适用于iOS 9.0,而我正在使用FBSDK 4.7.1(通过CocoaPods安装):

  pod'FBSDKLoginKit','〜> 4.6'

代码本身是漂亮的样板,这里是我的AppDelegate.m:

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

@interface AppDelegate()

@end

@implementation AppDelegate

- (void)applicationDidBecomeActive :((UIApplication) *)应用程序{
[FBSDKAppEvents activateApp];


- (BOOL)应用程序:(UIApplication *)应用程序didFinishLaunchingWithOptions :( NSDictionary *)launchOptions {
[[FBSDKApplicationDelegate sharedInstance]应用程序:应用程序
didFinishLaunchingWithOptions: launchOptions];
返回YES;


- (BOOL)应用程序:(UIApplication *)应用程序
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
注释:(id)注释{
return [[FBSDKApplicationDelegate sharedInstance]应用程序:应用程序
openURL:url
sourceApplication:sourceApplication
注释:注释]
}
@end

和我的ViewController.m:

  #importViewController.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]; //无差异

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

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
//处理可以重新创建的任何资源。
}

@end

.plist:





最后,我也是在控制台中收到这两个错误:

  2015-11-24 11:50:42.855 lixo [26941:389756] -canOpenURL :失败的URL:fbauth2:/ - 错误:(null)
2015-11-24 11:50:42.860 lixo [26941:389756] -canOpenURL:URL失败:fbauth2:/ - 错误:(null)

虽然从我读过的这个可以安全地忽略,

解决方案



任何想法如何避免这种情况? / div>

这是默认行为!



Facebook SDK允许您从Facebook应用程序登录(如果它已安装在手机中),否则它将管理登录 苹果浏览器。
当您的应用程序从Safari使用Facebook登录时,这是每次必须接受许可的方式。另一个行为是,如果你的iphone没有Facebook应用程序,并且你的应用程序使用Facebook SDK登录过程,它将使用Safari;您将无法注销,因为Safari将您的凭据保存在Cookie中,您无法从应用程序中清除safari cookie。



如果您的手机已经Facebook应用程序,它将重定向到您的应用程序,而不会有任何中断。



编辑 -



感谢您的编辑 - Tiois


I was following Facebook's own tutorial for FB login in iOS (Objective-C) but every time I log in - after the initial permission authorization screen - I'm getting the infamous "You have already authorized this app" webview.

I've read a ton of posts but I haven't been able to sort it out, hence the (re)post. I find this rather odd because the app has absolutely nothing except the boilerplate login code. This behaviour happens in both Simulator and real devices.

This app 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 boilerplate stuff, here's 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 the Info.plist:

Finally, I'm also getting these two errors in the console:

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)"

Although from what I've read this can be safely ignored if LSApplicationQueriesSchemes is set in the Info.plist.

Any ideas how to avoid this?

解决方案

This is the default behaviour!

Facebook SDK allows you to login to facebook from Facebook App (if it is installed in your phone), OR else it will manage the login from Safari. And when Facebook login is used by your application from Safari, this is how you have to accept permission everytime.

Another behaviour is that If your iphone doesnt have Facebook App, and you use Facebook SDK login process from your application, it will use Safari; you wont be able to logout even, as Safari saves your credentials in cookies and there is no way by which you can clear safari cookies from your application.

If your phone has Facebook App, it will redirect to your application without any interruptions as such.

EDIT -

This behaviour is also found in iOS 10. Thanks for the edit - Tiois

这篇关于“您已经授权了您的应用”当使用FBSDK 4.7.1登录时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆