firebase crashlytics fix
This commit is contained in:
parent
37f624401f
commit
b9f355cdbf
|
@ -53,26 +53,29 @@ Future<void> _initializeSystemSettings() async {
|
||||||
final crashlyticsInstance = FirebaseCrashlytics.instance;
|
final crashlyticsInstance = FirebaseCrashlytics.instance;
|
||||||
|
|
||||||
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||||
|
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
//kDebugMode
|
|
||||||
print('Debug mode');
|
print('Debug mode');
|
||||||
|
await crashlyticsInstance.setCrashlyticsCollectionEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
print('Release mode');
|
print('Release mode');
|
||||||
bool unsentReports =
|
|
||||||
await FirebaseCrashlytics.instance.checkForUnsentReports();
|
|
||||||
if (unsentReports) {
|
|
||||||
// Existem relatórios não enviados
|
|
||||||
await crashlyticsInstance.sendUnsentReports();
|
|
||||||
print('Existem relatórios de falhas não enviados.');
|
|
||||||
} else {
|
|
||||||
// Não existem relatórios não enviados
|
|
||||||
print('Todos os relatórios de falhas foram enviados.');
|
|
||||||
}
|
|
||||||
await crashlyticsInstance.setCrashlyticsCollectionEnabled(true);
|
await crashlyticsInstance.setCrashlyticsCollectionEnabled(true);
|
||||||
// if (crashlyticsInstance.isCrashlyticsCollectionEnabled) {
|
|
||||||
FlutterError.onError = await crashlyticsInstance.recordFlutterError;
|
// Verifica e envia relatórios não enviados de forma assíncrona
|
||||||
|
crashlyticsInstance.checkForUnsentReports().then((unsentReports) {
|
||||||
|
if (unsentReports) {
|
||||||
|
crashlyticsInstance.sendUnsentReports();
|
||||||
|
print('Existem relatórios de falhas não enviados.');
|
||||||
|
} else {
|
||||||
|
print('Todos os relatórios de falhas foram enviados.');
|
||||||
|
}
|
||||||
|
}).catchError((error) {
|
||||||
|
print('Erro ao verificar ou enviar relatórios não enviados: $error');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Configura o tratamento de erros não capturados
|
||||||
|
FlutterError.onError = crashlyticsInstance.recordFlutterError;
|
||||||
print('Crashlytics enabled');
|
print('Crashlytics enabled');
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue