public void ShareImageOnFacebook(string caption, string imagePath) { SharePhoto tt = SharePhoto.From(new UIImage(imagePath), true); tt.Caption = caption; SharePhotoContent content = new SharePhotoContent(); content.Photos = new SharePhoto[] { tt }; content.SetContentUrl(new NSUrl(imagePath)); var shareDelegate = new FbDelegate(); var dialog = new ShareDialog(); dialog.Mode = ShareDialogMode.FeedBrowser; dialog.SetDelegate(shareDelegate); dialog.SetShareContent(content); dialog.FromViewController = UIApplication.SharedApplication.KeyWindow.RootViewController; bool isInstalled = UIApplication.SharedApplication.CanOpenUrl(new NSUrl(urlString: "fb://")); if (isInstalled) { dialog.Mode = ShareDialogMode.Native; dialog.Show(); } else { ShareAPI.Share(content, shareDelegate); } }
public void ShareLinkOnFacebook(string text, string description, string link) { ShareLinkContent link1 = new ShareLinkContent(); link1.SetContentUrl(new NSUrl(link)); var shareDelegate = new FbDelegate(); var dialog = new ShareDialog(); dialog.Mode = ShareDialogMode.FeedBrowser; dialog.SetDelegate(shareDelegate); dialog.SetShareContent(link1); dialog.FromViewController = UIApplication.SharedApplication.KeyWindow.RootViewController; bool isInstalled = UIApplication.SharedApplication.CanOpenUrl(new NSUrl(urlString: "fb://")); if (isInstalled) { dialog.Mode = ShareDialogMode.Native; dialog.Show(); } else { ShareAPI.Share(link1, shareDelegate); } }
public void ShareTextOnFacebook(string text) { ShareLinkContent link = new ShareLinkContent(); var shareDelegate = new FbDelegate(); var dialog = new ShareDialog(); dialog.Mode = ShareDialogMode.Native; dialog.SetDelegate(shareDelegate); dialog.SetShareContent(link); dialog.FromViewController = UIApplication.SharedApplication.KeyWindow.RootViewController; bool isInstalled = UIApplication.SharedApplication.CanOpenUrl(new NSUrl(urlString: "fb://")); if (isInstalled) { dialog.Show(); } else { new UIAlertView("Error", "Cannot share text when app is not installed", null, "Ok", null).Show(); } }