我在iOS应用中添加了Facebook原生分享对话框,让用户可以分享一些数据。问题是,对话框无法打开。这是代码。另外,将图像的URL传递给方法是正常的吗?也许,这是问题吗?
BOOL displayedNativeDialog =
[FBNativeDialogs
presentShareDialogModallyFrom:self
initialText:activityName
image:activityImageURL
url:activityURL
handler:^(FBNativeDialogResult result, NSError *error) {
if (error) {
NSLOG(@"Error occured");
} else {
if (result == FBNativeDialogResultSucceeded) {
NSLOG(@"Success");
} else {
NSLOG(@"No success");
}
}
}];
if (!displayedNativeDialog) {
NSLOG("Window does notdisplayed");
}
答案 0 :(得分:0)
答案 1 :(得分:0)
只有在用户安装了Facebook App时才能使用本机对话框。首先检查Facebook应用程序是否可用,然后显示本机对话框或相应地显示Web对话框:
FBShareDialogParams *shareParams = [[FBShareDialogParams alloc] init];
shareParams.link = [NSURL URLWithString:@"http://some-url.com"];
shareParams.name = @"Post Name";
shareParams.picture= [NSURL URLWithString:someImageURL];
shareParams.description = @"Post Description";
if ([FBDialogs canPresentShareDialogWithParams:shareParams])
{
[FBDialogs presentShareDialogWithParams:shareParams
clientState:nil
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
NSLog(@"%@", [error localizedDescription]);
}];
}
else
{
NSDictionary *params = @{
@"name" : shareParams.name,
@"description" : shareParams.description,
@"picture" : objectiveCharacterImageURL,
@"link" : linkURL
};
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
}];
}