Facebook.AppDelegate.FinishedLaunching C# (CSharp) Method

FinishedLaunching() public method

public FinishedLaunching ( UIApplication app, NSDictionary options ) : bool
app UIApplication
options NSDictionary
return bool
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window = new UIWindow (UIScreen.MainScreen.Bounds);
            window.BackgroundColor = UIColor.White;

            table = new UITableViewController();

            NavController = new UINavigationController();

            // Add the [+] button
            statusButton = new UIBarButtonItem (UIBarButtonSystemItem.Add);
            statusButton.Clicked += delegate
            {
                usvc = new UpdateStatusViewController();
                NavController.PushViewController(usvc, true);
            };
            table.NavigationItem.SetRightBarButtonItem (statusButton, false);

            FacebookAuthorizationViewController fac =
                new FacebookAuthorizationViewController(
                      clientId
                    , new string[] {"read_stream", "publish_stream"} //, "user_groups"}
                    , FbDisplayType.Touch);

            fac.AccessToken +=
            delegate(string accessToken, DateTime expires)
            {
                token = accessToken;

                //Logged in, got your accessToken here and when it expires!
                NavController.PopViewControllerAnimated(true);

                //Do something else here (eg: Save the accessToken and expiry date to be used in your Graph API calls)
                Console.WriteLine("### Get json");
                System.Net.WebClient wc = new System.Net.WebClient();

                var b = wc.DownloadData(
                    new Uri("https://graph.facebook.com/me/home?access_token=" + token)
                );
                var s = Encoding.UTF8.GetString(b);

                //Console.WriteLine("### Output json");
                Console.WriteLine(s);

                // http://www.brettnagy.com/post/2009/11/21/Using-JsonNET-with-MonoTouch.aspx
                var posts = JsonConvert.DeserializeObject<Posts>( s );

            //				foreach(var p in posts.data)
            //				{
            //					Console.WriteLine("name: " + p.from.name);
            //				}

                table.Title = "Facebook";
                table.TableView.Source = new TableViewSource(posts);

            };

            NavController.PushViewController(table, false);
            NavController.PushViewController(fac, true);
            NavController.NavigationBar.TintColor = new UIColor(0.27f,0.52f,0.73f,1f);

            window.AddSubview(NavController.View);

            window.MakeKeyAndVisible ();
            return true;
        }