I am developing a facebook app and is wondering how to set the permission array.
in the Facebook SDK version before all I need to do is create an instance from Facebook.h and set the permission. But now the facebook.h file is no long there, and stopped work for SDK3.0 and 3.1.
Facebook said to import the depreciated files but if I do that I get lots of errors, so that didn't work at all.
and I cannot find any documents regard setting permission property on iOS 5 and later, could someone help me out?
thanks!!
[FBSession openActiveSessionWithPublishPermissions:[[NSArray alloc] initWithObjects:#"publish_stream",#"email", nil]
defaultAudience:FBSessionDefaultAudienceFriends
allowLoginUI:YES
completionHandler:^(FBSession *session,
FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
you can find a short tutroail and simple code samples in http://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/3.1/
Related
I am using the following code to present the user with the Facebook Embedded WebView Dialog in an iOS 7 app
FBSession *session = [[FBSession alloc] initWithPermissions:#[#"basic_info", #"email"]];
[FBSession setActiveSession:session];
[session openWithBehavior:FBSessionLoginBehaviorForcingWebView completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
[self sessionStateChanged:session state:status error:error];
}];
On my development iPad, I see the Facebook dialog and login view just fine. On iPhone, the dialog fills the screen just fine, but the spinning progress indicator just sits there forever. Our QA team is seeing the never ending spinning progress indicator on both devices.
Has anyone else seen this behavior? I am about to give up and just implement the Mobile Safari Login Dialog.
I use
FBSessionLoginBehaviorWithFallbackToWebView
and it works for me.
EDIT: You may also want to check to make sure you have the Advanced setting "Embedded Browser OAuth Login" turned on for you Facebook app.
Okay, when I try to open new session with publish permissions and pass array of permissions, facebook sdk pops up me an error. com.facebook.sdk code 2 error (which has a lot of explanations and I'm pretty sure that I tried almost everything from here).
That looks something like this:
permissions = [NSArray arrayWithObjects:#"publish_actions", #"publish_stream", nil];
[FBSession openActiveSessionWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceFriends allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
if I say: permissions = nil; And call this same thing, everything works okay. After that, I am able to call same function WITH permissions and user is able to post directly on facebook (directly on wall). Am I missing something?
I'm working with latest facebook sdk (3.8 I think) and testing on device with 6.1.4 version iOS.
Maybe I should try to call requestNewPublishPermissions for an active session after opening new session with nil permissions?
In the last SDK, read and publish permissions are separated. So, in my code, whenever the users logs in I am using this code:
[FBSession openActiveSessionWithReadPermissions:nil
allowLoginUI:YES
completionHandler:
^(FBSession *session,
FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
I have seen in the facebook developer that when I want to publish, I should ask for publish permissions like this:
// can include any of the "publish" or "manage" permissions
NSArray *permissions =
[NSArray arrayWithObjects:#"publish_actions", nil];
[[FBSession activeSession] reauthorizeWithPublishPermissions:permissions
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
/* handle success + failure in block */
}];
Since this is my first app that I am using facebook integration, I want to ask a couple of things:
1) Can these sessions be open at the same time? I will ask for the publish permissions only when the user wants to publish, but should I do something else with the other session? Like close it first, and reopen it later or I should not worry about?
2) If I have a postToFriends button for example, my pseudocode for making it work would be like this, right?
- (IBAction)postToFriendaction:(id)sender {
if (!FBSession.activeSession.isOpen) {
/* code from the above for enabling publish permissions*/
}
or I should change !FBSession.activeSession.isOpen to something else, because no the user is logged in with read permission only, he never enters the if clause. Can you help me?
The two sessions you refer to are actually the same session (it's the "active" session that's statically available after a call to openActiveSession... is called). So you don't need to do anything with the other session.
You should have a look at either the Scrumptious or Hello Facebook sample apps that ship with the SDK. They both give examples on how to post (while asking for publish permissions).
Has anyone solved this error message when a user is in the login flow? I tried to toggle my default privacy settings in DevCenter -> Permissions.
I am using the deprecated method in order to both get read and right permissions at the same time. I have other apps successfully using this method.
- (void)openSession
{
[FBSession openActiveSessionWithPermissions:[[NSArray alloc] initWithObjects:#"email",#"publish_actions",#"user_birthday", nil] allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
[self sessionStateChanged:session state:status error:error];
}];
}
I've already replied to your bug report on our developer website(https://developers.facebook.com/bugs/568170979870794).
If you're entering the FacebookDisplayName in your .plist file, it will opt you in for read-write permissions split. What this means is that you can no longer request read/write permissions together(using our deprecated openActiveSessionWithPermissions call). This is not a breaking change but is by design.
Set sandbox mode to no in your application settings in facebook.
I was able to fix this by removing the newly added FacebookDisplayName property ( as of FB SDK 3.5) from the *.plist file.
Opened a bug # facebook:
https://developers.facebook.com/bugs/568170979870794
If remove my app from Facebook App Center and then I try to authorize my app with
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
The alert ("Don't allow", "OK") that should be displayed requesting for access is not shown, instead when the completion handler is called FBSessionState will be FBSessionStateOpen which is wrong.
The second time I try to authorize it will always show the access alert correctly.
Am I the only one experiencing this? Is there a solution for this issue?
We now have better error handling in our new SDK 3.2.
Please check out our new SDK release 3.2 here: https://developers.facebook.com/blog/post/2013/02/25/facebook-sdk-3-2-for-ios/