【问题标题】:Trigger.IO - Cancelling Facebook UI dialogue fires success callbackTrigger.IO - 取消 Facebook UI 对话会触发成功回调
【发布时间】:2012-11-13 15:02:39
【问题描述】:

我正在使用 forge facebook api 打开提要对话框以将图像发布到用户墙上。如果用户单击“取消”而不是“共享”,则仍会触发成功回调。如果用户点击关闭 (x) 按钮,错误回调将正确触发。

    forge.facebook.ui(
          {
            method: 'feed',
            link: link,
            picture: model.get('file').url,
            name: name,
            caption: caption,
            description: 'Lorem Ipsum'
          },
          function(response) {

            // Called when user clicks cancel.

            forge.notification.create(
              'Great!',
              'Item has been posted to your wall',
              function() {

              },
              function(error) {
                forge.logging.error(JSON.stringify(error));
              }
            );

          },
          function (e) {
            // Called when user closes dialogue but not on cancel.
            forge.logging.info('facebook failed: ' + JSON.stringify(e));
          }
        );

【问题讨论】:

  • 您是否检查了响应以查看它是否传递了您可以关闭的任何数据?
  • 是的,我检查了响应,在这两种情况下都未定义。

标签: facebook trigger.io


【解决方案1】:

我倾向于同意这是出乎意料的行为 - 但是它在多个 Facebook 提供的 SDK 中是一致的,并且已经有一段时间了,因此我们按原样通过了它。

如果用户点击对话框左上角的x,您的错误回调将被调用。如果用户取消对话,你的成功回调将被调用,{} 作为回调参数。

我建议使用以下内容检查这种情况:

forge.facebook.ui({
        method: 'feed',
        link: link,
    },
    function (response) {
        if (JSON.stringify(response) === "{}") {
            handleCancel();
        } else {
            handleSuccess(response);
        }
    }
    function (error) {
        handleError(error);
    }
);

【讨论】:

  • 谢谢詹姆斯。问题是取消和保存的响应回调参数完全相同。即 JSON.stringify(response) 返回 null。因此,无论哪种情况,检查 JSON.stringify(response) === "{}" 都不会返回 true。是否期望 SDK 在“保存”时返回空响应?
  • 我看到这已在 v1.4.23 中修复。 docs.trigger.io/en/v1.4/release-notes.html#v1-4-23
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-09-03
  • 1970-01-01
  • 2012-05-04
  • 1970-01-01
  • 2013-01-25
  • 2018-12-23
  • 1970-01-01
相关资源
最近更新 更多