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.
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 :)
rmaddy can you exlain in detail what problem you are facing , I have also followed this tutorial and successfully, I am getting the access token, Try to put breakpoint in your code, You might haven't changed the callback URL in the code, Let me explain you a little using an image
First you should put a break point here in the following function
(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
Now run application and enter your login credentials in, After you have successfully got the request token then you will be redirected to your redirect URL and then you will get the access token
You program must be not entering in this if condition, try changing this code, to yours callback string, If still you have problem, Let me know in details, I will help you to solve this
Related
I know there are a lot of topics on this issue, but I just can't figure out what is wrong.
I want to implement sharekit for Facebook and Twitter, so I followed the install instructions on the github:
Appid is set, got my entry in the cfurlschemes thingy, etc.
I authorize my app:
- (void)authorizeFacebook {
[self.facebook authorize];
}
(self.facebook is a strong member of a share controller singleton).
To share:
- (void)shareFacebook:(SHKItem*)toShare {
[SHKFacebook shareItem:toShare];
}
I also tried:
- (void)shareFacebook:(SHKItem*)toShare {
[self.facebook setItem:toShare];
[self.facebook share];
}
The same constructions are made for twitter.
I can authorize my apps without issue, so my configuration should be fine. When I authorize my app before i call the shareFacebook function, it is authorized but nothing happens with the sharing.
When I don't auhorize before calling shareFacebook (so sharekit detects it is not authorizes and opens authorization first) the'sharekitSendDidFinish' notification is fired but nothing appears on Facebook.
The same goes for Twitter, authorization works but no tweets appear. The SHKItem i'm trying to share is not nil and is filled with the correct stuff I need to share.
*Edit
I'm trying to share an SHKItem with:
Title
Text
Image
I also tried to send an SHKItem with just text, but that didn't work either.
Reinstalling ShareKit did nothing.
Failed with error is not being fired
Senddidfinish is being fired (but only if you authorize via the share function) and has no 'last error'
Solved it, I forgot to set the sharetype... stupid that it doesnt give an error for this :S
Quite simply unable to make a post with just the text and NSURL object. I can do it with just the post, or with the post, NSURL and image, but ideally I'd just like to provide the link with the post.
It simply states "Cannot post to Facebook" as "The post cannot be sent because the connection to Facebook failed."
Is there anything I can do? I'm not using the Facebook SDK at the moment, but perhaps I might have to?
Many thanks
We just started running in to this issue with code that was working correctly yesterday. Googling shows a lot of people having this issue sharing from other Apple apps today via native integration. I actually think this is an issue on Facebook's end.
I tried sharing a URL from Mobile Safari and it too fails with the same error. Can you confirm that Mobile Safari also fails to share?
Well for now I'm able to leave the image part nil (still include the method, just leave the argument nil) and it will show the text and link only.
I'm looking at integrating support for tracking Facebook's new mobile app ads.
I've read the tutorial here:
https://developers.facebook.com/docs/tutorials/mobile-app-ads/
It says:
Include the following code to be executed when your app opens for the first time by user
[FBSettings publishInstall:appId];
So the first question is - where do I put this so that it only invokes the call if the install was driven from Facebook? I don't want FB to get credit for someone who found my app themselves on the app store.
Do I need to manually track whether or not I've called the publishInstall before for this specific user? (The preamble sentence implies this - but the SDK documentation for publishInstall implies otherwise).
And even more confusing is that the SDK FBSettings reference includes shouldAutoPublishInstall which defaults to YES. This would suggest that I don't need to do anything other than have the SDK integrated. So why does the tutorial not mention this as an option?
I assume that the appId is the associated Facebook appId (as opposed to the App Store App ID). This is also not clear from the documentation.
I browsed the sources of facebook iOS SDK, and it seems that guide is wrong.
You are right, that autoPublishInstall is set to YES by default, which means we don't need to invoke [FBSettings publishInstall:appId]; manually. AppId is indeed the facebook app id.
When you invoke openActiveSessionWith.... method, it initializes FBSession with
initWithAppID:permissions:defaultAudience:urlSchemeSuffix:tokenCacheStrategy: which contains in the end [FBSettings autoPublishInstall:self.appID];
+ (void)autoPublishInstall:(NSString *)appID {
if ([FBSettings shouldAutoPublishInstall]) {
dispatch_once(&g_publishInstallOnceToken, ^{
// dispatch_once is great, but not re-entrant. Inside publishInstall we use FBRequest, which will
// cause this function to get invoked a second time. By scheduling the work, we can sidestep the problem.
[[FBSettings class] performSelector:#selector(publishInstall:) withObject:appID afterDelay:FBPublishDelay];
});
}
}
So technically it should report the install out of the box (if I'm not missing something). I'm going to play with it a little more today to see if it works as expected and update answer with results.
Just put it at -[application:didFinishLaunchingWithOptions].
Not all of the apps want to integrate the Facebook login. They only want the feature "mobile app install ads". For these kind of app, they should invoke +[FBSettings publishInstall:appId] manually. On the other hand, if your app has already integrated facebook login, you can assume that the FB sdk has published the installation.
If we just have to put
[FBSettings publishInstall:appId];
manually in
-[application:didFinishLaunchingWithOptions]
how will I identify which install happened from facebook? I don't want FB to get credit for someone who found my app themselves on the app store.
put the code in Appdelegate DidbecomeActive method
- (void)applicationDidBecomeActive:(UIApplication *)application
hope this help :)
Sharekit opens up Safari to get authentication from the user which is fine (not sure if it should open up Safari or in it's own window). A page then appears saying you have authenticated app.x click ok to continue, once the continue button is tapped it tries to redirect to www.facebook.com/permissions.request but then show an error of:
'Cannot Open Page, Safari cannot open this page because the address is invalid.'
Any ideas what might be going on here, I'm presuming it should be redirecting to my app?!
Here's my solution to this problem (I am assuming you are using ShareKit 2.0):
I configured ShareKit following the guide they provide ShareKit Configuration Guide. In other words I subclassed the DefaultSHKConfigurator class and added all the necessary configuration there.
In my app delegate I linked the configuration class with ShareKit like this:
DefaultSHKConfigurator *configurator = [[MYSHKConfigurator alloc] init];
[SHKConfiguration sharedInstanceWithConfigurator:configurator];
And removed the configuration info from SHKConfig.h. I don't know why but this worked.
note: you could also get away by not subclassing and entering the configuration info directly inside the DefaultSHKConfigurator.m if you are not interested in updating ShareKit;
If you wish the Facebook screen to load inside the app and not in safari you can get inside the Facebook.m file and change the safariAuth: from YES to NO:
[self authorizeWithFBAppAuth:YES safariAuth:NO];
Same issue here, when I stop after complete step 5 in https://github.com/ShareKit/ShareKit/wiki/Installing-sharekit.
Always got "safari cannot open then page because the address is invalid",
Finally, issue solved by complete all steps(1 to 7)
Have not changed the statement [self authorizeWithFBAppAuth:YES safariAuth:YES];
I am using the official facebook ios sdk in my app (https://github.com/facebook/facebook-ios-sdk)
It was all working fine. I was able to log in, pull all my info from Facebook, post things on my wall. Do all those regular stuff that you do...
But since last night, it appears to be broken. When the login window appears and the user logs in, instead of getting the authkey and getting a callback. The login window directs users to facebook.com.
Did anyone else notice the problem? Is there any fix to it or we just assume that the graph API is broken right now and wait?
I assume Facebook were just having a problem. If you had it working & did not change the code then the issue is elsewhere?
In general it's a pain to get working so the following is a brief hint to anyone who is stuck.
Having spent 2 days getting this working I recommend (assuming you have registered an app with Facebook) :
First get the demo app working.
This ensures you have your app ID and worked out how to add the URL stuff into the plist. This is explained in the docs so should not give you much trouble.
Once all the options in the demo app work (login, post, upload a sample photo) you can think about your own app.
Many things are different but you still need to have the AppDelegate method for the URL stuff. Also this method does not work as is assuming your app is using more than one view controller.
I went for the approach of setting up facebook in the app delegate eg:
Facebook *facebook
and in the actual facebook routine referencing that appDelegate's facebook object eg:
appDelegate.facebook
This approach is the subject of quite a few posts on the interweb so you should be able to google it.
I can log on, get info, post & upload photos.
I'm having the same issue, i downloaded the "official example" from gitHub, and wehn compiled it does she#. After i login, it open safari and redirects to http://www.facebook.com/connect/uiserver.php, and the app stalls. Well that's not the way to do it, Facebook. They are obsoleting the old rest api, meanwhile the "new" graph things not working. Im currently using graph API with my own calls to graph.
Check if you have done the following
1.URL scheme corresponding to your Facebook application ID is set. Your URL Schemes must contain item looking like "fb1234567890"
2.AppDelegate's method must be implemented:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
it is described in https://github.com/facebook/facebook-ios-sdk "Authentication and Authorization".
Read also "Single Sign-On".