Read More

Twitter Login in iOS App using swift 4.

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

 

 

 

 

 

 

 

 

 

. . .

Comments (8)

Add Your Comment

  • Priya gupta
    Great!!
    Very Helpful
  • Tony Fotherby
    Thanks! The tip on the callback URLs was particularly helpful for me
  • 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
      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
        Please check the function in Appdelegate.swift for handling the redirect URL.
  • css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close