简体   繁体   English

Swift IOS Facebook登录快速应用程序切换

[英]Swift IOS Facebook Login Fast-App-Switch

Im a swift beginner and have already implemented FB login for IOS. 我是一位快速入门者,已经为IOS实现了FB登录。 I was wondering how to do it with Fast-App-Switching and staying on the App without moving to Facebook login form. 我想知道如何使用快速应用程序切换来做到这一点,并在不移至Facebook登录表单的情况下停留在应用程序上。

Heres my code for the ViewController.swift handling FB Login: 这是我的ViewController.swift处理FB登录的代码:

import UIKit
import Foundation

class FacebookLoginViewController : UIViewController, FBSDKLoginButtonDelegate {

let loginButton: FBSDKLoginButton = {
    let button = FBSDKLoginButton()
    button.readPermissions = ["public_profile","email","user_friends"]
    return button
}()

override func viewDidLoad() {
    super.viewDidLoad()

    view.addSubview(loginButton)
    loginButton.center = view.center
    loginButton.delegate = self

    if let token = FBSDKAccessToken.currentAccessToken() {
        fetchProfile()
    }
}

func fetchProfile() {
    print("User Profile fetched")


    redirectToHome()

}

func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
    print("User has successfully logged on.")

    redirectToHome()
}

func redirectToHome() {

    let storyboard:UIStoryboard = UIStoryboard(name:"Main", bundle: nil)

    let homeFeed: UIViewController = storyboard.instantiateViewControllerWithIdentifier("homeFeed") as UIViewController

    self.presentViewController(homeFeed, animated: true, completion: nil)
}

func loginButtonWillLogin(loginButton: FBSDKLoginButton!) -> Bool {
    return true
}

func loginButtonDidLogOut(loginButton: FBSDKLoginButton!) {
    print("User has logged out")
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

}

As far as I knew and since I saw your question did further research, it is still not possible to skip the second screen. 据我所知,并且由于我看到您的问题做了进一步的研究,所以仍然不可能跳过第二个屏幕。 By second screen I mean a webpage where you must tap "log in" and it provides details about how the app will interact with Facebook. 第二屏是指您必须点击“登录”的网页,其中提供了有关该应用程序如何与Facebook交互的详细信息。 Even the app for this website takes you there when logging in with Facebook. 使用Facebook登录时,即使是该网站的应用程序也可以带您到那里。 If it this changes or I am mistaken I will update this post. 如果它改变了或者我弄错了,我将更新这篇文章。 Since I just joined the site I cannot post pictures yet:) but I hope we are talking about the same thing. 由于我刚刚加入该网站,所以我还不能发布图片:),但我希望我们正在谈论同一件事。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM