1

I'm trying to setup firebase for my flutter macos app. I followed the steps in the setup guide, meaning I have done:

  1. Created the macos platform with flutter create .
  2. flutterfire configure --project=PROJECT_NAME --platforms=macos
  3. Initialize the app with

await Firebase.initializeApp(
  options: DefaultFirebaseOptions.currentPlatform,
);

The flutterfire configure command created the macos app in my Firebase project and I made sure it uses the correct Bundle Id.

However my documents from firestore are not loading and I get the following error

Unhandled Exception: [cloud_firestore/unavailable] The service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff.

I'm using the latest firebase package versions. Nothing I have tried works so far.

What could this error mean? All I found so far was this, but this describes only a offline issue, which is not the case here.

2 Answers 2

1

In my case (Flutter 3.35 on macOS), it was not a Firebase outage. It was a combination of package version and macOS network permissions / entitlements.

1️⃣ Update Flutter & Firebase packages

First, make sure you’re on a recent Flutter and Firebase version:

flutter upgrade
flutter pub upgrade

And in pubspec.yaml use the latest versions of:

firebase_core: ^latest
cloud_firestore: ^latest

Then:

flutter pub get

2️⃣ Add network permission in macos/Runner/Info.plist

In macos/Runner/Info.plist, add:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

3️⃣ Update macOS entitlements

Both of these files need network client permission:

  • macos/Runner/Release.entitlements

  • macos/Runner/DebugProfile.entitlements

Add:

<key>com.apple.security.network.client</key>
<true/>

4️⃣ Clean and reinstall pods

Finally, clean and rebuild:

flutter clean
rm -rf macos/Pods macos/Podfile.lock
pod install
flutter run

Hope this helps someone facing the same issue Thanks

New contributor
mutahir nizami2 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Sign up to request clarification or add additional context in comments.

Comments

0

You should do Firestore rules like this ->

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
 match /{document=**} {
  allow read, write: if request.auth != null;
  }
 }
}

2 Comments

My permissions are not the problem. Furthermore, there is a different error for no permission
Are you sure that using latest versions of flutter and firebase ? Unless it works, you may create a new test project then try again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.