iOS:如何从应用程序中打开Facebook应用程序中的特定帖子?

iOS:如何从应用程序中打开Facebook应用程序中的特定帖子?,ios,facebook,Ios,Facebook,当Safari打开URL时,我可以轻松链接到Facebook上的特定帖子,但我还没有找到在Facebook应用程序中打开该帖子的方法。在用户点击“更多帖子”之前,Facebook应用程序只显示大约三篇最近的帖子。所以要找到他们感兴趣的职位有点困难。这是我现在的代码,它允许用户在Safari中链接到确切的帖子,但如果安装了Facebook应用程序,则不能 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIn

当Safari打开URL时,我可以轻松链接到Facebook上的特定帖子,但我还没有找到在Facebook应用程序中打开该帖子的方法。在用户点击“更多帖子”之前,Facebook应用程序只显示大约三篇最近的帖子。所以要找到他们感兴趣的职位有点困难。这是我现在的代码,它允许用户在Safari中链接到确切的帖子,但如果安装了Facebook应用程序,则不能

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *postID = [[parsedPosts objectAtIndex:[indexPath indexAtPosition:1]] objectForKey:@"post_id"];
    NSArray *idParts = [postID componentsSeparatedByString:@"_"];
    UIApplication *sharedApp = [UIApplication sharedApplication];
    NSURL *faceBookURL = [NSURL URLWithString:[NSString stringWithFormat:@"fb://profile/%@", [idParts objectAtIndex:0]]];
    if([sharedApp canOpenURL:faceBookURL]){
         [sharedApp openURL:faceBookURL];
    } else {
        NSURL *safariURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://m.facebook.com/story.php?story_fbid=%@&id=%@", [idParts objectAtIndex:1], [idParts objectAtIndex:0]]];
        [sharedApp openURL:safariURL];
    }
}

一个不起作用的URL,但应该是:fb://post/123456789_123456789

,如果仍然是这样的话

首先,您需要将您的帖子id按字符“\”拆分

然后使用path:fb://profile/{id},其中{id}将等于从拆分中获得的数组的第二部分。这对我有用

澄清:
ID 123456_789789将成为一个数组=[123456789],然后您的url将如下所示:fb://profile/789789

在实际尝试之前,我会将其标记为已解决。三年等待的时间太长了:-)