我在项目中添加了UIActivityController
。看起来这个特定主题的帮助很少。我面临的问题是链接在Facebook上以奇怪的方式分享,而不是通常在Facebook上共享的方式。为了更有意义,照片和链接都在iOS Photos文件夹中,没有任何选项可以更改它。
下面是他们目前如何在Facebook上分享的示例图片:
他们通常如何在Facebook上分享我想要的东西:
以下是我用于在项目中添加UIActivityController的代码:
UIActivityViewController *objVC = [[UIActivityViewController alloc]initWithActivityItems:[NSArray arrayWithObjects:titleString, [NSURL URLWithString:urlString], imageTaker, nil] applicationActivities:nil];
[self presentViewController:objVC animated:YES completion:nil];
[objVC setCompletionHandler:^(NSString *activityType, BOOL completed)
{
NSLog(@"Activity = %@",activityType);
NSLog(@"Completed Status = %d",completed);
if (completed)
{
UIAlertView *objalert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"Posting was success" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[objalert show];
objalert = nil;
}else
{
UIAlertView *objalert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"Posting was not successful" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[objalert show];
objalert = nil;
}
}];
除此之外,我还在控制台中收到一些警告,如下:
Registering unknown app identifier com.apple.mobilemail failed
Unable to find app identifier com.apple.mobilemail
Registering unknown app identifier com.apple.MobileSMS failed
Unable to find app identifier com.apple.MobileSMS
更新:我还尝试集成REActivityController
,这是一个实现相同功能但具有额外功能的库,但我遇到了同样的问题。
答案 0 :(得分:2)
共享链接,避免传入图像。所以使用代码链接:
UIActivityViewController *objVC = [[UIActivityViewController alloc]initWithActivityItems:[NSArray arrayWithObjects:[NSURL URLWithString:urlString], nil] applicationActivities:nil];
或者这个:
UIActivityViewController *objVC = [[UIActivityViewController alloc]initWithActivityItems:[NSArray arrayWithObjects:titleString, [NSURL URLWithString:urlString], nil] applicationActivities:nil];
要记住的关键是,如果您指定图像,那么它被视为照片共享故事,您的标题和网址最终与照片标题类似。如果省略图像,则将其视为链接共享,您的标题将成为消息。
如果链接有Open Graph标签,最终的故事在Facebook上正确渲染,并且通过正确渲染我的意思是你会看到图片,标题,描述等。如果链接中没有嵌入Open Graph标签,那么链接只显示在生成的故事中。