Firebase and restore Wifi

BorisopritBorisoprit Member ✭✭✭
edited January 11 in Xamarin.Forms

I fill Entry with data from Firebase , there is only 1 record in the database.

Found out when i start the mainpage the record is in label , but when i start with no wifi nothing is happening of course.

Oke , but when i start Wifi and go back to mainpage there is en error that it is waiting for a response from the database ( from the first time i start mainpage ).

Put it for now in Try and Catch but is there another way to get the record , maybe only 1 time when i start the app

`

try
{
await Task.Delay(2000);

            base.OnAppearing();


            var person = await firebaseHelper.GetPerson(Convert.ToInt32(txtId.Text));
            if (person != null)
            {
                txtId.Text = person.PersonId.ToString();
                txtName.Text = person.Name;



            }
            else
            {

            }
        }
        catch
        {
            // If there is an error
        }

`

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    Will it instantiate a correct firebase when using await firebaseHelper.GetPerson?
    I guess it hasn't been successfully initialized due to internet access at the beginning time. Try to reconnect to firebase when it comes back and the network could be accessed.

Sign In or Register to comment.