Twitter login on iOS with Social Framework

There are many library to get authentication with Twitter. Most of them using oAuth, and others don’t provide the easy access. As you might know, Social Framework support Twitter since iOS 5. So its been 4 major version update and I think we should use that instead.

In short, I couldn’t find any on github and then I created for my self. It has been used and working as expected. The library is self-explaning, you will have no worry using it. Download the library on my Github profile and follow these steps below.

Put these below on your .m file:

#import "DTTwitterLogin.h"

Then when the user clicked on some button, put these below:

[DTTwitterLogin loginWithCompletion:^(NSDictionary *twitterDetail, ACAccount *twitterAccount) {
    [DTTwitterLogin requestLoginWithAccount:twitterAccount completionBlock:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
        dispatch_sync(dispatch_get_main_queue(), ^{
            if (error == nil) {
                NSError *jsonError;
                NSDictionary *item = [NSJSONSerialization JSONObjectWithData:responseData
                NSLog(@"Item: %@", item);
} andError:^(NSError *error) {
    NSLog(@"Error: %@", error);

If you have multiple account, the library will ask a user which account he wanted to use. Then it will ask Twitter API to get the details of that user.

Happy coding!