Connect Facebook Social Plugin with FB iOS SDK - objective-c

In one of our app, our user already logged in using the iOS FB SDK, and in one page is am displaying the comment box social plugin to render comments, but seems it can't use the existing logged session.
Are there any steps required so user don't need to double login?

Comments box social plugin is not designed for iOS. But we can make it work by restricting the user to sign into FB only using WebView popup. To achieve this, set NO for both authorizeWithFBAppAuth and safariAuth in - (void)authorize:(NSArray *)permissions; method of Facebook.m
- (void)authorize:(NSArray *)permissions {
self.permissions = permissions;
[self authorizeWithFBAppAuth:NO safariAuth:NO];
}
This will store all the facebook credentials in sharedHTTPCookieStorage. Now when you load your comments box social plugin using webview, it will recognize the existing session.

Related

Facebook instant game login with JS SDK

I am trying to upload my game made with React to Facebook Instant games. I have facebook login implemented with Facebook JS SDK. But facebook instant game runs inside a sandboxed iframe which blocks any popups and I cannot run FB.login(). In instant games docs it says that FB.login should work and it should open a popup in 'async' mode. But it doesn't. Login popup gets blocked and I get the following error:
Blocked opening ... in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.
You are looking for the wrong documentation, which leads to Legacy Web games.
You need to refer to the Facebook Instant Game SDK to get the user information inside a FB Instant Game. Most importantly FB Instant games don't allow to use of the Facebook Graph API within the FB Instant Game. Although the Graph API offers more capabilities like getting the user gender, the Facebook Instant Game SDK only exposes a limited number of data for developers. The Facebook Login for the Web with the JavaScript SDK is an OAuth login that cannot be used inside a FB Instant Game.
FYI: Facebook Instant GAme SDK v7.0 doesn't provide all the user information about the user. It only provides the following data
Display Name
var playerName = FBInstant.player.getName()
Profile Picture
var playerImage = new Image();
playerImage.crossOrigin = 'anonymous';
playerImage.src = FBInstant.player.getPhoto();
You can only use the above information in your FB instant games.

unable to share auto text on facebook in ios 8 .

When I click on fb icon to share auto text, it appear in popup view if am not logged in. but if I login in facebook application it doesn't appear the auto text.However it works proper on twitter and mail.
This is intended behaviour. Pre-filling is not allowed (2.3) and when using the Facebook App, this is programatically enforced.

Can we authenticate facebook user which view page in UIWebView?

I work on application which provide bonus content for certain actions Facebook Share, Facebook Like of our page and etc.
I have problem with Facebook Like, as we know Facebook SDK ToS don't allow us (developers) to programmatically like Facebook page, so I have two ideas
Open the native Facebook APP, which is straight forward.
UIWebView within' our APP. But here is the problem
How to authenticate the user in facebook, to skip the inconvenience of double login. (The first time is within' our app, to be able to fetch the result of /me/likes/(id))?
I also faced the same problem for liking pages
i found this
https://github.com/brow/FacebookLikeView it is very help full go through this it shows how to like face book pages by using web view
hope this helps

Facebook library login dialog how to modify its appearance?

Using the facebook library in order to login I call this method:
+ (BOOL)openActiveSessionWithReadPermissions:(NSArray*)readPermissions
allowLoginUI:(BOOL)allowLoginUI
completionHandler:(FBSessionStateHandler)handler;
If the allowLoginUI:(BOOL)allowLoginUI parameter is set to yes the facebook login dialog is shown in full screen. Is there any way to change that and have the login dialog appear not in full screen? I would like it to just appear on foreground and take most of the screen size but not full screen.
I've seen this done but I would like to know if it is possible with the current facebook library?
I do not believe you are allowed to modify the login UI. I have seen devs getting rejected for modifying other aspects of the facebook SDK UI bundle (namely the login button) but this was clearly not acceptable.
My best guess is to set allowUI to no, and sort of mimic your own interface.
Although, from a UX perspective, I would prefer you kept it in the style defined by the FB SDK.

FBConnect login, share with a webview?

I am using FBConnect in my iOS project to authorize the user (SSO).
Once logged in, I sometimes need to open a Webview in order to show the user specific dialogs such as the app request dialog (invite to app) and even to open a friend's profile page in a webview for my app user to browse.
The problem is that the Webview doesn't recognize the logged in user and asks him to login again, this is not very friendly.
Any ideas how to share the logged in auth key/cookie/something with the webview?
You are likely running into this situation. It's really frustrating.
Facebook iOS SDK not storing cookies for access
You can, if you want, force the iOS library to use your app for login, and authorize through a UIWebview local to your app. You are thus logged in, and have cookies to use. You'll have to add a method to the existing Facebook object. Normally, you call:
- (void) authorize:(NSArray *)permissions
delegate:(id<FBSessionDelegate>)delegate
to authorize, which in turns calls the private method:
- (void)authorizeWithFBAppAuth:(BOOL)tryFBAppAuth
safariAuth:(BOOL)trySafariAuth
with both parameters set to YES.
You want to add a public method that calls the same private function but with both parameters set to NO. I added this method to Facebook.m and declared it in Facebook.h so I could call it however I like:
- (void)authorize:(NSArray *)permissions
tryFBApp:(BOOL) tryFBApp
trySafariAuth:(BOOL) trySafariAuth
delegate:(id<FBSessionDelegate>)delegate {
[_permissions release];
_permissions = [permissions retain];
_sessionDelegate = delegate;
[self authorizeWithFBAppAuth:tryFBApp safariAuth:trySafariAuth];
}
I call that with the two BOOL parameters set to NO, and the library pops ups a local UIWebView that leaves me with cookies that work for the app.
FBConnect returns you a token so that you have access to the FB API not the FB website. Unfortunately this doesn't login them in through a UIWebView and set the proper FB cookies.
Another strategy would be to change in the FBConnect source code to redirect to your own UIWebView instead of the standard FB pop-out to the FB-APP process and have them login only once. You would however have to persist the cookie state of the UIWebView.
I suggest that you also take a look at http://www.getsocialize.com which can help you manage social network integration.
good luck!