简体   繁体   English

iOS上的Facebook共享对话框/进纸对话框-如何知道是否轻按了共享按钮或取消按钮

[英]Facebook Share Dialog/Feed Dialog on iOS - how to know if share button or cancel button is tapped

I was trying to implement a Facebook share dialog in my iOS app. 我试图在我的iOS应用程序中实现Facebook分享对话框。 I tried both the Share Dialog 我尝试了两个共享对话框

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

and Feed dialog 和提要对话框

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

In both the cases I was able to actually share my content, but my problem is I cannot track whether the user actually "Shared" or "Cancel"ed out. 在这两种情况下,我都可以实际共享我的内容,但是我的问题是我无法跟踪用户实际上是“共享”还是“取消”用户。

The links above show handlers (even comments are there) which gets fired if the user actually shares the content. 上面的链接显示了处理程序(甚至有注释),如果用户实际共享内容,则将触发该处理程序。 But when the code is actually run, it always returns positive or in other words I'm not being able to distinguish if the cancel button was hit or the share button. 但是,当代码实际运行时,它总是返回正数,换句话说,我无法区分是按下了取消按钮还是共享按钮。

Please point me out if I'm missing out anything, or if anyone else has faced the same issue. 如果我遗漏了任何东西,或者其他人也遇到了同样的问题,请给我指出。

Thanks, 谢谢,

Updating just in case this helps anyone, the following link finally worked for me: 更新以防万一这对任何人都有用,下面的链接终于对我有用:

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

Though it had it's limitations (doesn't run on iOS < 6), but it successfully returns me when the user cancels out the dialog. 尽管它有局限性(不能在iOS <6上运行),但是当用户取消对话框时,它会成功返回我。 Here's the code I used: 这是我使用的代码:

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");
                  }
          }];

Here's how to get the explicit result on your console. 这是在控制台上获得明确结果的方法。

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));
});

Here's what the console output looks like. 控制台输出如下所示。 Notice that the result is also in the call info. 请注意,结果也包含在呼叫信息中。

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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM