Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter login without social framework

Tags:

ios

twitter

I am trying to implement twitter login in my ios app. I do not want to use social frame work. I have tried all ways to twitter login but unfortunately this not working. Mainly i am facing the callback url issue in it. Can you please guys help me.

I have tried this url as well

http://codegerms.com/login-with-twitter-example-with-ios-tutorial-using-oauth/

but mainly i am facing the callback issue. Can any one please suggest other plugin.

like image 354
user3771542 Avatar asked Jun 08 '26 00:06

user3771542


1 Answers

To get the user's information from Twitter, you can use OAuth.io's iOS SDK: https://github.com/oauth-io/oauth-ios

After having created an account on https://oauth.io, and added Twitter as a provider, you'll be able to get the user's info quite easily. You just need to follow these steps:

1 Install the framework through Cocoa Pods, or manually

Via Cocoa pod:

$ pod install "OAuth.io"

Manually:

Just get the OAuthiOS.framework file here and install it like any other framework.

2 Insert the header reference

Add #import <OAuthiOS/OAuthiOS.h> in your ViewController.

3 Set the view controller as delegate to OAuthIODelegate:

@interface MyViewController : UIViewController<OAuthIODelegate>
//[...]
@end

4 Initialize and launch an authentication popup in the ViewController:

OAuthIOModal *oauthioModal = [[OAuthIOModal alloc] initWithKey:@"your_app_public_key" delegate:self];
[oauthioModal showWithProvider:@"twitter"];

5 Implement the following delegate method to get a Request Object, that lets you retrieve the user's information, thanks to the me method:

- (void)didReceiveOAuthIOResponse:(OAuthIORequest *)request
{
    [_request me:nil success:^(NSDictionary *output, NSString *body, NSHTTPURLResponse 
    *httpResponse)
     {
         NSLog(@"name: %@", [output objectForKey:@"name"]);
     }];
}

To get more information about the iOS SDK, feel free to check out the guide here:

https://oauth.io/getting-started?ios&None

You can also follow a git based tutorial here:

https://oauth.io/docs/tutorials/client/ios

And find the reference documentation of the SDK here:

https://oauth.io/docs/api-reference/client/ios

Note that OAuth.io also open sourced their core in the oauthd project (check out the repo here: https://github.com/oauth-io/oauthd)

Hope this helps :)

like image 147
willjcksn Avatar answered Jun 10 '26 09:06

willjcksn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!