I'm trying to adopt Facebook login process for my application goals. After successful Facebook login, I want to send a User to another View. For this reason, I'm using PerformSegue in UserLoginManager class, but always get the same issue in the AppDelegate file: Thread 1: "Receiver (<Leeeeeds.UserLoginManager: 0x7f9015010010>) has no segue with identifier 'gonext'"* (spelling for the identifier is correct, I've checked it thousands of times).*
At the same time, in debug console I see: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<Leeeeeds.UserLoginManager: 0x7f9015010010>) has no segue with identifier 'gonext''terminating with uncaught exception of type NSException CoreSimulator 802.6.1 - Device: iPhone 11
Here is my AppDelegate code:
import UIKit
import FacebookCore
import FacebookLogin
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
ApplicationDelegate.shared.application(
application,
didFinishLaunchingWithOptions: launchOptions
)
return true
}
func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]
) -> Bool {
ApplicationDelegate.shared.application(
app,
open: url,
sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
annotation: options[UIApplication.OpenURLOptionsKey.annotation]
)
}
}
And my UserLoginManager class:
import Foundation
import FacebookLogin
let loginManager = LoginManager()
class UserLoginManager: UIViewController {
func facebookLogin() {
loginManager.logIn(permissions: [.publicProfile, .email], viewController: nil) { loginResult in
switch loginResult {
case .failed(let error):
print(error)
case .cancelled:
print("User cancelled login.")
case .success(let grantedPermissions, let declinedPermissions, let accessToken):
self.performSegue(withIdentifier: "gonext", sender: self)
print("Logged in! \(grantedPermissions) \(declinedPermissions) \(accessToken)")
GraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name"]).start(completionHandler: { (connection, result, error) -> Void in
if (error == nil){
let fbDetails = result as! NSDictionary
print(fbDetails)
}
})
}
}
}
}
Here is my ViewController:
import UIKit
import FacebookLogin
class ViewController: UIViewController {
var fbmanager = UserLoginManager()
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func facebook(_ sender: UIButton) {
fbmanager.facebookLogin()
}
}
Thanks for any advice!