示例#1
0
        void DeleteHiPost()
        {
            if (!isHiPosted)
            {
                new UIAlertView("Error", "Please Post \"Hello\" to your wall first", null, "Ok", null).Show();
                return;
            }

            FBRequestConnection.StartWithGraphPath(helloId, null, "DELETE", (connection, result, err) => {
                if (err != null)
                {
                    // Temporal validation until enums can inherit from new unified types (nint, nuint).
                    FBErrorCode errorCode;
                    if (IntPtr.Size == 8)
                    {
                        errorCode = (FBErrorCode)(ulong)err.Code;
                    }
                    else
                    {
                        errorCode = (FBErrorCode)(uint)err.Code;
                    }

                    InvokeOnMainThread(() => new UIAlertView("Error", string.Format("Error:\nDomain: {0}\nCode: {1}\nDescription: {2}", err.Domain, errorCode, err.Description), null, "Ok", null).Show());
                }
                else
                {
                    isHiPosted = false;
                    helloId    = null;
                    InvokeOnMainThread(() => new UIAlertView("Success", "Deleted Hello from your wall", null, "Ok", null).Show());
                }
            });
        }
示例#2
0
    private void ConnectionReturn(FBRequestConnection connection, NSObject result, NSError error)
    {
        var me = (FBGraphObject)result;

        Console.WriteLine("this is a test");
        emailTask.SetResult(me["email"].ToString());
    }
示例#3
0
        void GraphApiPost()
        {
            if (IsHiPosted)
            {
                InvokeOnMainThread(() => new UIAlertView("Error", "Hello already posted on your wall", null, "Ok", null).Show());
                return;
            }

            var data = new NSMutableDictionary();

            data.Add(new NSString("message"), new NSString("Hello!"));

            // Ask for publish_actions permissions in context
            if (!FBSession.ActiveSession.Permissions.Contains("publish_actions"))
            {
                // No permissions found in session, ask for it
                FBSession.ActiveSession.RequestNewPublishPermissions(new [] { "publish_actions" }, FBSessionDefaultAudience.Friends, (session, error) => {
                    if (error != null)
                    {
                        InvokeOnMainThread(() => new UIAlertView("Error", error.Description, null, "Ok", null).Show());
                    }
                    else
                    {
                        // If permissions granted, publish the story
                        FBRequestConnection.StartWithGraphPath("me/feed", data, "POST", (connection, result, err) => {
                            if (err != null)
                            {
                                InvokeOnMainThread(() => new UIAlertView("Error", string.Format("Error:\nDomain: {0}\nCode: {1}\nDescription: {3}", err.Domain, (FBErrorCode)err.Code, err.Description), null, "Ok", null).Show());
                            }
                            else
                            {
                                HelloId = (result as FBGraphObject)["id"] as NSString;
                                InvokeOnMainThread(() => new UIAlertView("Success", "Posted Hello, MsgId: " + HelloId, null, "Ok", null).Show());
                                IsHiPosted = true;
                            }
                        });
                    }
                });
            }
            else
            {
                // If permissions is found, publish the story
                FBRequestConnection.StartWithGraphPath("me/feed", data, "POST", (connection, result, err) => {
                    if (err != null)
                    {
                        InvokeOnMainThread(() => new UIAlertView("Error", string.Format("Error:\nDomain: {0}\nCode: {1}\nDescription: {3}", err.Domain, (FBErrorCode)err.Code, err.Description), null, "Ok", null).Show());
                    }
                    else
                    {
                        HelloId = (result as FBGraphObject)["id"] as NSString;
                        InvokeOnMainThread(() => new UIAlertView("Success", "Posted Hello in your wall, MsgId: " + HelloId, null, "Ok", null).Show());
                        IsHiPosted = true;
                    }
                });
            }
        }
示例#4
0
        void GraphApiDeletePost()
        {
            if (!IsHiPosted)
            {
                new UIAlertView("Error", "Please Post \"Hello\" to your wall first", null, "Ok", null).Show();
                return;
            }

            FBRequestConnection.StartWithGraphPath(HelloId, null, "DELETE", (connection, result, err) => {
                if (err != null)
                {
                    InvokeOnMainThread(() => new UIAlertView("Error", string.Format("Error:\nDomain: {0}\nCode: {1}\nDescription: {2}", err.Domain, (FBErrorCode)err.Code, err.Description), null, "Ok", null).Show());
                }
                else
                {
                    HelloId = null;
                    InvokeOnMainThread(() => new UIAlertView("Success", "Deleted Hello from your wall", null, "Ok", null).Show());
                    IsHiPosted = false;
                }
            });
        }
