Screen transition method after completing authentication with Swifter (Twitter, Firestore)

Asked 2 months ago, Updated 2 months ago, 5 views

I also asked you about teratail, but I will also ask you a question.

実現What I want to realize したい
I implement the Twitter login function using Swifter.
After the authentication is complete, I want to move on to the next View, but I don't know how to do it.
Could you please let me know?

[Error Contents]
I would like to make a screen transition using the code below.
The current code will return to the original screen after the authentication is completed on the screen below.

self.performSegue (withIdentifier: "gotoMain", sender:self)

Twitter Authentication Screen

[Code Affected]

import UIKit
import Firebase
import Swifter
import SafariServices

class LoginViewController:UIViewController, SFSafariViewControllerDelegate{

    @IBOutlet weak var emailTextField: UITextField!
    @IBOutlet weak var passwordTextField: UITextField!

    override func viewDidLoad(){
        super.viewDidLoad()
    }

    @ IBAction function twitterLoginButton(_sender:UIButton){
        letswifter=Swifter(consumerKey: "consumerKey", consumerSecret: "consumerSecret")
        swifter.authorize(withCallback:URL(string: "Callback URL")!, presentingFrom:self,
                          success: {accessToken, response in

                            guardlet accessToken=accessTokenelse{
                                return
                            }
                            self.performSegue(withIdentifier: "gotoMain", sender:self)
                            letoAuthToken=accessToken.key
                            let secret=accessToken.secret
                            let credential = TwitterAuthProvider.credential (withToken:oAuthToken, secret:secret)
                            Auth.auth().signIn(with:credential, completion:{(authResult, error)in   
                            })
        }, failure: {error in print(error)
        })
    }
}

参考Reference >
[iOS] Log in to Twitter using "Swifter" instead of TwitterKit

swift ios firebase

2022-09-30 11:17

1 Answers

SceneDelegate.swift was added from xcode11 and much of the code previously written in AppDelegate was migrated to SceneDelegate.

As a result, functions that run when other url are opened in the app have also been migrated from AppDelegate to SceneDelegate.

Reviewing the code again with reference to the article below may help resolve the issue.

[iOS13] Description of callback URL to SceneDelegate when using swifter - Qiita


2022-09-30 11:17

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.