SHARE
TWEET

Fix for Fecebook SDK when retrieving user permissions

priore Aug 30th, 2013 481 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // fix for Facebook SDK bug (from 3.0 to 3.7.1) https://developers.facebook.com/bugs/111727002307769
  2. - (void)getUserDataPermissionsComplete:(void(^)(NSArray *permissions, NSError *error))completeBlock {
  3.  
  4.     FBRequest *requestPermissions = [FBRequest requestWithGraphPath:@"me/permissions" parameters:Nil HTTPMethod:@"GET"];
  5.     [requestPermissions startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
  6.         if (completeBlock) {
  7.             NSMutableArray *permiss = [NSMutableArray array];
  8.             NSArray *data = [(NSDictionary*)result objectForKey:@"data"];
  9.             if (data && data.count > 0) {
  10.                 NSDictionary *dict = [data objectAtIndex:0];
  11.                 for (NSString *key in dict.allKeys) {
  12.                     if ([[dict objectForKey:key] boolValue]) {
  13.                         [permiss addObject:key];
  14.                     }
  15.                 }
  16.             }
  17.             completeBlock(permiss , error);
  18.         }
  19.     }];
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top