Read More
Read now

Twitter Login in iOS App using swift 4.

Save

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.

https://github.com/twitter/twitter-kit-ios/wiki/Installation

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*


10 comments

  • Priya gupta
    Great!!
    Very Helpful
    • kunal prasad (Moderator)
      Thanks
  • Tony Fotherby
    Thanks! The tip on the callback URLs was particularly helpful for me
    • kunal prasad (Moderator)
      Thanks
  • 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?

      Thanks
      Nick

      • 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
  • css.php

    Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!

    Deniel Kerr

    Owner and Founder. Opencart

    Talk to Sales
    Start a Project

      Message Sent!

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

      Back to Home