gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 22:01:12 25 4
gpt4 key购买 nike

我是这个领域的新手。任何人都可以帮助将应用内屏幕截图分享到 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com