示例#5
0
        void FQLSample()
        {
            // Query to fetch the active user's friends, limit to 25.
            string query = "SELECT uid, name, pic_big FROM user WHERE uid IN " +
                           "(SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 25)";
            // Set up the query parameter
            var queryParam = NSDictionary.FromObjectAndKey(new NSString(query), new NSString("q"));

            // Make the API request that uses FQL
            FBRequestConnection.StartWithGraphPath("/fql", queryParam, "GET", (connection, result, error) => {
                if (error != null)
                {
                    InvokeOnMainThread(() => new UIAlertView("Error", error.Description, null, "Ok", null).Show());
                }
                else
                {
                    // Here we use an utility method to extract all FBGraphObjects that came from the result
                    var users = FBGraphObject.FromResultObject(result);

                    // We create a RootElement that will hold the list
                    // of people that returned in the result
                    var root = new RootElement("25 Friends")
                    {
                        new Section()
                    };

                    foreach (var usr in users)
                    {
                        root[0].Add(new HtmlElement(usr["name"] as NSString, new NSUrl(usr["pic_big"] as NSString)));
                    }

                    // We create the Dialog View Controller that will display the results and push it.
                    var friendsDialog = new DialogViewController(root, true);
                    NavigationController.PushViewController(friendsDialog, true);
                }
            });
        }
示例#6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            try{
                UIBarButtonItem home = new UIBarButtonItem();
                home.Style  = UIBarButtonItemStyle.Plain;
                home.Target = this;
                home.Image  = UIImage.FromFile("Images/home.png");
                this.NavigationItem.RightBarButtonItem = home;
                UIViewController[] vistas = NavigationController.ViewControllers;
                home.Clicked += (sender, e) => {
                    this.NavigationController.PopToViewController(vistas[0], true);
                };

                //Configuramos la vista popup de nueva lista
                NewListView.Layer.BorderWidth  = 1.0f;
                NewListView.Layer.BorderColor  = UIColor.Black.CGColor;
                NewListView.Layer.CornerRadius = 8;
                tblLists.Add(this.NewListView);
                NewListView.Hidden = true;
                //Configuramos la vista popup de cantidad
                QuantityView.Layer.BorderWidth  = 1.0f;
                QuantityView.Layer.BorderColor  = UIColor.Black.CGColor;
                QuantityView.Layer.CornerRadius = 8;
                this.Add(QuantityView);
                QuantityView.Hidden = true;

                //Configuramos la vista de popup de listas
                ListsView.Layer.BorderWidth  = 1.0f;
                ListsView.Layer.BorderColor  = UIColor.Black.CGColor;
                ListsView.Layer.CornerRadius = 8;
                this.Add(this.ListsView);
                ListsView.Hidden = true;

                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
                {
                    this.btnMapa.SetBackgroundImage(Images.mapa, UIControlState.Normal);
                }
                else
                {
                    this.btnMapa.SetBackgroundImage(Images.mapa, UIControlState.Normal);
                }

                this.btnMapa.TouchUpInside += (sender, e) => {
                    SecondMapViewController mapView = new SecondMapViewController();
                    mapView.setTienda(this.producto);
                    NavigationController.PushViewController(mapView, true);
                };

                var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                _pathToDatabase = Path.Combine(documents, "db_sqlite-net.db");

                //Hacemos la conexion a la bd para buscar si hay un usuario registrado
                using (var db = new SQLite.SQLiteConnection(_pathToDatabase))
                {
                    people = new List <Person> (from p in db.Table <Person> () select p);
                }

                NSUrl nsUrl = new NSUrl(producto.imagen);
                data = NSData.FromUrl(nsUrl);
                if (data != null)
                {
                    Images.imagenDetalle   = UIImage.LoadFromData(data);
                    this.imgProducto.Image = Images.imagenDetalle;
                }
                else
                {
                    this.imgProducto.Image = Images.sinImagen;
                }

                //Establecemos la informacion del producto
                this.lblNombre.Text = producto.nombre;
                double precio = Double.Parse(producto.precio);
                this.lblPrecio.Text      = precio.ToString("C2");
                this.lblDescripcion.Text = producto.descripcion;
                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
                {
                    this.lblDescripcion.Font = UIFont.SystemFontOfSize(10);
                }
                else
                {
                    this.lblDescripcion.Font = UIFont.SystemFontOfSize(25);
                }
                //Establecemos la informacion de la tienda
                NSUrl  nsurl = new NSUrl(producto.tienda_imagen);
                NSData data1 = NSData.FromUrl(nsurl);
                if (data1 != null)
                {
                    Images.imagenDetalleTienda = UIImage.LoadFromData(data1);
                    this.imgTienda.Image       = Images.imagenDetalleTienda;
                }
                else
                {
                    this.imgTienda.Image = Images.sinImagen;
                }
                this.lblTiendaNombre.Text    = producto.tienda_nombre;
                this.lblTiendaDireccion.Text = producto.tienda_direccion + "\n \nTeléfono: " + producto.tienda_telefono;
                if (distancia != 0)
                {
                    this.lblTiendaDistancia.Text = "A " + Math.Round(distancia, 2) + "km de tu ubicación";
                }
                else
                {
                    this.lblTiendaDistancia.Text = "Distancia no disponible";
                }
                this.lblVigencia.Text = "Vigencia del " + producto.inicio_validez + " Al " + producto.final_validez;

                this.btnLista.TouchUpInside += (sender, e) => {
                    if (people.Count > 0)
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Añadir a mi lista", Message = "¿Deseas añadir este producto a una de tus listas?"
                        };
                        alert.AddButton("Añadir");
                        alert.AddButton("Cancelar");
                        alert.Show();
                        alert.Clicked += (s, o) => {
                            if (o.ButtonIndex == 0)
                            {
                                QuantityView.Hidden = false;
                            }
                        };
                    }
                    else
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Espera!", Message = "Debes iniciar sesión para acceder a tus listas"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }
                };

                int cantidad = 1;
                this.cmpCantidad.Text = cantidad.ToString();
                btnMas.TouchUpInside += (sender, e) => {
                    cantidad++;
                    this.cmpCantidad.Text = cantidad.ToString();
                };

                btnMenos.TouchUpInside += (sender, e) => {
                    cantidad--;
                    if (cantidad < 1)
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Espera!", Message = "La cantidad minima es 1"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                        cantidad = 1;
                        this.cmpCantidad.Text = cantidad.ToString();
                    }
                    else
                    {
                        this.cmpCantidad.Text = cantidad.ToString();
                    }
                };

                this.btnAceptarCantidad.TouchUpInside += (sender, e) => {
                    try{
                        if (cmpCantidad.Text.Equals(""))
                        {
                            UIAlertView alert = new UIAlertView()
                            {
                                Title = "Espera!", Message = "Debes ingresar la cantidad"
                            };
                            alert.AddButton("Registrar");
                            alert.AddButton("Cancelar");
                            alert.Show();
                        }
                        else
                        {
                            cmpCantidad.ResignFirstResponder();
                            QuantityView.Hidden = true;
                            ls = new ListsService();
                            Person persona = people.ElementAt(0);
                            ls.setUserId(persona.ID.ToString());
                            List <ListsService> tableItems = ls.All();
                            if (tableItems.Count > 0)
                            {
                                this.tblLists.Source = new AddToListsTableSource(tableItems, this, this.producto, int.Parse(cmpCantidad.Text));
                                ListsView.Add(this.tblLists);
                                this.tblLists.ReloadData();
                                ListsView.Hidden = false;
                                cmpCantidad.Text = "";
                            }
                            else
                            {
                                UIAlertView alert = new UIAlertView()
                                {
                                    Title = "No tienes listas", Message = "No tienes listas registradas, porfavor ve a \"Mis listas\" para crear una nueva"
                                };
                                alert.AddButton("Registrar");
                                alert.AddButton("Cancelar");
                                alert.Show();
                            }
                        }
                    }catch (System.FormatException ex) {
                        Console.WriteLine(ex.ToString());
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Espera!", Message = "Debes ingresar solo números"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                        QuantityView.Hidden = false;
                    }catch (System.Net.WebException) {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Ups :S", Message = "Algo salio mal,no se pudieron cargar tus listas, verifica tu conexión a internet e inténtalo de nuevo"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }catch (System.Exception ext) {
                        Console.WriteLine(ext.ToString());
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Ups :S", Message = "Ocurrió un problema, inténtalo de nuevo"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }
                };

                btnCerrarLista.TouchUpInside += (sender, e) => {
                    ListsView.Hidden = true;
                };

                btnBadPrice.TouchUpInside += (sender, e) => {
                    if (MainView.userId != 0)
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Gracias por su reporte", Message = "Estamos revisando constantemente los precios de los productos y le agradecemos su aportación, ¿le gustaría reportar el precio de este producto para su revision?"
                        };
                        alert.AddButton("SI");
                        alert.AddButton("NO");
                        alert.Clicked += (s, o) => {
                            try{
                                if (o.ButtonIndex == 0)
                                {
                                    ReportService report    = new ReportService();
                                    String        respuesta = report.SetData(MainView.userId.ToString(), this.producto.id, this.producto.tienda_id, this.producto.precio);
                                    if (respuesta.Equals("\"correct\""))
                                    {
                                        UIAlertView alert2 = new UIAlertView()
                                        {
                                            Title = "Muchas gracias!", Message = "En FixBuy estamos comprometidos con ofrecer siempre la informacion correcta, muchas gracias por tu reporte =)"
                                        };
                                        alert2.AddButton("Aceptar");
                                        alert2.Show();
                                    }
                                    else
                                    {
                                        UIAlertView alert3 = new UIAlertView()
                                        {
                                            Title = "UPS :S", Message = "Algo salio mal, verifica tu conexión a internet e intentalo de nuevo"
                                        };
                                        alert3.AddButton("Aceptar");
                                        alert3.Show();
                                    }
                                }
                            }catch (System.Net.WebException) {
                                UIAlertView alerta = new UIAlertView()
                                {
                                    Title = "UPS :S", Message = "Algo salio mal, verifica tu conexión a internet e intentalo de nuevo"
                                };
                                alerta.AddButton("Aceptar");
                                alerta.Show();
                            }catch (Exception) {
                                UIAlertView alerta = new UIAlertView()
                                {
                                    Title = "UPS :S", Message = "Algo salio mal, por favor intentalo de nuevo"
                                };
                                alerta.AddButton("Aceptar");
                                alerta.Show();
                            }
                        };
                        alert.Show();
                    }
                    else
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Espera!", Message = "Debes iniciar sesión para poder reportar el precio incorrecto"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }
                };

                btnFacebook.TouchUpInside += (sender, e) => {
                    try{
                        if (MainView.isWithFacebook == true)
                        {
                            UIAlertView alert = new UIAlertView()
                            {
                                Title = "Quieres publicar este producto?", Message = "Deseas publicar este producto en tu perfil de Facebook?"
                            };
                            alert.AddButton("Aceptar");
                            alert.AddButton("Cancelar");
                            alert.Clicked += (s, o) => {
                                if (o.ButtonIndex == 0)
                                {
                                    var post = new NSMutableDictionary();
                                    if (data != null)
                                    {
                                        post.Add(new NSString("message"), new NSString(producto.imagen + "\t" + producto.nombre + "\t(" + producto.descripcion + ")" + "\nGracias a FixBuy encontre mi producto =D"));
                                    }
                                    else
                                    {
                                        post.Add(new NSString("message"), new NSString(producto.nombre + "\t(" + producto.descripcion + ")" + "\nGracias a FixBuy encontre mi producto =D "));
                                    }
                                    // Ask for publish_actions permissions in context
                                    if (!FBSession.ActiveSession.Permissions.Contains("publish_actions"))
                                    {
                                        // No permissions found in session, ask for it
                                        FBSession.ActiveSession.RequestNewPublishPermissions(new [] { "publish_actions" }, FBSessionDefaultAudience.Friends, (session, error) => {
                                            if (error != null)
                                            {
                                                InvokeOnMainThread(() => new UIAlertView("Ups =S", "Ocurrio un error intentalo de nuevo", null, "Aceptar", null).Show());
                                            }
                                            else
                                            {
                                                // If permissions granted, publish the story
                                                FBRequestConnection.StartWithGraphPath("me/feed", post, "POST", (connection, result, err) => {
                                                    if (err != null)
                                                    {
                                                        InvokeOnMainThread(() => new UIAlertView("Ups =S", "Ocurrio un error intentalo de nuevo", null, "Aceptar", null).Show());
                                                    }
                                                    else
                                                    {
                                                        HelloId = (result as FBGraphObject)["id"] as NSString;
                                                        InvokeOnMainThread(() => new UIAlertView("Producto publicado =)", "El producto que FixBuy te ayudo a encontrar a sido publicado en tu biografia =)", null, "Aceptar", null).Show());
                                                    }
                                                });
                                            }
                                        });
                                    }
                                    else
                                    {
                                        // If permissions is found, publish the story
                                        FBRequestConnection.StartWithGraphPath("me/feed", post, "POST", (connection, result, err) => {
                                            if (err != null)
                                            {
                                                InvokeOnMainThread(() => new UIAlertView("Ups =S", "Ocurrio un error intentalo de nuevo", null, "Ok", null).Show());
                                            }
                                            else
                                            {
                                                HelloId = (result as FBGraphObject)["id"] as NSString;
                                                InvokeOnMainThread(() => new UIAlertView("Producto publicado =)", "El producto que FixBuy te ayudo a encontrar a sido publicado en tu biografia =)", null, "Aceptar", null).Show());
                                            }
                                        });
                                    }
                                }
                            };
                            alert.Show();
                        }
                        else
                        {
                            InvokeOnMainThread(() => new UIAlertView("No has entrado a Facebook", "Debes iniciar sesion en Facebook para poder publicar tu producto, por favor regresa a la pantalla inicial para iniciar sesion en Facebook", null, "Aceptar", null).Show());
                        }
                    }catch (Exception exc) {
                        Console.WriteLine("UPS: " + exc.ToString());
                    }
                    //Console.WriteLine(HelloId.ToString());
                };

                btnNuevaLista.TouchUpInside += (sender, e) => {
                    this.NewListView.Hidden = false;
                };

                btnAceptarNuevaLista.TouchUpInside += (sender, e) => {
                    try{
                        if (cmpNewList.Text == "")
                        {
                            UIAlertView alert = new UIAlertView()
                            {
                                Title = "Espera!", Message = "Debes ingresar el nombre de la lista"
                            };
                            alert.AddButton("Aceptar");
                            alert.Show();
                        }
                        else
                        {
                            nls = new NewListService();
                            String respuesta = nls.SetListData(cmpNewList.Text, MainView.userId.ToString());
                            if (respuesta.Equals("\"lista ya existe\""))
                            {
                                UIAlertView alert = new UIAlertView()
                                {
                                    Title = "Ups :S", Message = "Ese nombre de lista ya se encuentra registrado"
                                };
                                alert.AddButton("Aceptar");
                                alert.Show();
                                //cmpNewList.Hidden = true;
                                cmpNewList.Text = "";
                                cmpNewList.ResignFirstResponder();
                            }
                            else
                            {
                                UIAlertView alert = new UIAlertView()
                                {
                                    Title = "Lista creada", Message = "Tu nueva lista \"" + cmpNewList.Text + "\" ha sido creada =D"
                                };
                                alert.AddButton("Aceptar");
                                alert.Show();
                                ls = new ListsService();
                                ls.setUserId(MainView.userId.ToString());
                                List <ListsService> items = ls.All();
                                this.tblLists.Source = new AddToListsTableSource(items, this, producto, 1);
                                this.tblLists.ReloadData();
                                cmpNewList.Text    = "";
                                NewListView.Hidden = true;
                                cmpNewList.ResignFirstResponder();
                            }
                        }
                    }catch (System.Net.WebException) {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Ups =S", Message = "Algo salio mal, verifica tu conexión a internet e intentalo de nuevo"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }catch (Exception exc) {
                        Console.WriteLine(exc.ToString());
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Ups =S", Message = "Algo salio mal, por favor intentalo de nuevo"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }
                };

                btnCerrarNombreNL.TouchUpInside += (sender, e) => {
                    this.NewListView.Hidden = true;
                    this.cmpNewList.ResignFirstResponder();
                };
            }catch (Exception e) {
                Console.WriteLine(e.ToString());
                UIAlertView alert = new UIAlertView()
                {
                    Title = "Ups =S", Message = "Algo salio mal, por favor intentalo de nuevo."
                };
                alert.AddButton("Aceptar");
                alert.Show();
            }

            try{
                //Registramos la visita al producto en la aplicacion web
                RegisterVisit(producto.tienda_id, MainView.userId);
            }
            catch (Exception) {
                /*Atrapamos la excepcion en caso de que el registro de la visita no pueda hacerse
                 * sin mostrar ningun mensaje ni detener el flujo de la aplicacion*/
            }

            try{
                //Leemos el servicio de los banners
                this.bannersService = new BannersService();
                banners             = bannersService.All();
            } catch (System.Net.WebException) {
                UIAlertView alert = new UIAlertView()
                {
                    Title = "UPS :S", Message = "Hubo un error al conectarse a internet la seccion de banners no puede mostrarse, por favor verifica tu conexión a internet"
                };
                alert.AddButton("Aceptar");
                alert.Show();
            }

            button = new UIButton(new CGRect(0, 0, bannerImage.Bounds.Width, bannerImage.Bounds.Height));
            bannerImage.Add(button);
            button.TouchUpInside += (sender, e) => {
                try{
                    if (bannerError == false)
                    {
                        if (element.imagen != "")
                        {
                            NSUrl url = new NSUrl(element.link);
                            UIApplication.SharedApplication.OpenUrl(url);
                        }
                    }
                }catch (Exception) {
                    //solo atrapamos la excepcion, no hacemos nada
                }
            };
        }
        // FBSample logic
        // Creates the Open Graph Action.
        void PostOpenGraphAction()
        {
            // First create the Open Graph meal object for the meal we ate.
            SCOGMeal mealObject = MealObjectForMeal(selectedMeal);

            // Now create an Open Graph eat action with the meal, our location, and the people we were with.
            //SCOGEatMealAction action = (SCOGEatMealAction)FBGraphObject.GraphObject ();

            FBGraphObject     obj    = FBGraphObject.GraphObject();
            SCOGEatMealAction action = new SCOGEatMealAction(obj.Handle);

            action.Meal = mealObject;
            if (selectedPlace != null)
            {
                action.Place = selectedPlace;
            }
            if (selectedFriends != null)
            {
                action.Tags = selectedFriends;
            }

            // Create the request and post the action to the "me/fb_sample_scrumps:eat" path.
            FBRequestConnection.StartForPostWithGraphPath("me/fb_sample_mtscrumps:eat", action, (FBRequestConnection connection, NSObject result, NSError error) => {
                activityIndicator.StopAnimating();
                this.View.UserInteractionEnabled = true;

                if (error == null)
                {
                    new UIAlertView("Result", "Posted Open Graph action, id: " + (string)new NSString(result.ValueForKey(new NSString("id")).Handle), null, "Thanks!", null).Show();
                    selectedMeal    = null;
                    selectedPlace   = null;
                    selectedFriends = null;
                    selectedPhoto   = null;
                    UpdateSelections();
                }
                else
                {
                    // do we lack permissions here? If so, the application's policy is to reask for the permissions, and if
                    // granted, we will recall this method in order to post the action
                    // TODO: Resolve Status Code 200
                    if (false)
                    {
                        Console.WriteLine(error.LocalizedDescription);

                        FBSession.ActiveSession.ReauthorizeWithPublishPermissions(new string[] { "publish_actions" }, FBSessionDefaultAudience.Friends, (FBSession fsession, NSError innerError) =>
                        {
                            if (innerError == null)
                            {
                                // re-call assuming we now have the permission
                                PostOpenGraphAction();
                            }
                            else
                            {
                                // If we are here, this means the user has disallowed posting after a retry
                                // which means iOS 6.0 will have turned the app's slider to "off" in the
                                // device settings->Facebook.
                                // You may want to customize the message for your application, since this
                                // string is specifically for iOS 6.0.
                                new UIAlertView("Permission To Post Disallowed", "Use device settings->Facebook to re-enable permission to post.", null, "Ok!", null).Show();
                            }
                        });
                    }
                    else
                    {
                        new UIAlertView("Result", "error: domain = " + error.Domain + ", code = " + (FBErrorCode)error.Code, null, "Ok", null).Show();
                    }
                }
            });
        }
		private void FacebookRequestForMeCompleted(FBRequestConnection connection, NSObject result, NSError error)
		{
			if (error == null)
			{
				Interfaces.Instance.FacebookInterface.UserEmail = result.ValueForKey(new NSString("email")) as NSString;
				Interfaces.Instance.FacebookInterface.UserId = result.ValueForKey(new NSString("id")) as NSString;
				if (!FBSession.ActiveSession.HasGranted("email"))
				{
					FBSession.ActiveSession.RequestNewReadPermissions(new string[] { "email" }, null);
					UIAlertView alertView = new UIAlertView("APP/ALERT/TITLE/ERROR".Localize(), "APP/FACEBOOK/ERRORS/NEED_EMAIL".Localize(), null, "APP/ALERT/BUTTON/OK".Localize(), null);
					alertView.Show();
					return;
				}
				FacebookLogin();
			}
			else
			{
				HandleFacebookError(error);
			}
		}
示例#9
0
 private void GetEmail()
 {
     FBRequestConnection.StartWithGraphPath("/me", null, "GET", ConnectionReturn);
 }