Search code examples
iosfacebookfacebook-ios-sdk

Friends Online Presence - Facebook SDK 3


Is it possible to find my friends online presence ( online,away or error ) with Facebook SDK?

Using FQL I could do it like this:

   SELECT uid, name,pic_small,pic_big,online_presence FROM user
  WHERE online_presence IN ('active') AND uid IN
   (SELECT uid2 FROM friend WHERE uid1 = me())order by name

But is there a way to do it in facebook SDK, may be using something like this:

  [FBRequest requestForGraphPath:@"some/end/point/that/I/am/missing"]

Any help appreciated. Thanks.


Solution

  • Sorry for being late to post it here... I had solved this issue myself, here is my solution:

    - (void)getFriendsOnlinePresence
    {
    
    NSString* fql1 = [NSString stringWithFormat:@"SELECT uid,pic_square, name,online_presence FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY name"];
    NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                    fql1, @"q",
                                    nil];
    [FBSession openActiveSessionWithAllowLoginUI:NO];
    [FBRequestConnection startWithGraphPath:@"fql"
                                 parameters:params
                                 HTTPMethod:@"GET"
                          completionHandler:^(FBRequestConnection *connection,
                                              id result,
                                              NSError *error) {
                              if (error) {
                                  NSLog(@"Error: %@", [error localizedDescription]);
                              } else {
                                  NSLog(@"Result: %@", result);
                                  }
                              }
    //Notify via notification center
                          }];
    
    }