iOS上的Facebook Share Dialog / Feed对话框 - 如何知道是否点击了分享按钮或取消按钮

时间:2013-07-30 14:58:49

标签: ios facebook dialog share

我试图在我的iOS应用中实现Facebook共享对话框。我尝试了两个Share Dialog

https://developers.facebook.com/ios/share-dialog/

和Feed对话框

https://developers.facebook.com/docs/howtos/feed-dialog-using-ios-sdk/

在这两种情况下,我都能够实际分享我的内容,但我的问题是我无法跟踪用户是否真的"共享"或"取消"退出。

上面的链接显示处理程序(甚至是注释),如果用户实际共享内容,则会触发。但是当代码实际运行时,它总是返回正值,换句话说,我无法区分取消按钮是否被击中或分享按钮。

如果我错过了任何内容,或者其他人遇到同样的问题,请指出我。

谢谢,

2 个答案:

答案 0 :(得分:0)

更新以防万一这有助于任何人,以下链接最终为我工作:

https://developers.facebook.com/docs/howtos/ios-6/#nativepostcontroller

虽然它有它的局限性(不能在iOS< 6上运行),但是当用户取消对话框时它会成功返回我。这是我使用的代码:

BOOL displayedNativeDialog = [FBDialogs presentOSIntegratedShareDialogModallyFrom:self
                  initialText:[NSString stringWithFormat:@"%@", url]
                  image:nil
                  url:url
                  handler:^(FBOSIntegratedShareDialogResult result, NSError *error) {                                                  
                  if(result == 0)
                  {
                       //Fire our callback

                  }
                  else{
                        NSLog(@"USER CANCELLED");
                  }
          }];

答案 1 :(得分:0)

以下是如何在您的控制台上获得显式结果。

FBDialogs.PresentShareDialog(myAction,"altimeterthree:share","flight",(call, results, error) => {
    if(call != null)show("Call = " + call.ToString());
    if(results != null)Console.WriteLine("Results = "+results.ToString());
    if(error != null)Console.WriteLine("Error = "+FBErrorUtility.UserMessage(error));
});

这是控制台输出的样子。请注意,结果也在呼叫信息中。

2014-05-11 10:09:26.067 AltimeterThree[18988:60b] Call = <FBAppCall: 0x19e02350, ID: 4589F102-3D11-40D5-BC95-1A1852B341AC
 dialogData: <FBDialogsData: 0x19e04e20, method: ogshare
 arguments: {
    action =     {
        flight =         {
            data =             {
            };
            description = "my description";
            "fbsdk:create_object" = 1;
            id = 1413672752238899;
            image =             (
                                {
                    url = "<UIImage: 0x147f9180>";
                    "user_generated" = true;
                }
            );
            title = "Flight 23";
            type = "altimeterthree:flight";
            url = "http://http://samples.ogp.me/1413756595563848";
        };
    };
    actionType = "altimeterthree:share";
    previewPropertyName = flight;
}
 results: {
    completionGesture = cancel;
    didComplete = 1;
}>
>
2014-05-11 10:09:26.070 AltimeterThree[18988:60b] Results = {
    completionGesture = cancel;
    didComplete = 1;
}