public DVCLogIn() : base(UITableViewStyle.Grouped, null, true) { loginView = new FBLoginView (ExtendedPermissions); if (UIDevice.CurrentDevice.CheckSystemVersion (7, 0)) { loginView.Frame = new RectangleF (51, 0, 218, 46); } else { loginView.Frame = new RectangleF (40, 0, 218, 46); } loginView.FetchedUserInfo += (sender, e) => { if (Root.Count < 3) { user = e.User; pictureView.ProfileID = user.Id; Root.Add (new Section ("Hello " + user.Name) { new StringElement ("Actions Menu", () => { var dvc = new DVCActions (user); NavigationController.PushViewController (dvc, true); }) { Alignment = UITextAlignment.Center } }); } }; loginView.ShowingLoggedOutUser += (sender, e) => { pictureView.ProfileID = null; if (Root.Count >= 3) { InvokeOnMainThread (() => { var section = Root [2]; section.Remove (0); Root.Remove (section); ReloadData (); }); } }; pictureView = new FBProfilePictureView () ; if (UIDevice.CurrentDevice.CheckSystemVersion (7,0)) { pictureView.Frame = new RectangleF (50, 0, 220, 220); } else { pictureView.Frame = new RectangleF (40, 0, 220, 220); } Root = new RootElement ("Facebook Sample") { new Section () { new UIViewElement ("", loginView, true) { Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent, } }, new Section () { new UIViewElement ("", pictureView, true) { Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent, }, } }; }
public DVCLogIn() : base(UITableViewStyle.Grouped, null, true) { loginView = new FBLoginView(ExtendedPermissions) { Frame = new RectangleF(74, 0, 151, 43) }; loginView.FetchedUserInfo += (sender, e) => { if (Root.Count < 3) { user = e.User; pictureView.ProfileID = user.Id; Root.Add(new Section("Hello " + user.Name) { new StringElement("Actions Menu", () => { var dvc = new DVCActions(user); NavigationController.PushViewController(dvc, true); }) { Alignment = UITextAlignment.Center } }); } }; loginView.ShowingLoggedOutUser += (sender, e) => { pictureView.ProfileID = null; if (Root.Count >= 3) { InvokeOnMainThread(() => { var section = Root[2]; section.Remove(0); Root.Remove(section); ReloadData(); }); } }; pictureView = new FBProfilePictureView() { Frame = new RectangleF(40, 0, 220, 220) }; Root = new RootElement("Facebook Sample") { new Section() { new UIViewElement("", loginView, true) { Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent, } }, new Section() { new UIViewElement("", pictureView, true) { Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent, }, } }; }
private void InitializeView() { // Create the Facebook LogIn View with the needed Permissions // https://developers.facebook.com/ios/login-ui-control/ var loginView = new FBLoginView() { Frame = new RectangleF(85, 0, 151, 43) }; // Hook up to FetchedUserInfo event, so you know when // you have the user information available bool didFetchUserInfo = false; loginView.FetchedUserInfo += (sender, e) => { if (didFetchUserInfo) { return; } didFetchUserInfo = true; Console.WriteLine("User is logged in ID=" + e.User.GetId() + ", User name is " + e.User.GetName()); FacebookClient fb = new FacebookClient(FBSession.ActiveSession.AccessTokenData.AccessToken); fb.AppId = PopPicConstants.AppId; fb.AppSecret = PopPicConstants.AppSecret; BuddyClient buddyClient = new BuddyClient(PopPicConstants.BuddyAppName, PopPicConstants.BuddyAppKey); buddyClient.SocialLoginAsync("Facebook", e.User.GetId(), FBSession.ActiveSession.AccessTokenData.AccessToken).ContinueWith(result => { var authenticatedUser = result.Result; var repository = new GameRepository(authenticatedUser, buddyClient, fb); AppDelegate.Repository = repository; InvokeOnMainThread(() => { if (this.ReturnAfterLoading) { this.NavigationController.PopViewControllerAnimated(true); } if (this.RepositoryLoaded != null) { this.RepositoryLoaded(this, repository); } }); }); }; // Clean user Picture and label when Logged Out loginView.ShowingLoggedOutUser += (sender, e) => { }; Root = new RootElement("Log In") { new Section("Please Sign In") { new UIViewElement("", loginView, false) { Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent, } } }; }
public override void LoginViewShowingLoggedInUser(FBLoginView loginView) { Console.WriteLine("LoginViewShowingLoggedInUser"); // first get the buttons set for login mode parentViewController.buttonPostPhoto.Enabled = true; parentViewController.buttonPostStatus.Enabled = true; parentViewController.buttonPickFriends.Enabled = true; parentViewController.buttonPickPlace.Enabled = true; }
public override void LoginViewShowingLoggedOutUser(FBLoginView loginView) { Console.WriteLine("LoginViewShowingLoggedOutUser"); parentViewController.buttonPostPhoto.Enabled = false; parentViewController.buttonPostStatus.Enabled = false; parentViewController.buttonPickFriends.Enabled = false; parentViewController.buttonPickPlace.Enabled = false; parentViewController.profilePic.ProfileID = String.Empty; parentViewController.labelFirstName.Text = String.Empty; }
public override void LoginViewFetchedUserInfo(FBLoginView loginView, FBGraphUser user) { Console.WriteLine("LoginViewFetchedUserInfo"); // here we use helper properties of FBGraphUser to dot-through to first_name and // id properties of the json response from the server; alternatively we could use // NSDictionary methods such as objectForKey to get values from the my json object parentViewController.labelFirstName.Text = String.Format(@"Hello {0}!", user.ObjectForKey(new NSString(@"first_name")).ToString()); // setting the profileID property of the FBProfilePictureView instance // causes the control to fetch and display the profile picture for the user parentViewController.profilePic.ProfileID = user.ObjectForKey(new NSString(@"id")).ToString(); parentViewController.loggedInUser = user; }
public override void ViewDidLoad() { base.ViewDidLoad(); // Create Login View so that the app will be granted "status_update" permission. FBLoginView loginview = new FBLoginView(NSArray.FromNSObjects(new NSString(@"publish_actions"))); loginview.Frame = new RectangleF(5, 5, loginview.Frame.Width, loginview.Frame.Height); loginview.Delegate = new HelloFBLoginViewDelegate(this); View.AddSubview(loginview); loginview.SizeToFit(); // Perform any additional setup after loading the view, typically from a nib. }
//float x=22,float y=120,float width=130,float height = 200 public FBLoginView CreateFaceBookBtn(float x = 18, float y = 135, float width = 135, float height = 400) { var btn = new FBLoginView(ExtendedPermissions) { Frame = new RectangleF(x, y, width, height) }; btn.FetchedUserInfo += (sender, e) => { var user = e.User; //var id = user.GetId (); //this.txtUser.Text = user.GetName (); this.isFaceBookLogin = true; this.LoggedInServiceType = LoginType.FaceBook; this.AccessToken = FBSession.ActiveSession.AccessTokenData.AccessToken; }; return(btn); }
public override void ViewDidLoad () { base.ViewDidLoad (); this.Add (faceBookView); this.Add (facebookView2); iPhoneLocationManager = new CLLocationManager (); iPhoneLocationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters; iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => { }; iPhoneLocationManager.RequestAlwaysAuthorization (); if (CLLocationManager.LocationServicesEnabled) { iPhoneLocationManager.StartUpdatingLocation (); } #region observadores del teclado // Keyboard popup NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.DidShowNotification,KeyBoardUpNotification); // Keyboard Down NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.WillHideNotification,KeyBoardDownNotification); #endregion #region declaracion de vista de Facebook // Create the Facebook LogIn View with the needed Permissions // https://developers.facebook.com/ios/login-ui-control/ loginView = new FBLoginView (ExtendedPermissions) { Frame = new CGRect (0,0,45, 45) }; // Create view that will display user's profile picture // https://developers.facebook.com/ios/profilepicture-ui-control/ pictureView = new FBProfilePictureView () { Frame = new CGRect (0, 0, 45, 45) }; pictureView.UserInteractionEnabled = true; // Hook up to FetchedUserInfo event, so you know when // you have the user information available loginView.FetchedUserInfo += (sender, e) => { user = e.User; pictureView.ProfileID = user.GetId (); MainView.isWithFacebook = true; loginView.Alpha = 0.1f; pictureView.Hidden = false; }; // Clean user Picture and label when Logged Out loginView.ShowingLoggedOutUser += (sender, e) => { pictureView.ProfileID = null; pictureView.Hidden = true; lblUserName.Text = string.Empty; loginView.Alpha = 1f; MainView.isWithFacebook = false; }; this.faceBookView.Add(pictureView); this.faceBookView.Add(loginView); #endregion var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal); _pathToDatabase = Path.Combine(documents, "db_sqlite-net.db"); //Creamos la base de datos y la tabla de persona using (var conn= new SQLite.SQLiteConnection(_pathToDatabase)) { conn.CreateTable<Person>(); conn.CreateTable<State> (); conn.CreateTable<Terms> (); conn.CreateTable<PrivacyNotice> (); } using (var db = new SQLite.SQLiteConnection(_pathToDatabase )) { people = new List<Person> (from p in db.Table<Person> () select p); states = new List<State> (from s in db.Table<State> () select s); terms = new List<Terms> (from t in db.Table<Terms> ()select t); privacyNotices = new List<PrivacyNotice> (from pr in db.Table<PrivacyNotice> () select pr); } if(people.Count > 0){ Person user = people.ElementAt(0); MainView.userId = user.ID; Console.WriteLine ("El Id de usuario es: "+ user.ID); } if(states.Count > 0){ State estado = states.ElementAt(0); MainView.localityId = estado.localityId; Console.WriteLine ("El Id de localidad es: "+ estado.stateId); } //Boton para entrar al menu de la aplicacion. this.btnEntrar.TouchUpInside += (sender, e) => { scanView = new ScanView(); this.NavigationController.PushViewController(scanView, true); }; this.btnListas.TouchUpInside += (sender, e) => { using (var db = new SQLite.SQLiteConnection(_pathToDatabase )) { people = new List<Person> (from p in db.Table<Person> () select p); } if(people.Count > 0){ MyListsView mylists = new MyListsView(); this.NavigationController.PushViewController(mylists,true); }else{ UIAlertView alert = new UIAlertView () { Title = "Espera!", Message = "Debes iniciar sesion para acceder a tus listas" }; alert.AddButton ("Aceptar"); alert.Show (); } }; //Boton para hacer busqueda por nombre de producto this.btnBuscar.TouchUpInside += (sender, e) => { if(this.cmpNombre.Text == ""){ UIAlertView alert = new UIAlertView () { Title = "Espera!", Message = "Debes ingresar el nombre del producto a buscar" }; alert.AddButton ("Aceptar"); alert.Show (); } else if (states.Count < 1){ UIAlertView alert = new UIAlertView () { Title = "Espera!", Message = "Debes seleccionar tu ubicacion antes de comenzar a usar FixBuy, por favor ingresa " + "Al menu de opciones para establecerla" }; alert.AddButton ("Aceptar"); alert.Clicked += (s, o) => { StatesView statesView = new StatesView(); this.NavigationController.PushViewController(statesView, true); }; alert.Show (); } else{ this._loadPop = new LoadingOverlay (UIScreen.MainScreen.Bounds); this.View.Add ( this._loadPop ); this.cmpNombre.ResignFirstResponder(); Task.Factory.StartNew ( () => { System.Threading.Thread.Sleep ( 1 * 1000 ); } ).ContinueWith ( t => { nsr = new NameSearchResultView(); nsr.setProductName(this.cmpNombre.Text.Trim()); this.NavigationController.PushViewController(nsr,true); this._loadPop.Hide (); }, TaskScheduler.FromCurrentSynchronizationContext() ); } }; this.cmpNombre.ShouldReturn += (textField) => { if(this.cmpNombre.Text == ""){ UIAlertView alert = new UIAlertView () { Title = "Espera!", Message = "Debes ingresar el nombre del producto a buscar" }; alert.AddButton ("Aceptar"); alert.Show (); } else if (states.Count < 1){ UIAlertView alert = new UIAlertView () { Title = "Espera!", Message = "Debes seleccionar tu ubicacion antes de comenzar a usar FixBuy, por favor ingresa " + "Al menu de opciones para establecerla" }; alert.AddButton ("Aceptar"); alert.Clicked += (s, o) => { StatesView statesView = new StatesView(); this.NavigationController.PushViewController(statesView, true); }; alert.Show (); } else{ this._loadPop = new LoadingOverlay (UIScreen.MainScreen.Bounds); this.View.Add ( this._loadPop ); this.cmpNombre.ResignFirstResponder(); Task.Factory.StartNew ( () => { System.Threading.Thread.Sleep ( 1 * 1000 ); } ).ContinueWith ( t => { nsr = new NameSearchResultView(); nsr.setProductName(this.cmpNombre.Text.Trim()); this.NavigationController.PushViewController(nsr,true); this._loadPop.Hide (); }, TaskScheduler.FromCurrentSynchronizationContext() ); } return true; }; //Boton para iniciar el escaner de codigo de barras this.btnCodigo.TouchUpInside += (sender, e) => { if(states.Count > 0){ // Configurar el escaner de codigo de barras. picker = new ScanditSDKRotatingBarcodePicker (appKey); picker.OverlayController.Delegate = new overlayControllerDelegate(picker, this); picker.OverlayController.ShowToolBar(true); picker.OverlayController.ShowSearchBar(true); picker.OverlayController.SetToolBarButtonCaption("Cancelar"); picker.OverlayController.SetSearchBarKeyboardType(UIKeyboardType.Default); picker.OverlayController.SetSearchBarPlaceholderText("Búsqueda por nombre de producto"); picker.OverlayController.SetCameraSwitchVisibility(SICameraSwitchVisibility.OnTablet); picker.OverlayController.SetTextForInitializingCamera("Iniciando la camara"); this.PresentViewController (picker, true, null); picker.StartScanning (); }else{ UIAlertView alert = new UIAlertView () { Title = "Espera!", Message = "Debes seleccionar tu ubicacion antes de comenzar a usar FixBuy, por favor ingresa " + "Al menu de opciones para establecerla" }; alert.AddButton ("Aceptar"); alert.Clicked += (s, o) => { StatesView statesView = new StatesView(); this.NavigationController.PushViewController(statesView, true); }; alert.Show (); } }; }
public override void ViewDidLoad() { base.ViewDidLoad(); this.Add(faceBookView); this.Add(facebookView2); iPhoneLocationManager = new CLLocationManager(); iPhoneLocationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters; iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => { }; iPhoneLocationManager.RequestAlwaysAuthorization(); if (CLLocationManager.LocationServicesEnabled) { iPhoneLocationManager.StartUpdatingLocation(); } #region observadores del teclado // Keyboard popup NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.DidShowNotification, KeyBoardUpNotification); // Keyboard Down NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.WillHideNotification, KeyBoardDownNotification); #endregion #region declaracion de vista de Facebook // Create the Facebook LogIn View with the needed Permissions // https://developers.facebook.com/ios/login-ui-control/ loginView = new FBLoginView(ExtendedPermissions) { Frame = new CGRect(0, 0, 45, 45) }; // Create view that will display user's profile picture // https://developers.facebook.com/ios/profilepicture-ui-control/ pictureView = new FBProfilePictureView() { Frame = new CGRect(0, 0, 45, 45) }; pictureView.UserInteractionEnabled = true; // Hook up to FetchedUserInfo event, so you know when // you have the user information available loginView.FetchedUserInfo += (sender, e) => { user = e.User; pictureView.ProfileID = user.GetId(); MainView.isWithFacebook = true; loginView.Alpha = 0.1f; pictureView.Hidden = false; }; // Clean user Picture and label when Logged Out loginView.ShowingLoggedOutUser += (sender, e) => { pictureView.ProfileID = null; pictureView.Hidden = true; lblUserName.Text = string.Empty; loginView.Alpha = 1f; MainView.isWithFacebook = false; }; this.faceBookView.Add(pictureView); this.faceBookView.Add(loginView); #endregion var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal); _pathToDatabase = Path.Combine(documents, "db_sqlite-net.db"); //Creamos la base de datos y la tabla de persona using (var conn = new SQLite.SQLiteConnection(_pathToDatabase)) { conn.CreateTable <Person>(); conn.CreateTable <State> (); conn.CreateTable <Terms> (); conn.CreateTable <PrivacyNotice> (); } using (var db = new SQLite.SQLiteConnection(_pathToDatabase)) { people = new List <Person> (from p in db.Table <Person> () select p); states = new List <State> (from s in db.Table <State> () select s); terms = new List <Terms> (from t in db.Table <Terms> () select t); privacyNotices = new List <PrivacyNotice> (from pr in db.Table <PrivacyNotice> () select pr); } if (people.Count > 0) { Person user = people.ElementAt(0); MainView.userId = user.ID; Console.WriteLine("El Id de usuario es: " + user.ID); } if (states.Count > 0) { State estado = states.ElementAt(0); MainView.localityId = estado.localityId; Console.WriteLine("El Id de localidad es: " + estado.stateId); } //Boton para entrar al menu de la aplicacion. this.btnEntrar.TouchUpInside += (sender, e) => { scanView = new ScanView(); this.NavigationController.PushViewController(scanView, true); }; this.btnListas.TouchUpInside += (sender, e) => { using (var db = new SQLite.SQLiteConnection(_pathToDatabase)) { people = new List <Person> (from p in db.Table <Person> () select p); } if (people.Count > 0) { MyListsView mylists = new MyListsView(); this.NavigationController.PushViewController(mylists, true); } else { UIAlertView alert = new UIAlertView() { Title = "Espera!", Message = "Debes iniciar sesion para acceder a tus listas" }; alert.AddButton("Aceptar"); alert.Show(); } }; //Boton para hacer busqueda por nombre de producto this.btnBuscar.TouchUpInside += (sender, e) => { if (this.cmpNombre.Text == "") { UIAlertView alert = new UIAlertView() { Title = "Espera!", Message = "Debes ingresar el nombre del producto a buscar" }; alert.AddButton("Aceptar"); alert.Show(); } else if (states.Count < 1) { UIAlertView alert = new UIAlertView() { Title = "Espera!", Message = "Debes seleccionar tu ubicacion antes de comenzar a usar FixBuy, por favor ingresa " + "Al menu de opciones para establecerla" }; alert.AddButton("Aceptar"); alert.Clicked += (s, o) => { StatesView statesView = new StatesView(); this.NavigationController.PushViewController(statesView, true); }; alert.Show(); } else { this._loadPop = new LoadingOverlay(UIScreen.MainScreen.Bounds); this.View.Add(this._loadPop); this.cmpNombre.ResignFirstResponder(); Task.Factory.StartNew( () => { System.Threading.Thread.Sleep(1 * 1000); } ).ContinueWith( t => { nsr = new NameSearchResultView(); nsr.setProductName(this.cmpNombre.Text.Trim()); this.NavigationController.PushViewController(nsr, true); this._loadPop.Hide(); }, TaskScheduler.FromCurrentSynchronizationContext() ); } }; this.cmpNombre.ShouldReturn += (textField) => { if (this.cmpNombre.Text == "") { UIAlertView alert = new UIAlertView() { Title = "Espera!", Message = "Debes ingresar el nombre del producto a buscar" }; alert.AddButton("Aceptar"); alert.Show(); } else if (states.Count < 1) { UIAlertView alert = new UIAlertView() { Title = "Espera!", Message = "Debes seleccionar tu ubicacion antes de comenzar a usar FixBuy, por favor ingresa " + "Al menu de opciones para establecerla" }; alert.AddButton("Aceptar"); alert.Clicked += (s, o) => { StatesView statesView = new StatesView(); this.NavigationController.PushViewController(statesView, true); }; alert.Show(); } else { this._loadPop = new LoadingOverlay(UIScreen.MainScreen.Bounds); this.View.Add(this._loadPop); this.cmpNombre.ResignFirstResponder(); Task.Factory.StartNew( () => { System.Threading.Thread.Sleep(1 * 1000); } ).ContinueWith( t => { nsr = new NameSearchResultView(); nsr.setProductName(this.cmpNombre.Text.Trim()); this.NavigationController.PushViewController(nsr, true); this._loadPop.Hide(); }, TaskScheduler.FromCurrentSynchronizationContext() ); } return(true); }; //Boton para iniciar el escaner de codigo de barras this.btnCodigo.TouchUpInside += (sender, e) => { if (states.Count > 0) { // Configurar el escaner de codigo de barras. picker = new ScanditSDKRotatingBarcodePicker(appKey); picker.OverlayController.Delegate = new overlayControllerDelegate(picker, this); picker.OverlayController.ShowToolBar(true); picker.OverlayController.ShowSearchBar(true); picker.OverlayController.SetToolBarButtonCaption("Cancelar"); picker.OverlayController.SetSearchBarKeyboardType(UIKeyboardType.Default); picker.OverlayController.SetSearchBarPlaceholderText("Búsqueda por nombre de producto"); picker.OverlayController.SetCameraSwitchVisibility(SICameraSwitchVisibility.OnTablet); picker.OverlayController.SetTextForInitializingCamera("Iniciando la camara"); this.PresentViewController(picker, true, null); picker.StartScanning(); } else { UIAlertView alert = new UIAlertView() { Title = "Espera!", Message = "Debes seleccionar tu ubicacion antes de comenzar a usar FixBuy, por favor ingresa " + "Al menu de opciones para establecerla" }; alert.AddButton("Aceptar"); alert.Clicked += (s, o) => { StatesView statesView = new StatesView(); this.NavigationController.PushViewController(statesView, true); }; alert.Show(); } }; }
public override void ViewWillAppear(bool animated) { this.Email.Background = UIImage.FromFile ("./Assets/input.png"); this.Password.Background = UIImage.FromFile ("./Assets/input.png"); this.Login.SetBackgroundImage (UIImage.FromFile ("./Assets/buttonlong.png"), UIControlState.Normal); this.Email.LeftView = new UIView (new RectangleF (0, 0, 5, 30)); this.Email.LeftViewMode = UITextFieldViewMode.Always; this.Password.LeftView = new UIView (new RectangleF (0, 0, 5, 30)); this.Password.LeftViewMode = UITextFieldViewMode.Always; var button = new UIBarButtonItem ("Back", UIBarButtonItemStyle.Plain, null); var custom = new UIButton (new RectangleF (0, 0, 26, 15)); custom.SetBackgroundImage(UIImage.FromFile("./Assets/back.png"), UIControlState.Normal); custom.TouchUpInside += (sender, e) => NavigationController.PopViewControllerAnimated (true); button.CustomView = custom; this.NavigationItem.LeftBarButtonItem = button; this.NavigationController.SetNavigationBarHidden (false, false); // FACEBOOK LOGIN fbLogin = new FBLoginView (AppDelegate.Permissions); FacebookView.AddSubview (fbLogin); fbLogin.SizeToFit (); fbLogin.FetchedUserInfo += (object sender, FBLoginViewUserInfoEventArgs e) => { if (FBSession.ActiveSession.IsOpen) { var model = new FacebookProfile { Id = long.Parse (e.User.Id), Name = e.User.Name, first_name = e.User.FirstName, last_name = e.User.LastName, Birthday = e.User.Birthday, Email = e.User.ObjectForKey ("email").ToString (), UserName = e.User.Username }; var request = new RestRequest (); request.RequestFinished += (object sendr, RequestEndedArgs ev) => { var jsonId = (int)JsonConvert.DeserializeObject (ev.Result, typeof(int)); InvokeOnMainThread (delegate { AppDelegate.SaveProfileId(jsonId); var tabbar = new MainTabController(); UIApplication.SharedApplication.Delegate.Window.RootViewController = tabbar; }); }; request.Send (RequestConfig.Facebook, "POST", model); } }; fbLogin.ShowingLoggedOutUser += (object sender, EventArgs e) => { Console.WriteLine(e.ToString()); }; fbLogin.ShowingLoggedInUser += (object sender, EventArgs e) => { Console.WriteLine("Logged in."); }; // GOOGLE LOGIN var signIn = SignIn.SharedInstance; signIn.ClientId = AppDelegate.GoogleClientId; signIn.Scopes = new [] { PlusConstants.AuthScopePlusLogin, PlusConstants.AuthScopePlusMe, "https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email" }; signIn.ShouldFetchGoogleUserEmail = true; signIn.ShouldFetchGoogleUserId = true; signIn.Finished += (object sender, SignInDelegateFinishedEventArgs e) => { if(e.Error != null) { InvokeOnMainThread(delegate { new UIAlertView("Error.", "Could not sign in.", null, "Ok", null).Show(); }); } else { var request = new RestRequest(); request.RequestFinished += (object sendr, RequestEndedArgs ev) => { var data = (GoogleClient)JsonConvert.DeserializeObject(ev.Result, typeof(GoogleClient)); var request2 = new RestRequest(); request2.RequestFinished += (object sndr, RequestEndedArgs evnt) => { var jsonId = (int)JsonConvert.DeserializeObject (evnt.Result, typeof(int)); InvokeOnMainThread (delegate { AppDelegate.SaveProfileId(jsonId); var tabbar = new MainTabController(); UIApplication.SharedApplication.Delegate.Window.RootViewController = tabbar; }); }; request2.Send(RequestConfig.Google, "POST", data); }; request.Send(String.Format(RequestConfig.GoogleFetch, Uri.EscapeDataString(signIn.Authentication.AccessToken)), "GET"); } }; var signInButton = new SignInButton (); GoogleView.AddSubview (signInButton); signInButton.Frame = new RectangleF (0, 0, GoogleView.Frame.Size.Width - 8, GoogleView.Frame.Size.Height); signInButton.SizeToFit (); }