繁体   English   中英

适用于iOS 6.0的Facebook SDK本机“共享”对话框

[英]Facebook SDK for iOS 6.0 native Share dialog

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

代替image:activityImageURL,将UIImage数据传递到图像image:[UIImage imageWithNamed:@“ blahblah”]

仅当用户安装了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) {

                                              }];
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM