0

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

2 回答 2

0

只有当用户安装了 Facebook 应用程序时,您才能使用本机对话框。首先检查 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) {

                                              }];
}
于 2014-04-29T22:02:05.463 回答
0

而不是 image:activityImageURL 将 UIImage 数据传递给 image image:[UIImage imageWithNamed:@"blahblah"]

于 2013-02-01T16:59:44.653 回答