Twitter Login in iOS App using swift 4.

Updated 26 October 2021


Twitter Login in iOS App using swift 4.

Most of the time we provide the social login in app that will help user to login in app fast & smooth .

Here i have taken example of Twitter .

1: First try to follow this steps and add their SDK in App.

2: After that Go to Appdelgate.swift file and add this:

Now add this method also in Appdelegate.swift file.

3: Now write the code that will fetch user email & Name .

for this:


4: Now you have done all the required things for fetching the user credential in App

5: Now last important things that open the twitter developer site and select your app (where you have registered your iOS app)

1.1: Now you have  to call back URL for App.

2.1: To get the call back URL

a: open info.plist file and copy URL schemes.

it look like this.

copy this ” twitterkit-js5zHyDKTz2RTthfgV5xl9icA”

Note: ” twitterkit- Your Consumer Key”


and Now open your twitter developer account & select your app.

3.1: edit the App account .

4.1: go to callback URLs section and paste it.

like that.


5.1:Now save this.

6: Now you are able to fetch the user data without any issue.




if you have any issue regarding twitter login than freely to ask , we will wait for your valuable feedback










. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


  • Priya gupta
    Very Helpful
    • kunal prasad (Moderator)
  • Tony Fotherby
    Thanks! The tip on the callback URLs was particularly helpful for me
    • kunal prasad (Moderator)
  • Sonu verma
    i am not getting email id from this method
    let client = TWTRAPIClient.withCurrentUser()
    client.requestEmail { email, error in
    if (email != nil) {
    print(“signed in as \(String(describing: session?.userName))”);
    let firstName = session?.userName ?? “” // received first name
    let lastName = session?.userName ?? “” // received last name
    let recivedEmailID = email ?? “” // received email

    }else {
    print(“error: \(String(describing: error?.localizedDescription))”);

    • kunal prasad (Moderator)
      twitter account is created not only by email , it is created by phone number or other things so you will have make the check on this.
    • Nicholas Marriotti
      I’m stuck at “Redirecting back to application” after authorizing my app. My URL scheme and callback URL on the Twitter dashboard match. Any idea of what’s wrong or how to fix it?


      • kunal prasad (Moderator)
        Please check the function in Appdelegate.swift for handling the redirect URL.
        • Tarang Gupta
          Inside AppDelegate.swift, I have already written code like mentioned below:

          func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {

          if TWTRTwitter.sharedInstance().application(application, open: url, options: options) {
          return true
          return true

          Still, I am not able to get redirected to my application. Any suggestion?

  • Nikunj
    when click authenticate click then move my app after open browser twitter login page
  • Arjun
    Hello, how it work in RxSwift?
  • Start a Project

      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home