How to share product information using the iOS app on Facebook

I am making an online shopping application. I want to create functionality to post my product data to Facebook. Can someone tell me how I can achieve this?

I want to automatically share product information in fb when the user clicks the sharing button.

+4
source share
3 answers

I think you already have an image of your product and detailed information about it. Thus, Facebook provides SKD, where you can share information about your product with the click of a button. You can also redirect users to your link when users click on your message.

for more information about FBSDKShareKit, please go through this FB developer link

Here is the code to share information about your product and send users to your page when they click on it,

just write this code in your share button method.

 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];

make sure you import FBSDKCoreKit / FBSDKCoreKit.h and FBSDKShareKit / FBSDKShareKit.h into your .h file and add delegates to it.

+8
source

IOS 11 update

Facebook, Twitter 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 Sharing Doc

Twitter Sharing Doc

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

, Social Framework. .

enter image description here

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

+3

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];

  }
+1

Source: https://habr.com/ru/post/1682179/


All Articles