public void OnSessionStateChanged(FBSession session, FBSessionState state, NSError error)
        {
            // FBSample logic
            // Any time the session is closed, we want to display the login controller (the user
            // cannot use the application unless they are logged in to Facebook). When the session
            // is opened successfully, hide the login controller and show the main UI.
            switch (state)
            {

            case FBSessionState.Open:
                this.mainViewController.StartLocationManager();
                if (loginViewController != null)
                {
                    navController.TopViewController.DismissViewController(true, null);
                    loginViewController = null;
                }

                // FBSample logic
                // Pre-fetch and cache the friends for the friend picker as soon as possible to improve
                // responsiveness when the user tags their friends.
                FBCacheDescriptor cacheDescriptor = FBFriendPickerViewController.CacheDescriptor();
                cacheDescriptor.PrefetchAndCacheForSession(session);
                break;

            case FBSessionState.Closed:
                // FBSample logic
                // Once the user has logged out, we want them to be looking at the root view.
                // and to clear the user Token
                if (navController.TopViewController.ModalViewController != null)
                    navController.TopViewController.DismissViewController(false, null);

                navController.PopToRootViewController(false);
                FBSession.ActiveSession.CloseAndClearTokenInformation();
                ShowLoginView();
                break;

            case FBSessionState.ClosedLoginFailed:
                // if the token goes invalid we want to switch right back to
                // the login view, however we do it with a slight delay in order to
                // account for a race between this and the login view dissappearing
                // a moment before
                this.ShowLoginView();
                break;

            default:
                break;
            }

            NSNotificationCenter.DefaultCenter.PostNotificationName(SCSessionStateChangedNotification, session);

            if (error != null)
            {
                UIAlertView alertView = new UIAlertView("Error: " + ((FBErrorCode)error.Code).ToString(), error.LocalizedDescription, null, "Ok", null);
                alertView.Show();
            }
        }
		private void FacebookOpenActiveSessionCompleted(FBSession session, FBSessionState status, NSError error)
		{
			bool openOk = (error == null && (status == FBSessionState.Open || status == FBSessionState.OpenTokenExtended));

			if (openOk)
			{
				FBRequestConnection.GetMe(FacebookRequestForMeCompleted);
			}
			else if (error != null)
			{
				HandleFacebookError(error);
			}
		}