ios - 如何使用facebook sdk从iphone在facebook上分享截图

标签 ios objective-c facebook facebook-graph-api

我是这个领域的新手。任何人都可以帮助将应用内屏幕截图分享到 Facebook。我一直在尝试使用 [FBDialogs presentShareDialogWithParams] 共享屏幕截图,但随后显示只有 FBLinkShareParams: only\"http\"or\"https\"schemes are supported for link thumbnails

我们如何在 Facebook 上分享 iOS 设备的应用内截图?

最佳答案

希望对你有帮助

-(void)FBshareScreenshot{
    if ([FBDialogs canPresentShareDialogWithPhotos]) {
        FBPhotoParams *params = [[FBPhotoParams alloc] init];
        UIImage *screenshot = [self captureScreenshot]; //calling to capture screenshot
        params.photos = @[screenshot];
        [FBDialogs presentShareDialogWithPhotoParams:params
                                         clientState:nil
                                             handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {

                                                 if(error) {
                                                     NSLog(@"Error publishing story = %@.", error);
                                                     NSLog(@"result = %@.", results);
                                                 } else if (results[@"completionGesture"] && [results[@"completionGesture"] isEqualToString:@"cancel"]) {
                                                     NSLog(@"User canceled photo publishing.");
                                                 } else {
                                                     NSLog(@"photo posted");
                                                 }
                                             }];
    }else {
       //The user doesn't have the Facebook for iOS app installed, so we can't present the Share Dialog
       /*Fallback: You have two options
         1. Share the photo as a Custom Story using a "share a photo" Open Graph action, and publish it using API calls.
         See our Custom Stories tutorial: https://developers.facebook.com/docs/ios/open-graph
         2. Upload the photo making a requestForUploadPhoto
         See the reference: https://developers.facebook.com/docs/reference/ios/current/class/FBRequest/#requestForUploadPhoto:
         */
    }
}


-(UIImage *)captureScreenshot{
    UIGraphicsBeginImageContext(self.view.bounds.size);
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *imageView = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
  //  UIImageWriteToSavedPhotosAlbum(imageView, nil, nil, nil);
    return imageView;
}

关于ios - 如何使用facebook sdk从iphone在facebook上分享截图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25042196/

相关文章:

ios - 指向非常量类型 Tile * 的指针,没有明确的所有权

facebook - 请求对话框代码不执行任何操作

iOS7延迟应用UIKeyboardAppearanceDark

ios - UIButton 标题对齐不会更改为 RTL 中的正确方向

ios - Xcode 9 在 iOS 10.1.1 上运行的应用程序在启动时崩溃

objective-c - 获取 TableView 的标题titleForHeaderInSection

ios - Objective-C 创建一个 ViewController 的实例

iPhone:可变长度的UILabel,多行字符串,多种字体

Android Facebook 共享和墙贴在 Webview 中使用共享 url 不起作用

ios - Facebook登录问题iOS