2012-08-17 164 views
0

我有一個類型爲「Native iOS」的http://developer.facebook.com的Facebook應用,該應用使用新的Facebook iOS SDK 3.0連接到實際的iOS應用。篩選FBFriendPickerViewController在新Facebook 3.0中返回的朋友

如何知道是否已經安裝了應用程序並授權Facebook應用程序的多個人,因此我可以將它們放在某個列表中,但這不是我的問題,因爲我知道有一個名爲「已安裝」的字段,當用戶安裝應用程序時返回true

因此,如果我想根據用戶是否使用該應用程序篩選返回的朋友FBFriendPickerViewController,那麼我如何使用installed字段或其他名稱來篩選朋友。

注意:我知道在哪裏過濾好友(*),我需要的是我需要檢查的字段或屬性,以確保用戶安裝我的應用程序。

* - (BOOL)friendPickerViewController:(FBFriendPickerViewController *)friendPicker shouldIncludeUser:(id<FBGraphUser>)user

回答

0

我發現了一個辦法做到這一點:

我創建發送FQL那些我需要(例如我的朋友,他們都是男性)

,然後一個方法比較那些由該請求使用該方法已被FBFriendPickerViewController存在返回:

- (BOOL)friendPickerViewController:(FBFriendPickerViewController *)friendPicker shouldIncludeUser:(id<FBGraphUser>)user

的要求:

NSDictionary *queryParam = [NSDictionary dictionaryWithObjectsAndKeys:@"query", @"q", nil]; 
[FBRequestConnection startWithGraphPath:@"/fql" parameters:queryParam HTTPMethod:@"GET" 
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 
      if (error) 
      { 
       UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Oops" message:@"Some thing go wrong !, Try again" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; 

       [alert show]; 
      } 
      else 
      { 
       NSArray *friendInfo = (NSArray *) [result objectForKey:@"data"]; 

       for(int i = 0; i < [friendInfo count]; i++) 
       { 
        [self.friendsNames addObject:[[friendInfo objectAtIndex:i] objectForKey:@"name"]]; 
       } 
      }  
}]; 

正如你看到的我有一個存儲過濾朋友的NSArray,下一步是將它們在上面的委託方法進行比較。

希望你覺得它有用。

相關問題