繁体   English   中英

如何在Facebook上分享IOS应用程序的产品详细信息

[英]How to share product details from IOS app in Facebook

我正在制作基于在线购物的应用程序。 我想创建一个功能,在Facebook上发布我的产品详细信息。 谁能告诉我如何实现这一目标?

我想在用户按分享按钮时自动在fb中分享产品详细信息。

我想您已经拥有了产品图片及其详细信息。 所以Facebook提供了一个SKD,只需点击一下按钮就可以分享您的产品信息。 此外,当用户点击您的帖子时,您还可以让用户重定向到您的链接。

有关FBSDKShareKit的更多信息,请通过此FB获取开发人员链接

以下是用于分享您的产品信息并在用户点击时将用户发送到您的网页的代码,

只需在您的共享按钮方法中编写此代码即可。

 FBSDKShareLinkContent *content =[[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:@"your product page URL here"];
content.imageURL = [NSURL URLWithString:@"your product image url here"];
content.contentTitle= @"Title of your product";
content.contentDescription=@"Description of your product";
FBSDKShareDialog *dialog=[[FBSDKShareDialog alloc]init];
dialog.mode=FBSDKShareDialogModeNative;
if (![dialog canShow]) {
    // fallback presentation when there is no FB app
    dialog.mode = FBSDKShareDialogModeWeb;
    //
}
dialog.shareContent=content;
dialog.delegate=self;
dialog.fromViewController=self;
[dialog show];

确保在.h文件中导入FBSDKCoreKit / FBSDKCoreKit.h和FBSDKShareKit / FBSDKShareKit.h并将代理添加到其中。

iOS 11更新

FacebookTwitter和其他应用程序选项已在“ Settings应用中删除。

现在,应用程序将像其他应用程序一样使用iOS sharing extensions

let share = [image, text, url]
let activityViewController = UIActivityViewController(activityItems: share, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view
self.present(activityViewController, animated: true, completion: nil)

您还可以使用第三方SDK进行个人共享

Facebook分享文件

Twitter分享文档

================================================== ========================

您可以使用社交框架分享帖子。 你也可以在twitter上分享。

在此输入图像描述

目标C.

#import <Social/Social.h>


if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
    SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

    [controller setInitialText:@"First post from my iPhone app"];
    [self presentViewController:controller animated:YES completion:Nil];        
}

迅速

import Social

let vc = SLComposeViewController(forServiceType:SLServiceTypeFacebook)
vc.add(imageView.image!)
vc.add(URL(string: "http://www.example.com/"))
vc.setInitialText("Initial text here.")
self.present(vc, animated: true, completion: nil)

更多详情Facebook和Twitter分享

使用SLComposeViewController显示本机对话框并在Facebook上发布您的内容。

 if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {

    __weak CFShareToFacebookViewController *weakSelf = self;

        SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

        [controller setInitialText:self.captionTextField.text];
        [controller addURL:[NSURL URLWithString:@"http://www.google.com"]];
        [controller addImage:self.selectedImage];
        [controller setCompletionHandler:^(SLComposeViewControllerResult result) {

          switch (result) {
            case SLComposeViewControllerResultCancelled:
              break;
            case SLComposeViewControllerResultDone: {

            }
              break;

            default:
              break;
          }
        }];

        [self presentViewController:controller animated:YES completion:Nil];

  }

暂无
暂无

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

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