简体   繁体   English

Facebook登录您已授权APP_NAME

[英]Facebook Login You have already authorised APP_NAME

I have problem with facebook Login..I integrated Facebook into my app.First time when user wants to login it is showing login page,but from next time it is going to page "You have already authorised APP_NAME". 我在使用Facebook Login时遇到问题。我将Facebook集成到我的应用程序中。用户首次登录时,它显示登录页面,但是从下一次开始,它将进入页面“您已授权APP_NAME”。

I checked for Scrumptious tutorial which is the sample which I got from Facebook SDK.and it is also working like same. 我检查了Scrumptious教程,这是我从Facebook SDK获得的示例,并且它也可以正常工作。

I want to login from different user,I dont want that page "You have already authorised APP_NAME" every time. 我想从其他用户登录,我不想每次都显示“您已授权APP_NAME”页面。

How to solve this. 如何解决这个问题。

Try this code in your app delegate class. 在您的应用程序委托类中尝试此代码。

It checks whether the session is open or not and clears your login credentials from the device cache when you close the connection. 它检查会话是否打开,并在关闭连接时从设备缓存中清除登录凭据。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    LoginVC *loginScreen=[[LoginVC alloc]initWithNibName:@"LoginVC" bundle:nil];

    navigationController=[[UINavigationController alloc]initWithRootViewController:loginScreen];

    self.navigationController.navigationBar.tintColor = [UIColor blackColor];
    self.window.rootViewController=self.navigationController;
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];

    // See if we have a valid token for the current state.
    if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
        [self openSession];
        // To-do, show logged in view
    } else {
        // No, display the login page.
        [self showLoginView];
    }
    return YES;


}
- (void)sessionStateChanged:(FBSession *)session
                      state:(FBSessionState) state
                      error:(NSError *)error
{
    switch (state) {
        case FBSessionStateOpen: {
            UIViewController *topViewController =
            [self.navigationController topViewController];
            if ([[topViewController presentedViewController]
                 isKindOfClass:[LoginVC class]]) {
                [topViewController dismissViewControllerAnimated:YES completion:nil];
            }
        }
            break;
        case FBSessionStateClosed:
        case FBSessionStateClosedLoginFailed:
            // Once the user has logged in, we want them to
            // be looking at the root view.
            [self.navigationController popToRootViewControllerAnimated:NO];

            [FBSession.activeSession closeAndClearTokenInformation];

            [self showLoginView];
            break;
        default:
            break;
    }

    if (error) {
        UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithTitle:@"Error"
                                  message:error.localizedDescription
                                  delegate:nil
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil];
        [alertView show];
    }
}

- (void)openSession
{
    [FBSession openActiveSessionWithReadPermissions:nil
                                       allowLoginUI:YES
                                  completionHandler:
     ^(FBSession *session,
       FBSessionState state, NSError *error) {
         [self sessionStateChanged:session state:state error:error];
     }];
}

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation
{
    return [FBSession.activeSession handleOpenURL:url];
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    // We need to properly handle activation of the application with regards to Facebook Login
    // (e.g., returning from iOS 6.0 Login Dialog or from fast app switching).
    [FBSession.activeSession handleDidBecomeActive];
}

I hope this code will be helpful. 我希望这段代码对您有所帮助。

暂无
暂无

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

相关问题 Swift:登录时可以避免使用Facebook SDK 4.x“您已授权此应用”对话框吗? - Swift: Is it possible to avoid Facebook SDK 4.x “You have already authorized this app” dialog on login? Facebook iOS SDK 3.1 |每次用户尝试登录时,都会显示“您已授权YOUR_APP” - Facebook iOS SDK 3.1 | “You have already authorized YOUR_APP” appears every time user tries to login 在“确定您已授权的APPName”中单击“确定”按钮后,如何获取Facebook登录令牌 - How to get Facebook login token, after OK button clicked in “You have Already Authorized APPName” facebook 在Swift中使用Facebook登录api时“在APP_NAME中打开此页面” - “Open this page in APP_NAME” while using facebook sign in api in Swift 单击“确定”已经授权应用程序返回应用程序后,Facebook iOS似乎丢失了会话 - Facebook iOS seems lost session when return to app after clicking Okay to You have already authorized app CloudKit共享工作流程的结尾是:要打开它,您需要使用最新版本的“ app_name” - CloudKit share workflow ends with: To open it, you'll need the latest version of “app_name” 您已经授权了facebook、iOS - You have already authorized facebook, iOS Unity IOS的​​facebook api中的“被玩家取消登录”回调(仅当设备中具有facebook应用程序时) - “Login cancelled by player” callback in facebook api for Unity IOS (only if you have facebook app in device) 在ios中的Facebook登录中检查是否已在此应用程序中注册 - check for already registered with this app in facebook login in ios iPhone开发:如果Facebook应用程序已登录,如何自动进行Facebook登录 - iphone development: how to auto facebook login if the facebook app already logged in
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM