Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Failed to get document because the client is offline" error in Xamarin.Forms project #114

Open
CostasAthan opened this issue Oct 2, 2023 · 0 comments

Comments

@CostasAthan
Copy link

Here is my code of the App.xaml.cs file of a Xamarin.Forms project:

public partial class App : Application
    {
            public App()
            {
                CrossFirebaseCrashlytics.Current.HandleUncaughtException();
    
                InitializeComponent();
    
                MainPage = new Page();
    
                MainThread.BeginInvokeOnMainThread(async () => await Loader());
            }
    
            
            private async Task Loader()
            {
                var firebaseDocExists = false;
    
                var firebaseDoc = await CrossCloudFirestore.Current
                                                           .Instance
                                                           .Collection("myCollection")
                                                           .Document("docId")
                                                           .GetAsync();
    
                firebaseDocExists = firebaseDoc.Exists;
    
                if (firebaseDocExists == false) MainPage = new MyPage();
                else MainPage = new NavigationPage(new MainPage());
            }
    }

At the launch of the Android app on physical devices (API levels 29 & 31), not on the emulator, I get the following error:

crc64[alphanumeric_string].CrashlyticsException: Plugin.CloudFirestore.CloudFirestoreException: Failed to get document because the client is offline.
at MyApp.App.Loader ()(:0)
at MyApp.App.<.ctor>b__0_0 ()(:0)

Before the first Firestore reference in my initial code, I added this new line of code:

await CrossCloudFirestore.Current.Instance.EnableNetworkAsync();

No difference at all.

I also should add that running the app on the emulator does not produce the error, regardless which API level I use.

Environment details

  • OS: Android API levels 29 & 31
  • .NET version: .NET Standard 2.0
  • Package name and version: Plugin.CloudFirestore.Fix 5.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant