Awesome
SSTwitterLogin
The reusable Twitter login components for iOS is the easiest way to get data from Twitter.
Features
• Get default user data from Twitter
Requirements
• iOS 10.0+
• Xcode 9.0
Installation
Take TwitterLoginHelper.swift, and TwitterConstant.Swift Import two files in your project and it's done
Manually
- Configure Twitter App Settings for iOS (https://apps.twitter.com/)
- Download TwitterKit SDK
- Add SDK to Project
- Configure Xcode Project
- Connect App Delegate Using TwitterLoginManger.swift Methods
- Congratulations!
CocoaPods
- Configure Twitter App Settings for iOS (https://apps.twitter.com/)
- Install Pod ‘SSTwitterLogin’
- Configure Xcode Project
- Connect App Delegate Using TwitterLoginManger.swift Methods
- Congratulations!
Usage example
Add following in your application:didFinishLaunchingWithOptions launchOptions:
TwitterLoginHelper.sharedInstance.twitterStartwith(consumerKey: "YOUR_APP_CONSUMER_KEY", consumerSecret: "YOUR_APP_CONSUMER_SECRET")
Add following in your application:openURL:options function
return TwitterLoginHelper.sharedInstance.twitterConfigurationWithOptions(application,open: url, options:options)
To Do Twitter Login
TwitterLoginHelper.sharedInstance.doLoginWithTwitter { (isSuccess, error) in
if isSuccess {
// Fetch LoggedIn User's Details
} else {
print(error?.localizedDescription ?? "")
TwitterLoginHelper.sharedInstance.logoutFromTwitter()
}
}
To Fetch LoggedIn User's Details
TwitterLoginHelper.sharedInstance.getLoggedInUserDetailswith(completion: { (userData, error) in
if userData != nil {
print("UserData: \(userData?.userID ?? 0)")
} else {
print(error?.localizedDescription ?? "")
}
})