public void OnCompleted(JSONObject p0, GraphResponse p1)
        {
            FacebookResponseK fbResponse = JsonConvert.DeserializeObject <FacebookResponseK>(p1.RawResponse);

            profile = Profile.CurrentProfile;

            if (profile != null)
            {
                var buttonFB = view.FindViewById <Button>(Resource.Id.buttonFB);
                buttonFB.Enabled = false;
                buttonFB.SetBackgroundColor(Xamarin.Forms.Color.Gray.ToAndroid());

                profilePictureView.ProfileId = profile.Id;
                Android.Net.Uri profilePic = profile.GetProfilePictureUri(220, 220);
                fbPictureUrl = profilePic.ToString();

                //chito.do not force user to must have an email
                viewModel.FacebookEmail     = fbResponse.email ?? "";
                viewModel.FacebookFirstName = firstname ?? fbResponse.first_name;
                viewModel.FacebookLastName  = lastname ?? fbResponse.last_name;
                viewModel.FacebookPhoto     = fbPictureUrl;
                viewModel.FacebookBirthday  = fbResponse.birthday;
                viewModel.FacebookGender    = fbResponse.gender;
                viewModel.FacebookId        = fbResponse.id ?? "0";
                viewModel.FacebookLink      = fbResponse.link;
                viewModel.SaveFacebookProfileAsync();
            }
        }
Пример #2
0
        private void ProcessFBInfo()
        {
            var request = new GraphRequest("/me?fields=email,picture,birthday,gender,link", null, AccessToken.CurrentAccessToken.TokenString, null, "GET");

            request.Start((connection, result, error) => {
                if (error != null)
                {
                    new UIAlertView("Error...", error.Description, null, "Ok", null).Show();
                    return;
                }

                loginView.Enabled       = false;
                loginView.Alpha         = 0.5f;
                var userInfo            = result as NSDictionary;
                viewModel.FacebookEmail = (userInfo["email"] != null) ? userInfo["email"].ToString() : "";

                if (userInfo["birthday"] != null)
                {
                    viewModel.FacebookBirthday = userInfo["birthday"].ToString();
                }

                if (userInfo["gender"] != null)
                {
                    viewModel.FacebookGender = userInfo["gender"].ToString();
                }

                if (userInfo["link"] != null)
                {
                    viewModel.FacebookLink = userInfo["link"].ToString();
                }

                var nsImageURL          = Profile.CurrentProfile.ImageUrl(ProfilePictureMode.Normal, new CGSize(220, 220));
                viewModel.FacebookPhoto = nsImageURL.AbsoluteString;
                viewModel.SaveFacebookProfileAsync();
            });
        }