Search code examples
iosfacebook-ios-sdkfacebook-share

where is the FBSDKShareDialog shareFromViewController method


download the latest Facebook SDK and followed the Document:

FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:@"http://developers.facebook.com"];
[FBSDKShareDialog shareFromViewController:self
                              withContent:content
                                 delegate:nil];

But there is a issue, no shareFromViewController method ! There is only has showFromViewController method, It can't do the share job,where is the share method?


Solution

  • There is no shareFromViewController method in SDK for sharing.It's the showFromViewController method used for sharing.

    [FBSDKShareDialog showFromViewController:self
                                     withContent:tempContent
                                        delegate:self];
    

    OR

    FBSDKShareDialog *shareDialog = [[FBSDKShareDialog alloc] init];
    shareDialog.delegate=self;
    shareDialog.fromViewController = self;
    shareDialog.shareContent = content;
    [shareDialog show];
    

    //Delegate methods

    - (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results{
    
    }
     - (void)sharerDidCancel:(id<FBSDKSharing>)sharer{
    
    }
    
    - (void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error{
    NSLog(@"%@",error);
    }