Facebook Share Dialog在成功/取消后未关闭

时间:2015-12-17 14:49:28

标签: c# ios facebook xamarin facebook-share

我设法将Facebook(Xamarin.Facebook.iOS)与自定义类(ShareDialog具有受保护的构造函数)整合到我的游戏中:

public class MyShareDialog : Facebook.ShareKit.ShareDialog
    {
        public MyShareDialog() : base(NSObjectFlag.Empty)
        {
        }
    }

然后我创建并显示Dialog:

string url = "http://my-url.com/class-to-generate-picture.php?score=" + Board.Score + "&textUp=" + 
System.Web.HttpUtility.UrlEncode("facebook_I_Scored".Localize());

                var myShareDialog = new MyShareDialog();


                var content = new Facebook.ShareKit.ShareLinkContent {
                    ContentDescription = "facebook_URLTitle".Localize(), 
                    ContentTitle = "facebook_URLDescription1".Localize() + " " + 
                        Board.Score + " " + "facebook_URLDescription2".Localize(), 
                    ImageURL = new NSUrl(url)};
                content.SetContentUrl(new NSUrl("http://my-url.com"));

                myShareDialog.SetShareContent(content);
                myShareDialog.SetDelegate(new MyShareDelegate());

                myShareDialog.Show();

Localize()是我获取本地化字符串的扩展方法(我在Windows和Android中使用此代码,这个扩展为我提供了共享代码的舒适:))。 Board.Score是一个静态int,包含 - 是 - 得分。

MyShareDelegate:

public class MyShareDelegate : Facebook.ShareKit.ISharingDelegate
{
public IntPtr Handle { get; }

    public void DidComplete (Facebook.ShareKit.ISharing sharer, NSDictionary results)
    {
    }

    public void DidFail (Facebook.ShareKit.ISharing sharer, NSError error)
    {
    }

    public void DidCancel (Facebook.ShareKit.ISharing sharer)
    {
    }

    public void Dispose()
    {

    }
}

我有两个问题:

  1. 没有调用DidComplete / DidFail / DidCancel。

  2. 一切正常,分享正在时间轴上发布但是点击分享/取消后对话框没有关闭......

  3. 我做错了什么?

1 个答案:

答案 0 :(得分:0)

1)尝试将public void更改为public override void

2)您需要在收到通知后手动呼叫dismissModalViewControllerAnimated