Ilker Baltaci
Ilker Baltaci

Reputation: 11779

Facebook SDK 3.0 permissions array for FBSession holds wrong permissions

With Facebook sdk 3.1 I want to make sure that the app has the "publish_stream" right just before i send the post request.

The problem is [FBSession.activeSession.permissions indexOfObject:@"publish_stream"] never return NSNotFound even if the user chooses allow none during login.This causes a problem naturally because i assume that i have the right to send the post but it returns HTTP status code 403 since i do not have the required right actually.

IS is a bug or is there another way to check the permissions of the active session.

Upvotes: 1

Views: 1958

Answers (4)

Pedro Romão
Pedro Romão

Reputation: 2327

As @Zorayr said you can do as follows.

NSArray *permissions = FBSession.activeSession.permissions;
    if ([permissions containsObject:@"publish_actions"]) {
       [self performNextTestWithLastPostID:nil];
    } else {
        ...
}

Upvotes: 0

Tapan Thaker
Tapan Thaker

Reputation: 362

[FBSession.activeSession.permissions indexOfObject:@"publish_stream"] != NSNotFound

The code above is not the right way to check for write permissions.

Instead of that please try the following :

-(BOOL)hasWritePermissions{

    NSArray *permissiones = [FBSession activeSession].permissions;
    for (NSString *permission in permissiones) {

        if ([permission isEqualToString:@"publish_actions"]) {
            return YES;
        }
    }

    return NO;
}

Upvotes: 0

Alexander Poleschuk
Alexander Poleschuk

Reputation: 1039

Facebook confirmed that it is a bug in iOS SDK: https://developers.facebook.com/bugs/111727002307769

The bug still remains in iOS SDK 3.1

A workaround is to check permissons using API call /me/permissions as Igy proposed.

Upvotes: 0

Igy
Igy

Reputation: 43816

If you make an API call to /me/permissions all permissions currently associated with the access token you're using will be returned

Upvotes: 1

Related Questions