我可以在新的FB对话中预选朋友吗?

时间:2014-05-12 11:13:10

标签: ios facebook-graph-api facebook-ios-sdk

我正在使用FBDialogs打开Facebook Messenger(如果用户已在设备上安装它)以发送个人消息。但是我不能在我的应用程序中预先选择朋友(信使总是给我一个列表并提示我选择那里)。

FB Messenger

我正在使用presentMessageDialogWithParams:clientState:handler:收到FBLinkShareParams object

  

FBLinkShareParams好友阵列

     

要在帖子中标记的NSStrings数组或FBGraphUsers。如果使用NSStrings,则值必须表示要标记的用户的ID。

但是当我发送FBGraphUsers时,他们没有在Messenger应用程序中预先选择。他们应该吗?或者这只是一个"标记为朋友"功能?

我的代码:

NSMutableArray *inviteFriends = [[NSMutableArray alloc] init];

FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
                                              NSDictionary* result,
                                              NSError *error) {
    NSArray* friends = [result objectForKey:@"data"];
    NSLog(@"Found: %i friends", friends.count);
    for (NSDictionary<FBGraphUser>* friend in friends) {
        if ([friend.name isEqualToString:@"XXX"]) {
            NSLog(@"I have a friend named %@ with id %@", friend.name, friend.id);
            [inviteFriends addObject:friend];
        }
    }

    FBLinkShareParams *params = [[FBLinkShareParams alloc] init];
    params.link = [NSURL URLWithString:@"https://developers.facebook.com/docs/ios/share/"];
    params.name = @"Message Dialog Tutorial";
    params.caption = @"Build great social apps that engage your friends.";
    params.picture = [NSURL URLWithString:@"http://i.imgur.com/g3Qc1HN.png"];
    params.description = @"Send links from your app using the iOS SDK.";
    params.friends = inviteFriends;


    // If the Facebook app is installed and we can present the share dialog
    if ([FBDialogs canPresentMessageDialogWithParams:params]) {
        [FBDialogs presentMessageDialogWithParams:params clientState:nil handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
            //
        }];
    }
}];

1 个答案:

答案 0 :(得分:1)

Messenger会忽略“friends”和“place”参数,因为这些参数特定于标记,而Messenger不支持标记。

您无法使用消息对话框指定要预选的用户。

我们将在未来更新文档以反映这一点。

相关问题