你有没有想过检查一下Facebook wall上的分享是否成功?
我想知道是用户从SDK的界面取消了共享操作,还是由于技术问题而没有发布。
我在iOS 7上使用框架"FacebookSDK/FacebookSDK.h“的FBDialogs。
像presentShareDialogWithPhotoParams这样的处理程序块永远不会被调用。
提前谢谢。再见。
发布于 2014-04-25 17:00:58
当您呈现提要对话框时,您可以使用以下代码来检测用户何时成功分享帖子、何时用户取消操作或何时发生错误:
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(@"%@", [NSString stringWithFormat:@"Error publishing story: %@", error.description]);
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User cancelled.
NSLog(@"User cancelled.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:@"post_id"]) {
// User cancelled.
NSLog(@"User cancelled.");
} else {
// User clicked the Share button
NSString *result = [NSString stringWithFormat: @"Posted story, id: %@", [urlParams valueForKey:@"post_id"]];
NSLog(@"result %@", result);
}
}
}
}];当你显示分享对话框时,你可以让来自服务器的以下错误来处理是否成功分享了帖子:
[FBDialogs presentShareDialogWithLink:params.link
name:params.name
caption:params.caption
description:params.description
picture:params.picture
clientState:nil
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(@"%@", [NSString stringWithFormat:@"Error publishing story: %@", error.description]);
} else {
// Success
NSLog(@"result %@", results);
}
}];https://stackoverflow.com/questions/23227398
复制相似问题