4
当Safari打开URL时,我可以轻松链接到Facebook上的特定帖子,但是我还没有找到在Facebook应用中打开该帖子的方法。在用户点击“更多帖子”之前,Facebook应用程序只显示最近三个帖子。因此,找到他们感兴趣的帖子有点困难。这是我现在的代码,它允许用户链接到Safari中的确切文章,但是如果安装了Facebook应用程序,则不会。iOS:如何从我的应用程序中在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];
}
}
是这么想的工作的一个网址,而是应该:FB://后/ 123456789_123456789
如提前实际上是试图解决它,我会记住这。三年来是漫长的等待时间:-) – Tjalsma