我正在尝试将新的Facebook集成到我正在开发的应用程序中,由于某种原因,每当我尝试共享一个链接时,共享屏幕就不会出现。我被踢到了Facebook应用程序(或者如果没有安装Facebook应用程序的话),但是我从来没有任何选择来分享我试图让用户发布的链接。
我基本上遵循了Facebook开发人员站点上的示例T,但作为参考,下面是我的代码:
- (IBAction)shareToFacebook:(id)sender {
NSLog(@"Share to Facebook");
FBSDKShareLinkContent *content = [FBSDKShareLinkContent new];
content.contentURL = [NSURL URLWithString:@"http://google.com"];
content.contentTitle = @"Test Post!";
content.contentDescription = @"Content Description;
FBSDKShareDialog *shareDialog = [FBSDKShareDialog new];
[shareDialog setMode:FBSDKShareDialogModeAutomatic];
[shareDialog setShareContent:content];
[shareDialog setFromViewController:self];
[shareDialog show];
// [FBSDKShareDialog showFromViewController:self withContent:content delegate:nil];
}正如您在上面看到的,我尝试使用Facebook在文档中使用的两种方便方法,以及更详细的方法,但都产生了相同的结果(打开Facebook应用程序,但没有给用户一个分享任何内容的选项)。任何帮助都是非常感谢的!
发布于 2015-04-09 22:24:08
它实际上是我的应用程序info.plist中的一个小错误。只要提醒其他人得到类似的错误,就可以检查他们在那里设置的所有信息,并确保所有信息都是正确的。
发布于 2015-04-30 00:50:14
添加代码
[shareDialog setDelegate:self]<FBSDKSharingDelegate>到您的班级FBSDKSharing代码
# FBSDKSharingDelegate -(Void)共享者:(Id)共享者didCompleteWithResults :(NSDictionary *)结果{ NSLog(@"FB:共享RESULTS=%@\n",结果debugDescription);}-(Void)共享者:(Id)共享者didFailWithError:(NSError *)错误{ NSLog(@"FB: ERROR=%@\n",error debugDescription);}-(Void)sharerDidCancel:(Id)共享者{ NSLog(@"FB: SHARER=%@\n",sharer debugDescription);}在didFailWithError中设置断点,您可以看到许多有趣的底层错误描述。
发布于 2016-04-28 11:16:33
此示例用于将图像从应用程序共享到facebook,并使用!
func shareWithFacebook(){
let share : FBSDKShareLinkContent = FBSDKShareLinkContent()
share.imageURL = NSURL(string: "image url")
share.contentTitle = "content description "
share.contentURL = NSURL(string: "https://www.example.com")
let dialog : FBSDKShareDialog = FBSDKShareDialog()
dialog.fromViewController = self
dialog.shareContent = share
let facebookURL = NSURL(string: "fbauth2://app")
if(UIApplication.sharedApplication().canOpenURL(facebookURL!)){
dialog.mode = FBSDKShareDialogMode.Native
}else{
dialog.mode = FBSDKShareDialogMode.FeedWeb
}
dialog.show()
}别忘了添加facebook框架
https://stackoverflow.com/questions/29547971
复制相似问题