My app needs to send a private message to the user's Facebook friend. The user needs to grant the XMPP permission before my app can do this.
[[FBSession activeSession]
requestNewPublishPermissions:[NSArray arrayWithObjects:
#"publish_stream",
#"xmpp_login",
nil
]
defaultAudience:FBSessionDefaultAudienceEveryone
completionHandler:^(FBSession *session, NSError *error) {
}
];
The above code will pop up this alert view as expected:
However, even before tapping any button, this warning is printed out in the debug log:
FBSDKLog: FBSession: a permission request for publish or manage
permissions contains unexpected read permissions
Surely enough, after tapping the "OK" button, the completion handler comes back with an error, containing the same warning. I understand that the Facebook API requires asking for read and write permissions separately, but the xmpp_login permission seems to need both read and write at the same time. I'm at a dead end here.
iOS 7.1
Facebook SDK 3.12.0
Xcode 5.1
See the section Extended Permissions in this link.
According to this, xmpp_login is the read permission, not the write/publish permission. So you should add that the readPermission
Related
I just started using facebook sdk and slightly confused with it documentation. It's well written, but very often does not correspond to current SDK version. So i'm not found what to do with this situation:
I request publish permissions when firstly require them, with the next code:
[[FBSession activeSession] requestNewPublishPermissions:permissions
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
if (error) {
NSLog(#"Permissions request error: %#", error.description);
}
completion(error == nil);
}];
I need only one publish permission - 'publish_actions', when i request it sdk redirects me to facebook app and immediately returns back to the my app without asking whether i'm agree to give this permission.
There are no errors in completionHandler, but through debug i found that this permission was saved in the variable _requestedReauthPermissions:
So, finally, permission i requested not granted to me.
How properly request publish permission? What could I miss? May it occur due to setup of facebook app?
every time you tap the facebook login button you are asked to accept the read permissions regardless of whether you just accepted them on your previous login attempt. you can accept the read permissions and land back in the app, only to logout, login, and be presented with the read permissions to accept yet again.
this issue did not exist prior to 3.5, 3.5.1, or the new 3.5.2. Due to this issue my application is stuck on the latest version of the pre v3.5 version of the sdk (3.2.1).
to me, this sounds like a bug in the facebook sdk/app but when i submitted this bug report it was marked as "triaged/low priority" and had the following note attached: "Thanks for the report. We are prioritizing other reports at the moment. You may want to check out http://facebook.stackoverflow.com/" so here i am.
my logic behind the assertion of it being a facebook server side thing is that we are making an auth request to facebook. it is within the facebook realm that they decide what permissions you have and have not accepted. how can it be a fault on my side? it is not the developer's job to tell facebook what their own user has accepted or not.
heres the code that i have behind the "Login with Facebook" button touch up event:
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
if (appDelegate.session.state != FBSessionStateCreated) {
appDelegate.session = [[FBSession alloc] initWithPermissions:permissions];
}
[appDelegate.session openWithCompletionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
if([appDelegate.session isOpen]) {
//login ui flow finished here
}
}];
anybody have any thoughts?
I'm sure there's something simple I'm missing regarding this, but when using requestForUploadPhoto to send a photo to an album, it gets sent up with permission set to 'Only me'. Because the permission setting is so restrictive, photos then need to be manually approved by the user. Is there a way to alter the default upload permission (which will hopefully stop it requiring manual approval)? Normally it would be set when requesting a publish permission, but because user_photos is technically a read permission, I'm not given the chance to specify this. Code is below.
[FBSession openActiveSessionWithReadPermissions:[NSArray arrayWithObject:#"user_photos"] allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
FBRequest* request = [FBRequest requestForUploadPhoto:uploadImage];
FBRequestConnection* connection = [[FBRequestConnection alloc] init];
[connection addRequest:request completionHandler:^(FBRequestConnection* connection, id result, NSError* error)
{ NSLog(#"Done with upload"); }];
[connection start];
}];
I know it's not even slightly close in terms of catching and managing other session changes, but I'm not fussed with that atm - I just want to get this permission issue resolved before coding the rest.
user_photos only allows you to see photos (using GET), and does not allow you to post a photo. To do that, you need either publish_stream or publish_actions. Are you sure your app didn't already have a publish permission somehow?
You are correct in that the privacy is set when an app requests publish permissions, and the user can change that at any point later on as well (via the Facebook app or website).
I'm trying to get post permissions from a user using the Facebook SDK on iOS.
I'm calling the code below in a method that is called if the app does not have the required publishing permissions to post to the users facebook wall.
// No permissions found in session, ask for it
[FBSession.activeSession requestNewPublishPermissions: [NSArray arrayWithObject:#"publish_actions"]
defaultAudience: FBSessionDefaultAudienceEveryone
completionHandler: ^(FBSession *session, NSError *error)
{
if( !error )
{
// Do something
}
}];
The first time I call this code it takes the user to the permissions page, and before it even switches to safari on the device the block gets called and this error message is returned
Error Domain=com.facebook.sdk Code=2 "The operation couldn’t be completed. (com.facebook.sdk error 2.)" UserInfo=0xc426410 {com.facebook.sdk:ErrorLoginFailedReason=com.facebook.sdk:ErrorReauthorizeFailedReasonUserCancelled,
The app then continues on to show the permissions page in safari where the user selects ok. Then it returns to the app. Permissions have not been set at this point even tho the user was presented with the permissions page and accepted.
When trying to post a second time it takes the user to the permissions page in safari and the requestNewPublishPermissions method doesn't fail instantly. The user selects ok and then everything works as expected.
So it is only on the very first time calling requestNewPublishPermissions that it fails instantly returning the error ErrorReauthorizeFailedReasonUserCancelled.
This happens in the simulator and on the device.
Any idea what might be causing this?
I found the solution to this problem on the answer to this question Facebook iOS 3.1 sdk login with publish permission callbacks
dispatch_async(dispatch_get_current_queue(), ^{
[self openSessionForPublishPermissions];
});
Where opensessionforpublishpermissions is the method that contains the requestNewPublishPermissions method.
"The reason is that the call to reauthorize.. needs to be after the event loop of which openActiveSession.. is called."
I assume this is a bug in the Facebook SDK, it doesn't make sense for this to be normal behaviour and I haven't seen any of the Facebook docs comment on this being the expected behaviour.
I had the similar issue, and the answer, provided by Tiddly worked for me. For some time.
Later I ran across the same issue. I don't know why, may be it was concerned with SDK or iOS updates, may be run loop of the app became more complicated. So I inspected FB SDK source and figured out that this issue occurs when you ask publish permissions just after read permissions, like this:
// Open with read permissions
[FBSession openActiveSessionWithReadPermissions: readPermissions
allowLoginUI: YES
completionHandler: ^
(FBSession *session, FBSessionState status, NSError *error)
{
// Ask for publish permissions (This is incorrect!)
[FBSession.activeSession requestNewPublishPermissions:publishPermissions
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:
^(FBSession *session, NSError *error)
{
// ...
}];
}];
When your app switches to Safari or FacebookApp and back,
-application: openURL: sourceApplication: annotation:
is called. CompletionHandler of
+openActiveSessionWithReadPermissions:
called immediately after this, before
applicationDidBecomeActive:. And after you start reauthorisation
applicationDidBecomeActive: is finally called. So, FB SDK think that user has returned back to the app, without giving permissions and reauthorisation fails with that "com.facebook.sdk error 2." error.
Sometimes dispatch_async() works well. But the robust solution, is to wait for active session to handle App Did Become Active event. And then request additional publish permissions. Here is an example of how to achieve this:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[FBAppCall handleDidBecomeActive];
if (self.shouldReauthorise) {
[self requestPublishPermissions];
self.shouldReauthorise = NO;
}
}
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