2012-01-18 108 views
1

我正在iPhone上開發一個應用程序,我需要邀請朋友加入我的應用程序,通過使用圖形API在FB上發送消息,我也希望當用戶點擊邀請FB的朋友時那麼我的應用程序顯示對話框實際上是FB對話框,其中顯示了他的所有朋友,並且用戶可以選擇想要發送消息的朋友。由於通過FB邀請朋友在Ios中自己申請

回答

-1

使用@ 「facebook.events.invite」 的方法來邀請你的朋友從iPhone

 params = [NSDictionary dictionaryWithObjectsAndKeys:facebookEventString,@"eid",udidsString,@"uids",nil]; 
     [[FBRequest requestWithDelegate:self] call:@"facebook.events.invite" params:params]; 
+0

我已經知道這樣的想法,但是這不是我想要的,怎麼我需要FB對話框,用戶選擇特定的他的朋友。 – Aleem 2012-01-18 13:44:27

4

您可以通過使用無摩擦的要求如下做到這一點

NSString *to =[NSString stringWithFormat:@"%d",[[[FriendUIDArray 
objectAtIndex:index] 
                objectForKey:@"uid"] intValue]]; 

FBFrictionlessRecipientCache *friendCache = 
[[FBFrictionlessRecipientCache alloc] init]; [friendCache 
prefetchAndCacheForSession:nil]; 


NSMutableDictionary* params = [NSMutableDictionary 
dictionaryWithObjectsAndKeys: 
            to, @"to", 
            nil]; 

[FBWebDialogs presentRequestsDialogModallyWithSession:nil 
     message:[NSString stringWithFormat:@"I’m using Nightup to find great party's 
     around me."] title:nil parameters:params handler:^(FBWebDialogResult result, 
     NSURL *resultURL, NSError *error) 
     { 
                if (error) { 
                 // Case A: Error launching the dialog or sending request. 
                 NSLog(@"Error sending request."); 
                } else { 
                 if (result == FBWebDialogResultDialogNotCompleted) { 
                  // Case B: User clicked the "x" icon 
                  NSLog(@"User canceled request."); 
                 } else { 
                  NSLog(@"Request Sent."); 
                 } 
     }} 

     friendCache:friendCache]; 

如果你沒有你想邀請的特定朋友的UID,那麼按照這個方法,你可以在對話框中選擇朋友。

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:nil]; 
[FBWebDialogs presentRequestsDialogModallyWithSession:nil 
       message:[NSString stringWithFormat:@"I just smashed %d friends! Can you beat it?", nScore] 
       title:nil 
       parameters:params 
       handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) { 
        if (error) { 
         // Case A: Error launching the dialog or sending request. 
         NSLog(@"Error sending request."); 
        } else { 
         if (result == FBWebDialogResultDialogNotCompleted) { 
          // Case B: User clicked the "x" icon 
          NSLog(@"User canceled request."); 
         } else { 
          NSLog(@"Request Sent."); 
        } 
}}]; 

你可以找到更多的細節here