private void FacebookPost(Account facebookAccount, string message, string clientID, string link) { var request = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me"), null, facebookAccount); request.GetResponseAsync().ContinueWith(t => { if (t.IsFaulted) { Console.WriteLine("Error: " + t.Exception.InnerException.Message); FacebookLoginPost(clientID, message, link); } else { // 1. Create the service var facebook = new FacebookService { ClientId = clientID }; facebook.SaveAccount(Forms.Context, facebookAccount); // 2. Create an item to share var item = new Item(); item.Text = message; if (link != null) { item.Links.Add(new Uri(link)); } Device.BeginInvokeOnMainThread(() => { // 3. Present the UI on iOS var shareIntent = facebook.GetShareUI((Activity)Forms.Context, item, result => { // result lets you know if the user shared the item or canceled }); Forms.Context.StartActivity(shareIntent); }); } }); }
// UIImage ImageWithView (UIView view){ // UIGraphics.BeginImageContextWithOptions (wordCloud.View.Bounds.Size, view.Opaque, 1.0f); // view.Layer.RenderInContext (UIGraphics.GetCurrentContext ()); // UIImage img = UIGraphics.GetImageFromCurrentImageContext (); // UIGraphics.EndImageContext (); // return img; // } void ShareOnFacebook () { // 1. Create the service var facebook = new FacebookService { ClientId = "662403690489016", RedirectUrl = new Uri ("https://apps.facebook.com/no_dctapps_indexer/") }; // 2. Create an item to share var item = new Item { Text = "This is my stuff from indexer as a wordcloud!" }; item.Links.Add (new Uri ("http://bit.ly/1hEfVgs")); item.Images = GetWordCloudAsImage (); // 3. Present the UI on iOS var shareController = facebook.GetShareUI (item, result => { // result lets you know if the user shared the item or canceled ancestor.NavigationController.DismissViewController(true,null); }); ancestor.NavigationController.PresentViewController (shareController, true, null); }
private void FacebookPost(Account facebookAccount, string message, string clientID, string link) { var request = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me?"), null, facebookAccount); request.GetResponseAsync().ContinueWith(t => { InvokeOnMainThread(() => { if (t.IsFaulted) { FacebookLoginPost(clientID, message, link); } else { // 1. Create the service var facebook = new FacebookService { ClientId = clientID, }; facebook.SaveAccount(facebookAccount); // 2. Create an item to share var item = new Item(); item.Text = message; if (!String.IsNullOrEmpty(link) ) { item.Links.Add(new Uri(link)); } // 3. Present the UI on iOS UIViewController cur_ViewController=(auth_ViewController==null?c_ViewController:auth_ViewController); var shareController = facebook.GetShareUI(item, result => { new UIAlertView ("Result",result.ToString(), null, "Ok").Show (); c_ViewController.DismissViewController(true,null); }); cur_ViewController.PresentViewController(shareController, true, null); } }); }); }
private void FacebookPost(Account facebookAccount, string message, string clientID, string link) { var request = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me"), null, facebookAccount); request.GetResponseAsync().ContinueWith(t => { if (t.IsFaulted) { Console.WriteLine("Error: " + t.Exception.InnerException.Message); FacebookLoginPost(clientID, message, link); } else { // 1. Create the service var facebook = new FacebookService { ClientId = clientID, }; facebook.SaveAccount(facebookAccount); // 2. Create an item to share var item = new Item(); item.Text = message; if (link != null) { item.Links.Add(new Uri(link)); } // 3. Present the UI on iOS InvokeOnMainThread(() => { var shareController = facebook.GetShareUI(item, result => { UIApplication.SharedApplication.KeyWindow.RootViewController.DismissViewController(true, null); }); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(shareController, true, null); }); } }); }