Facebook SDK for iOS 6.0 native共享对话框

时间:2012-12-16 11:33:28

标签: ios facebook share

我在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");
   }

2 个答案:

答案 0 :(得分:0)

而不是  图片:activityImageURL 将UIImage数据传递给图像  image:[UIImage imageWithNamed:@“blahblah”]

答案 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) {

                                              }];
}