Ejemplo n.º 1
0
        public async Task <bool> SocialLoginFacebook()
        {
            try
            {
                FbAccessToken token = await Xamarin.Forms.DependencyService.Get <IFacebookLogin>().LogIn(permissions);

                if (token != null)
                {
                    // save token
                    await token.Save();

                    IGraphRequest  request  = Xamarin.Forms.DependencyService.Get <IGraphRequest>().NewRequest(token, "/me", parameters);
                    IGraphResponse response = await request.ExecuteAsync();

                    SocialModel socialModel = GetFBData(JObject.Parse(response.RawResponse));
                    socialModel.AuthType = AuthType.Facebook;
                    await RegisterAndUpdate(socialModel);

                    return(true);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("======================token was null");
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.ToString());
            }
            return(false);
        }
Ejemplo n.º 2
0
        public async Task <bool> HandleAlreadyLoggedIn(FbAccessToken token)
        {
            IGraphRequest  request  = Xamarin.Forms.DependencyService.Get <IGraphRequest>().NewRequest(token, "/me", parameters);
            IGraphResponse response = await request.ExecuteAsync();

            if (response.RawResponse != null)
            {
                SocialModel socialModel = GetFBData(JObject.Parse(response.RawResponse));
                socialModel.AuthType = AuthType.Facebook;
                await RegisterAndUpdate(socialModel);

                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
0
        async void HandleAlreadyLoggedIn(FbAccessToken token)
        {
            parameters.Add("fields", "name, email");
            IGraphRequest request = DependencyService.Get <IGraphRequest>()
                                    .NewRequest(token, "/me", parameters);

            IGraphResponse response = await request.ExecuteAsync();

            System.Diagnostics.Debug.WriteLine(response.RawResponse);

            Dictionary <string, string> deserialized = JsonConvert
                                                       .DeserializeObject <Dictionary <string, string> >(response.RawResponse);
            FacebookProfile profile = new FacebookProfile(deserialized["name"], deserialized["email"], deserialized["id"]);

            await CoreMethods.PushPageModel <LoggedInPageModel>(profile);
        }