SLComposeViewController "Facebook not available" - facebook

I'm using the code snippet which was posted on my previous question, Simple way to add Facebook/Twitter share to app?
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *slComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[slComposeViewController setInitialText:#"Your text"];
[slComposeViewController addImage:[UIImage imageNamed:#"NameOfImage"]];
[self presentViewController:slComposeViewController animated:YES completion:nil];
} else {
//Show alert or in some way handle the fact that the device does not support this //feature
NSLog(#"Facebook not available");
}
But when I run it on the device and in the simulator all I'm getting is "Facebook not available", what could I be doing wrong?
I've looked at the available tutorials, and I've included the libraries that are required, so I'm not sure what else I'm doing wrong.

In Settings.app/Facebook, you need to set up an account.
SLComposeViewController only allows you to posts on FaceBook if you have an account. That's normal behavior, that's how FaceBook works: No account, nothing to do there.
Since iOS6, you can enter your account in iOS allowing apps to use this account with some of the iOS framework without importing the Facebook SDK. Of course, you have little options with the Social.framework, and if you want to do more, like timelines, etc. you'll have to use the FaceBook SDK.

Related

Facebook sharing on app doesn't work

I use social framework for Facebook and Twitter sharing integration into app. On the iPad Air iOS 8.1 it doesn't work for Facebook.
-(IBAction)Facebook:(id)sender{
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *FACEBOOK = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[FACEBOOK setInitialText:[NSString stringWithFormat:#"Wow, look at my new high score!"];
[self presentViewController:FACEBOOK animated:YES completion:nil];
}
else{
UIAlertView *alert =[[UIAlertView alloc]initWithTitle:#"FaceBook Signed Out" message:#"Add or create Facebook account in Settings." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
}
For the above iPad Air iOS 8.1, nothing at all appears in shared message.
However, for iPad non-retina iOS 8.1.2, the above code works fine and message appears in shared message.
What's going on? Even the signed out message doesn't appear as I stated in code for iPad Air iOS 8.1. Why isn't it working on all iOS 8's or is this an iPad Retina issue?
Any form is prefilling is not allowed, as stated in the policy. Previously it was still possible using setInitialText, but recently this has been also been enforced on the software side. Any values provided here are not used in the dialog.
In this case, it's actually a bug (or limitation of the platform) that it is still working on the non-retine iOS 8.1.2 iPad. Please don't rely on this; in a next update this might also become enforced through software.

iphone Social framework, make text read only

Here is my code:
SLComposeViewController*fvc = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
[fvc setInitialText:string];
[fvc addImage:[UIImage imageNamed:#"email.png"]];
[fvc setCompletionHandler:^(SLComposeViewControllerResult result) {
How to make facebook post title and text read only ?
I don't think that can be done with the standard framework. (The idea being that posting to Facebook is left as a user activity, not something you can force on them.)
You could, of course, go lower-level and talk to the Facebook API directly but that would be a lot more work. You'll probably find that people don't change the suggested text very much anyway.

iOS: Incorrect/Repetitive Facebook Request Message

I'm using the Facebook SDK and Parse.
I am submitting additional requests for the users email, events, and their friends' events.
Although I receive this info successfully, users who are logged into iOS' facebook system get this popup when I request permissions.
Notice that they are already logged into facebook (via the settings app) and they are simply getting a message to approve the request.
As you can see, it repeats the info about basic profile and friend list (FB login gives you this by default) and doesn't even mention the email. Since I doubt Apple or FB has made this kind of mistake, I assume it has something to do with me. Here is how I request access using FB and Parse.
// The permissions requested from the user
NSArray *permissionsArray = #[ #"email, user_events, friends_events"];
// Login PFUser using Facebook
[PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error) {
[activityIndicator stopAnimating]; // Hide loading indicator
if (!user) {
if (!error) {
NSLog(#"Uh oh. The user cancelled the Facebook login.");
} else {
NSLog(#"Uh oh. An error occurred: %#", error);
}
} else if (user.isNew) {
NSLog(#"User with facebook signed up and logged in!");
[self.delegate ViewWasDismissed];
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
} else {
NSLog(#"User with facebook logged in!");
[self.delegate ViewWasDismissed];
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}
}];
again, this request WORKS. Therefore, I can't imagine what I could be doing wrong, but the message is strange. Any ideas?
EDIT: I tried deleting my account from the iOS facebook system and requesting directly through the app. This time I got this message:
Notice that here, the user is logged into facebook via the FB app and simply gets this (correct) message to accept permissions.
Is this some kindof bug with Apple's Facebook system?
This is the correct behaviour that will happened for iOS. Since iOS 6, Apple has integrated Facebook to the devices. Therefore, users can log in Facebook from Settings page. Below are the scenario that explain your confusions.
Scenario 1: Logged in to Facebook from Settings page
The app will automatically detect the Facebook account from your device if there's any, and prompt you the permissions request with UIAlertView. This only happen if you're using latest SDK and I am not so sure since which SDK that Facebook released for iOS has this.
Scenario 2: Not logged in to Facebook from Settings page (Old way)
The app will lead you to Facebook app if it's installed in your device. Else it will lead you to Safari with Facebook mobile page open and ask you for permissions that the app required.
Hope this help :)

Facebook iOS SDK Logout

I'm using the official and updated Facebook iOS SDK.
We're developing an application on an iPad that is used inside a physical store using an in-house distribution profile. Where customers can login to their Facebook account on an iPad that's publicly available to improve their shopping experience.
The problem I came across is that when a user logs into their Facebook account, the next user (customer) will still be logged in with the previous users' credentials (You have already authorized xxx, Press "Okay" to continue). Ofcourse this is not okay.
Is there a way to actually logout (sign off, clear credentials, or what ever) the previous (or current) user so the next user can fill in its own username and password.
Unfortunately [[FBSession activeSession] closeAndClearTokenInformation] doesn't quite do the trick.
This is a part of the code so far:
// ....
[[FBSession activeSession] closeAndClearTokenInformation];
[FBSession.activeSession openWithCompletionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
// More code ...
}];
// ...
PS. The cookie 'workaround' doesn't work for me (obviously)
From your context, I'm assuming your device(s) does not have the Facebook app installed nor do you expect to use iOS 6 system authentication which would leave the default login behavior to use Safari. If you were to clear the Safari cookies, that should work but for a smoother experience in your scenario you should use the FBSession openWithBehavior:completionHandler: method and specify a behavior of FBSessionLoginBehaviorForcingWebview so that it uses the inline webview dialog for authentication.
See the SwitchUserSample in the Facebook iOS SDK for an example since that sample demonstrates an app that can toggle between multiple accounts.
Try with this code. I think it will help you.
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logOut];
If you are using facebook sdk 4.1.0 just call bellow method
if ([FBSDKAccessToken currentAccessToken]) {
[FBSDKAccessToken setCurrentAccessToken:nil];
[FBSDKProfile setCurrentProfile:nil];
}

How to do the Facebook authentication in a dialog instead of Safari webpage

When do a iPhone app that uses Facebook connect, I followed the guide for SSO (http://developers.facebook.com/docs/guides/mobile/) but I hate that SSO sends me to a Safari Page. I want to do the authentication in a dialog instead.
Please tell me if you ever met the same issues. Thank you.
In Facebook.m you need to change the following code:
- (void)authorize:(NSArray *)permissions
delegate:(id<FBSessionDelegate>)delegate {
[_permissions release];
_permissions = [permissions retain];
_sessionDelegate = delegate;
/* safariAuth should be NO */
[self authorizeWithFBAppAuth:NO safariAuth:NO];
/*
authorizeWithFBAppAuth: will launch the Facebook App
safariAuth: will launch Mobile Safari
When both of these are set to NO, the Facebook Login
Dialog will appear inside of your app.
*/
}