I had to take over a project that someone made half finish and then left. I have an APK that works, but when I try to create a new APK it always comes up with no internet connection. I know the service works I tested it using Postman. I did update most Nuget packages. I as unable to update Refit to version 3. so it is on 2.4.1. I had a break point on the data and all data is in the 'apiManager.SignUp'.
When added a break point on 'protected async Task RemoteRequestAsync(Task task, CancellationToken ct)' the TData is always null.
public class ApiManager : IApiManager
{
private IApiService<IComcaApi> _api;
private IApiService<IGoogleApi> _googleApi;
public ApiManager(IApiService<IComcaApi> api, IApiService<IGoogleApi> googleApi)
{
_api = api;
_googleApi = googleApi;
}
protected async Task<TData> RemoteRequestAsync<TData>(Task<TData> task, CancellationToken ct)
{
TData data = default(TData);
data = await Policy
.Handle<WebException>()
.Or<ApiException>()
.WaitAndRetryAsync
(
retryCount: 2,
sleepDurationProvider: retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))
)
.ExecuteAsync(async () =>
{
ct.ThrowIfCancellationRequested();
var result = await task;
ct.ThrowIfCancellationRequested();
return result;
});
return data;
}
public async Task<HttpResponseMessage> SignUp(string username, string password, string storedid, string firstName, string lastName, string address, string secondAddress, string build, string apt, string city, string state, string zip, string email, string phone, string mobile, string refer, string starch, bool receiveEmail, bool receiveSms)
{
return await RemoteRequestAsync<HttpResponseMessage>(_api.GetApi(Priority.UserInitiated).SignUp(username,password,storedid, Settings.Verified, firstName,lastName,address,secondAddress,build,apt,city,state,zip,email,phone,mobile,refer,starch, receiveEmail, receiveSms), new CancellationToken());
}
Here is the call:
async Task SignUp()
{
HttpResponseMessage response;
IsFormFilled = true;
using (UserDialogs.Instance.Loading("Loading"))
{
response = await apiManager.SignUp(Settings.Username, Settings.Password, Settings.StoreId, UserData.FirstName, UserData.LastName, UserData.Address, UserData.SecondAddress, UserData.Building, UserData.Apartment, UserData.City, Helpers.Constants.states.Keys.ElementAt(SelectedStateIndex), UserData.ZipCode, UserData.Email, UserData.Phone, UserData.Mobile, UserData.ReferredBy, StarchList[SelectedStarchIndex], IsReceivingEmails, IsReceivingSms);
var responseMessage = response.RequestMessage.RequestUri.ToString();
}
System.Diagnostics.Debug.WriteLine("#### Response: " + response);
if (await ValidateResponseSession(response))
{
var userCreated = await response.Content.ReadAsStringAsync();
var deserialize = JsonConvert.DeserializeObject<BaseResponse<RegistrationReponse>>(userCreated);
if (deserialize.Results[0].Success == "true")
{
IsMessageVisible = false;
IsVerificationVisible = true;
}
else {
IsMessageVisible = true;
MessageTitle = "Error - Please try again";
}
}
else
{
IsMessageVisible = true;
MessageTitle = "Error - Please try again";
}
}
Thanks for any help