Closed Alecia1997 closed 1 week ago
Hi @Alecia1997 . Kindly provide a full sample code reproducing this issue.
Please find sample code to run:
import 'dart:io';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:package_info_plus/package_info_plus.dart';
class MainFirebaseRepository {
final FirebaseFirestore _firebaseFirestore = FirebaseFirestore.instance;
Future<int> latestAppVersion() async {
try {
DocumentSnapshot<Map<String, dynamic>> snapshot =
await _firebaseFirestore.collection('settings').doc('latestAppVersion').get();
if (Platform.isIOS) {
return snapshot.data()?['iosBuild'] ?? 0;
} else if (Platform.isAndroid) {
return snapshot.data()?['androidBuild'] ?? 0;
}
return 0;
} catch (e) {
print('Error fetching latest app version: $e');
rethrow;
}
}
}
class AppVersionChecker {
final MainFirebaseRepository _repository = MainFirebaseRepository();
Future<void> checkIfLatestAppVersion() async {
try {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
int buildNumberStoredInFirebase = await _repository.latestAppVersion();
int myBuildNumber = int.tryParse(packageInfo.buildNumber) ?? 0;
print('Firebase build number: $buildNumberStoredInFirebase');
print('Current app build number: $myBuildNumber');
if (buildNumberStoredInFirebase > myBuildNumber) {
print('App not using latest version');
} else {
print('App is using latest version');
}
} catch (e) {
print('Error checking app version: $e');
}
}
}
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
AppVersionChecker checker = AppVersionChecker();
await checker.checkIfLatestAppVersion();
}
The issue primarily impacts android users.
I am unable to reproduce this issue locally on my end. This issue is similar to 12019. From previous reports, it seems to be related to network issue/firestore downtime, etc.
Hey @Alecia1997. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Since there haven't been any recent updates here, I am going to close this issue.
@Alecia1997 if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.
Is there an existing issue for this?
Which plugins are affected?
Database
Which platforms are affected?
No response
Description
Description:
We are encountering an issue with the cloud_firestore package where Android users are receiving the following error:
[cloud_firestore/unavailable] The service is currently unavailable. This is most likely a transient condition and may be corrected by retrying with a backoff.
Reproducing the issue
Steps to Reproduce: Update the cloud_firestore package to the latest version. Attempt to connect to a Firestore database from an Android device. The above error is received intermittently.
Expected Behavior: Android devices should be able to connect to the Firestore database without encountering the [cloud_firestore/unavailable] error.
Firebase Core version
^3.3.0
Flutter Version
3.24.0
Relevant Log Output
No response
Flutter dependencies
No response
Additional context and comments
No response