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

Catch errors when Firebase remote fetch didn't work. #907

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion app/lib/main/plugin_initializations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class PluginInitializations {
// First, we activate the fetched remote config from the last fetch. Then
// we fetch the remote config in the background. The next time the app
// starts, the fetched remote config will be available.
unawaited(remoteConfiguration.fetch());
unawaited(tryFetchRemoteConfiguration(remoteConfiguration));
}
} catch (e) {
log('Remote configuration could not be initialized: $e');
Expand All @@ -108,6 +108,15 @@ class PluginInitializations {
return remoteConfiguration;
}

static Future<void> tryFetchRemoteConfiguration(
RemoteConfiguration remoteConfiguration) async {
try {
await remoteConfiguration.fetch();
} catch (e, s) {
log('Remote configuration could not be fetched', error: e, stackTrace: s);
}
}

static Future<SharedPreferences> initializeSharedPreferences() async {
final prefs = await SharedPreferences.getInstance();
return prefs;
Expand Down