Like button in iOS application - ios

Does anybody know how to place Facebook "like" button into iOS application? I've tried the method described in this blog post. But I do not really like this method, because its ugly Login dialog. And, what is more important, it makes user login twice. For example, user wants post a message to his wall if he isn't logged in I call standard FBLoginDialog, after that user posted a message he may want push "like" button and he have to login again - it is really bad user experience.
How to be? How can I give user "like" feature in my iOS app?

That is actually the only way to do it. There is no special iOS like button. However, the good news is that just today Facebook announced single sign in support for mobile apps. This should remove some of the burden the user faces to log in to facebook.

It seems there is an agreement on not being able to do this. This question shows you can, as does the FB Graph API documentation:
You can comment on or like any object that has a /comments or /likes
connection by posting to https://graph.facebook.com/OBJECT_ID/comments
and https://graph.facebook.com/OBJECT_ID/likes, respectively.
Unfortunately, according to this question you can’t like a page.

I like using ShareKit: http://www.getsharekit.com/
It's not exactly what you're looking for, but still...

The only way supported by Facebook on any platform (web, mobile, etc) is from their iFrame code. From iOS, that means embedding a UIWebView into your application with the iFrame code. Note that it does require them to login via Safari.

- (void)addLikeButton{
[FBSettings enableBetaFeature:TRUE];
[FBSettings enablePlatformCompatibility:NO];
_like = [[FBLikeControl alloc] init];
_like.frame = CGRectMake(60,12,200,33);
_like.likeControlAuxiliaryPosition = FBLikeControlAuxiliaryPositionInline;
_like.likeControlHorizontalAlignment = FBLikeControlHorizontalAlignmentLeft;
_like.objectID = #"https://www.facebook.com/pages/Strana-Gapra/1377227779244834";
_like.likeControlStyle = FBLikeControlStyleStandard ;
[_like addTarget:self action:#selector(onSelect:) forControlEvents:UIControlEventValueChanged];
[self.likeView addSubview:_like];
[self performSelector:#selector(getLikeSubviews) withObject:nil afterDelay:0.6];
}

Related

Is it possible to invite friends without showing Facebook dialog?

I am building an iOS app that is using facebook to gain traction. I would like to invite some friends, that user selects from list, but without showing facebook confirmation dialog, i want that to happen behind the scenes.
Reading documentation there is property frictionlessRequestsEnabled, but even that shows dialog, where i have option to disable showing dialog in the future. Is there some other way to do this?
Many apps invite all of your friends without showing the Facebook Dialog Box. It is possible by modifying the FBSDK. Simply clone the FBSDK repository to your local machine, edit in Xcode and Command+B to build the framework for your own use. The following classes are relevant to inviting in the FBSDK for iOS:
FBSDKWebDialogView
FBSDKWebDialog
FBSDKGameRequestDialog
To get the URL Generated for the dialog view:
In FBSDKWebDialog.m in -(BOOL)show:
NSURL *URL = [self _generateURL:&error];
This is the URL generated to load the web view. It is possible to use this URL without the web dialog view, as long as it is only generated once (access token gets reset every time the URL is generated) and is used on a mobile browser.
To Invite Without The Dialog Box
You can use javascript to simulate clicking the go button by doing something like this (assuming you have specified your parameters and recipients properly and your app is already set up through Facebook)
In FBSDKWebDialogView.m in - (void)webViewDidFinishLoad:(UIWebView *)webView :
[NSTimer scheduledTimerWithTimeInterval:.1 target:[NSBlockOperation blockOperationWithBlock:^{ NSString * jsCallBack = [NSString stringWithFormat:#"document.getElementById(\"u_0_0\").click();"];
[webView stringByEvaluatingJavaScriptFromString:jsCallBack];
[webView stringByEvaluatingJavaScriptFromString:#"document.getElementById(\"u_0_0\").click();"]; }] selector:#selector(main) userInfo:nil repeats:NO ];
As long as the webView is present somewhere, you may be able to do these actions with little interference for the user. You could set the webView frame to be very small, or potentially hide the view altogether.
Facebook is however, policing hard against this sort of thing and it likely that that there will be more protection against this in the future.
FBSDK Repo Here:
https://github.com/facebook/facebook-ios-sdk

How do you get the Twitter and Facebook icons in your apps

I created a Twitter and Facebook SHARE buttons. However, I don't know if i'm allowed to use the official Twitter bird logo and the official Facebook F logo as a custom image button on my app. Are developers allowed to do that or are we supposed to get permission from Facebook and Twitter? Or should I just create a custom button that says Facebook, Twitter on it? I've seen only official facebook and twitter logos on game apps and other apps. How is it done?
Both Facebook and Twitter have strict guidelines for that, which you can find on their corresponding developer sites. You will also find the necessary resources (i.e. images) on these sites. It is typically not ok to use custom images.
That said, the official guides are not always followed and personally I have never heard of anyone being held responsible for doing it wrong. But I would strongly encourage you to follow them in any case.
At least for Facebook, I would always advise to use the official SDK and the Share Button it provided. You can read more here: https://developers.facebook.com/docs/sharing/ios#triggering
FBSDKShareButton *button = [[FBSDKShareButton alloc] init];
button.shareContent = content;
[self.view addSubview:button];

Inviting facebook friends in Air app for iOS

I'm working currently on an Air app for iOS and i have some hard time trying to make "invite friends" button. I'm using facebook-actionscript-api 1.8.1 with air 3.3 and I have something like this in my code:
invite_button.addEventListener(MouseEvent.CLICK, facebookInvite);
private function facebookInvite(e:MouseEvent):void
{
var dat:Object = new Object();
dat.message = 'I invite you to this awesome app!';
dat.title = 'Super Extra Max Facebook App';
dat.filters = ['app_non_users'];
Facebook.ui('apprequest', dat);
}
Button displays only if user is logged in.
But when I tried to tap the button I got debugging error:
ExternalInterface not available on the device.
Well, I guess the meaning of this is obvious - it's trying to use JS.
How can I show friends select dialog and send invitations from within an app? I thought I can write some StageWebView container and display the dialog in it but isn't there some other, probably simpler way?
Ok, so I finally found this thread on API page in issues a while ago:
http://code.google.com/p/facebook-actionscript-api/issues/detail?id=365
5th comment links to the thing I used. It appears it is just what I needed.
Next time I'm just going to use native component...

Creating share buttons in iOS app ( twitter facebook...)

I was wondering what is a good way to create share buttons in iOS, and by share buttons I mean these 3 kinds of buttons:
1- Follow me on Twitter
2- Like a page on Facebook
3- Send a mail (Optional)
I have heard about sharekit but I am interested in just creating these 3 buttons that will be found on the back of the page of the app.
You can use something like:
NSString *launchUrl = #"http://twitter.com/intent/user?screen_name=USER NAME";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: launchUrl]];
which will open Mobile Safari and let you follow that user. You may be required to log in.
I guess there is a similar URL for Facebook.
To send a mail from within your app, use the MessageUI Framework.
Posting data to social services is much more complicated than just setting up a button. You must register your application, choose user, authenticate, then communicate via the internet.
ShareKit does most of that for you.
You may not just 'create share button' and have it share data to fb or twitter.
Posting to those service is complicated because you'll have to create Apps on those social networks as well as handle the oauth handshake the occurs which allows your app to share on behalf of the user. The Socialize SDK (www.getsocialize.com) is the fastest way to get Facebook/Twitter authentication without coding it yourself. Sample code below:
Socialize* socialize = [[Socialize alloc] initWithDelegate:self];
[self.socialize createShareForEntityWithKey:#"http://www.url.com" medium:SocializeShareMediumFacebook text:#"Check this out!"];
You could use ShareKit 2.0
https://github.com/ShareKit/ShareKit
I believe it supports sharing on most common social networks.

iOS: Adding a Facebook Like button to a native iPhone app

I would like to know whether it is possible to add a Facebook Like button to a native iPhone app. In the app, the user browses a business directory or deals. When they tap on an item to view the details, it would be nice to have a Facebook Like button that can be used to post the item to the user's Facebook page.
Facebook writes: "Currently, the Like button is only available in mobile web apps".
My app is a native app and not a web app, so therefore I assume it's not possible. However, I do assume that it is possible to mix native UI components on a screen along with web components and therefore it might be possible to implement the Like button, although I am not sure how you pass data from the native portion to the web portion.
If the only solution is a hack, then I won't implement it because at some point the hack will fail when Facebook alters their API.
read around SO a little, you get many leads. Here's one:
Like button in iOS application
And a comment points to github.com/brow/FacebookLikeView
It has same caveats, but it seems there aren't any magic solutions.
There are these blogposts as well:
http://angelolloqui.blogspot.com/2010/11/facebook-like-button-on-ios.html
http://petersteinberger.com/2010/06/add-facebook-like-button-with-facebook-connect-iphone-sdk/
But not sure you get a native UIButton. Maybe you can open a webview in the background and emulate a click on it...
GL, update if you have some findings,
Oded.
Now you can use the FBlike button using the following code but it need to download latest sdk and it is the beta version :(
Here is the code:
[FBSettings enableBetaFeature:FBBetaFeaturesLikeButton];
[FBSettings enablePlatformCompatibility:NO];
FBLikeControl *like = [[FBLikeControl alloc] init];
like.objectID = #"http://shareitexampleapp.parseapp.com/photo1/";
like.likeControlHorizontalAlignment=FBLikeControlHorizontalAlignmentRight;
like.likeControlStyle=FBLikeControlStyleBoxCount;
[self.view addSubview like];
It looks like Facebook finally decided to allow this, more directly, via the Open Graph API.
See documentation here
Check this out, FB just made it possible through their SDK. Only for testing and ios for now
https://developers.facebook.com/docs/ios/like-button/

Resources