private TokenModel GetTokenModel()
        {
            if (tokenModel == null)
            {
                var bearerToken = (string)preferenceHelper.GetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN);
                tokenModel = new TokenModel {
                    Token = bearerToken
                };
            }

            return(tokenModel);
        }
		protected override async void OnCreate(Bundle savedInstanceState)
		{
			base.OnCreate(savedInstanceState);
			ActivityInstance = this;
			this.preferenceHelper = new SharedPreferencesHelper(this);
			bearerToken = (string)preferenceHelper.GetSharedPreference<string>(SharedPreferencesKeys.BEARER_TOKEN);
			this.chatHubClientService = ChatHubClientService.GetServiceInstance(bearerToken);
			SetContentView(Resource.Layout.ConversationActivity);
			GetExtras();
			pageNumber = 0;
			await SetupViews(savedInstanceState);
		}
        private async Task <bool> SignInUser()
        {
            var userIsLogged = false;

            preferenceHelper = new SharedPreferencesHelper(this);
            var bearerToken = (string)preferenceHelper.GetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN);

            if (bearerToken != null)
            {
                userIsLogged = await signInService.SignInUserWithBearerToken(GetTokenModel());
            }
            if (!userIsLogged)
            {
                if (AccessToken.CurrentAccessToken != null && AccessToken.CurrentAccessToken.Token != null)
                {
                    var facebookToken = new FacebookTokenViewModel {
                        FacebookToken = AccessToken.CurrentAccessToken.Token
                    };
                    var tokenModel = await signInService.SignInUserWithFacebookToken(facebookToken);

                    if (tokenModel != null)
                    {
                        preferenceHelper.SetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN, tokenModel.Token);
                        if (tokenModel.UserHasToSetNickName)
                        {
                            throw new UserHasToSetNickNameException();
                        }
                        else
                        {
                            SharedPreferencesHelper.SetUserNameInAppSettings(this, tokenModel.UserName);
                        }
                        userIsLogged = true;
                    }
                }
            }

            return(userIsLogged);
        }
		private async Task<bool> SignInUser()
		{
			var userIsLogged = false;
			var preferenceHelper = new SharedPreferencesHelper(this);
			var bearerToken = (string)preferenceHelper.GetSharedPreference<string>(SharedPreferencesKeys.BEARER_TOKEN);
			if (bearerToken != null)
			{
				userIsLogged = await signInService.SignInUserWithBearerToken(new TokenModel { Token = bearerToken });
			}
			if (!userIsLogged)
			{
				if (AccessToken.CurrentAccessToken != null && AccessToken.CurrentAccessToken.Token != null)
				{
					var facebookToken = new FacebookTokenViewModel { FacebookToken = AccessToken.CurrentAccessToken.Token };
					var tokenModel = await signInService.SignInUserWithFacebookToken(facebookToken);
					if (tokenModel != null)
					{
						preferenceHelper.SetSharedPreference<string>(SharedPreferencesKeys.BEARER_TOKEN, tokenModel.Token);
						userIsLogged = true;
					}
				}
			}

			return userIsLogged;
		}