public async Task <LoginResponse> SocialLoginUser(UserSocialLoginRequest model, ServiceType ServiceType, string Authkey) { LoginResponse response = new LoginResponse(); var result = await _objUtility.AllApiInterface(ApiRouteConstant.SocialUserLogin, (int)Method.POST, model, ServiceType, Authkey); if (result != null) { response = JsonConvert.DeserializeObject <LoginResponse>(result); } return(response); }
protected async Task <bool> UserSocialLogin(string authToken, string firstName, string lastName, string socialId, int loginType) { UserSocialLoginRequest model = new UserSocialLoginRequest { Email = "", FirstName = firstName, LastName = lastName, LoginType = loginType, SocialId = socialId, DeviceType = (int)EnumDeviceType.Android, DeviceToken = StorageUtils <String> .GetPreferencesValue(DroidConstant.DeviceToken) }; if (AppUtils.IsNetwork()) { var response = await _ILoginService.SocialLoginUser(model, ServiceType.UserService, authToken); if (response != null) { if (response.IsSuccess) { //StorageUtils<String>.GetPreferences(DroidConstant.CurrentUser) string token = response.Result.Token; StorageUtils <String> .SavePreferences(DroidConstant.CurrentUser, token); _objProgress.DismissDialog(); StartActivity(typeof(MainActivity)); Finish(); return(true); } else { AppUtils.ShowToast(this, response.Message); _objProgress.DismissDialog(); return(true); } } else { _objProgress.DismissDialog(); AppUtils.ShowToast(this, Resources.GetString(Resource.String.network_error)); return(true); } } else { _objProgress.DismissDialog(); AppUtils.ShowToast(this, Resources.GetString(Resource.String.network_error)); return(true); } }
protected async Task <bool> UserSocialLogin(UserSocialLoginRequest model) { var token = await GetAuthKey(); ILoginService _ILoginService = new LoginService(); NetworkReachabilityFlags flag; bool network = Reachability.IsNetworkAvailable(out flag); if (network) { CommonUtils.ShowProgress(View); var response = await _ILoginService.SocialLoginUser(model, ServiceType.UserService, token); if (response != null) { if (response.IsSuccess) { StorageUtils <LoginResponse> .SavePreferences(AppConstant.CurrentUser, response); var plist = NSUserDefaults.StandardUserDefaults; plist.SetBool(true, "IsLogged"); CommonUtils.HideProgress(); CommonUtils.RedirectToController(AppConstant.HomeController); return(true); } else { CommonUtils.AlertView(response.Message); CommonUtils.HideProgress(); return(true); } } else { CommonUtils.HideProgress(); CommonUtils.AlertView(AppConstant.NetworkError); return(true); } } else { CommonUtils.AlertView(AppConstant.NetworkError); return(true); } }
public async void FacebookAuth_Completed(object sender, AuthenticatorCompletedEventArgs e) { if (e.IsAuthenticated) { var request = new OAuth2Request( "GET", new Uri("https://graph.facebook.com/me?fields=name,picture,cover,first_name,gender,last_name,email"), null, e.Account); var fbResponse = await request.GetResponseAsync(); var fbUser = JsonValue.Parse(fbResponse.GetResponseText()); var name = fbUser["name"]; var id = fbUser["id"]; var FirstName = fbUser["first_name"]; var LastName = fbUser["last_name"]; //var Email = fbUser["Email"]; var UserID = fbUser["gender"]; var picture = fbUser["picture"]["data"]["url"]; var cover = fbUser["cover"]["source"]; DismissViewController(true, null); model = new UserSocialLoginRequest { FirstName = FirstName, LastName = LastName, Email = "", SocialId = UserID, LoginType = (int)LoginTypes.Facebook, DeviceType = (int)EnumDeviceType.IOS, DeviceToken = "ABC" // DeviceToken }; await UserSocialLogin(model); //NameLabel.Text += name; //IdLabel.Text += id; //PictureImage.Image = UIImage.LoadFromData(NSData.FromUrl(new NSUrl(picture))); //CoverImage.Image = UIImage.LoadFromData(NSData.FromUrl(new NSUrl(cover))); } else { DismissViewController(true, null); } }