From 8a0caa05d5abf6fef5bf0e654654dcd0b6ec874a Mon Sep 17 00:00:00 2001 From: Russell Wheatley Date: Wed, 26 Oct 2022 12:41:59 +0100 Subject: [PATCH] docs(crashlytics): Use `PlatformDispatcher.instance.onError` for async errors. Update Crashlytics example app to use "flutterfire-e2e-tests" project. (#9669) Co-authored-by: Kevin Cheung --- docs/crashlytics/_customize-crash-reports.md | 50 ++- docs/crashlytics/_get-started.md | 26 +- .../example/android/app/google-services.json | 417 +++++++++++++++++- .../ios/Runner.xcodeproj/project.pbxproj | 17 +- .../ios/{ => Runner}/GoogleService-Info.plist | 20 +- .../example/ios/Runner/Info.plist | 4 +- .../example/ios/firebase_app_id_file.json | 7 + .../example/lib/firebase_options.dart | 74 ++-- .../example/lib/main.dart | 24 +- .../macos/Runner.xcodeproj/project.pbxproj | 8 +- .../macos/Runner/GoogleService-Info.plist | 2 +- .../example/macos/firebase_app_id_file.json | 7 + 12 files changed, 556 insertions(+), 100 deletions(-) rename packages/firebase_crashlytics/firebase_crashlytics/example/ios/{ => Runner}/GoogleService-Info.plist (54%) create mode 100644 packages/firebase_crashlytics/firebase_crashlytics/example/ios/firebase_app_id_file.json create mode 100644 packages/firebase_crashlytics/firebase_crashlytics/example/macos/firebase_app_id_file.json diff --git a/docs/crashlytics/_customize-crash-reports.md b/docs/crashlytics/_customize-crash-reports.md index 35d0daef5efc..127e89081a6c 100644 --- a/docs/crashlytics/_customize-crash-reports.md +++ b/docs/crashlytics/_customize-crash-reports.md @@ -20,57 +20,62 @@ to disk to be sent along with the next fatal report or when the app restarts. ## Report uncaught exceptions {: #report-uncaught-exceptions} -You can automatically catch all errors that are thrown within the Flutter +You can automatically catch all "fatal" errors that are thrown within the Flutter framework by overriding `FlutterError.onError` with -`FirebaseCrashlytics.instance.recordFlutterFatalError`: +`FirebaseCrashlytics.instance.recordFlutterFatalError`. Alternatively, +to also catch "non-fatal" exceptions, override `FlutterError.onError` with `FirebaseCrashlytics.instance.recordFlutterError`: ```dart void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); - - // Pass all uncaught errors from the framework to Crashlytics. - FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError; + bool weWantFatalErrorRecording = true; + FlutterError.onError = (errorDetails) { + if(weWantFatalErrorRecording){ + FirebaseCrashlytics.instance.recordFlutterFatalError(errorDetails); + } else { + FirebaseCrashlytics.instance.recordFlutterError(errorDetails); + } + }; runApp(MyApp()); } ``` -### Zoned errors {: #zoned-errors} -Not all errors are caught by Flutter. Sometimes, errors are instead caught by -`Zones`. A common case where relying on Flutter to catch errors would not be -enough is when an exception happens inside the `onPressed` handler of a button: +### Asynchronous errors {: #asynchronous-errors} + +Asynchronous errors are not caught by the Flutter framework: ```dart ElevatedButton( - onPressed: () { + onPressed: () async { throw Error(); } ... ) ``` -To catch such errors, you can use `runZonedGuarded`: +To catch such errors, you can use the `PlatformDispatcher.instance.onError` handler: ```dart -void main() async { - runZonedGuarded>(() async { +Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); - // The following lines are the same as previously explained in "Handling uncaught errors" - FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError; - + FlutterError.onError = (errorDetails) { + FirebaseCrashlytics.instance.recordFlutterFatalError(errorDetails); + }; + // Pass all uncaught asynchronous errors that aren't handled by the Flutter framework to Crashlytics + PlatformDispatcher.instance.onError = (error, stack) { + FirebaseCrashlytics.instance.recordError(error, stack, fatal: true); + return true; + }; runApp(MyApp()); - }, (error, stack) => FirebaseCrashlytics.instance.recordError(error, stack, fatal: true)); + } ``` -Note: You must call `WidgetsFlutterBinding.ensureInitialized()` _inside_ -`runZonedGuarded`. Error handling wouldn’t work if -`WidgetsFlutterBinding.ensureInitialized()` was called from the outside. - ### Errors outside of Flutter {: #errors-outside-flutter} To catch errors that happen outside of the Flutter context, install an error @@ -108,6 +113,9 @@ await FirebaseCrashlytics.instance.recordError( stackTrace, reason: 'a non-fatal error' ); + +// Or you can use: +await FirebaseCrashlytics.instance.recordFlutterError(errorDetails); ``` You may also wish to log further information about the error which is possible diff --git a/docs/crashlytics/_get-started.md b/docs/crashlytics/_get-started.md index 31d5f944b726..56e4306b6277 100644 --- a/docs/crashlytics/_get-started.md +++ b/docs/crashlytics/_get-started.md @@ -66,29 +66,31 @@ void main() async { await Firebase.initializeApp(); - // Pass all uncaught errors from the framework to Crashlytics. + // Pass all uncaught "fatal" errors from the framework to Crashlytics FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError; runApp(MyApp()); } ``` -If you're using zones, instrumenting the zone’s error handler will catch errors -that aren't caught by the Flutter framework (for example, in a button’s -`onPressed` handler): +To catch asynchronous errors that aren't handled by the Flutter framework, use +`PlatformDispatcher.instance.onError`: + ```dart -void main() async { - runZonedGuarded>(() async { +Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); - - FlutterError.onError = - FirebaseCrashlytics.instance.recordFlutterFatalError; - + FlutterError.onError = (errorDetails) { + FirebaseCrashlytics.instance.recordFlutterFatalError(errorDetails); + }; + // Pass all uncaught asynchronous errors that aren't handled by the Flutter framework to Crashlytics + PlatformDispatcher.instance.onError = (error, stack) { + FirebaseCrashlytics.instance.recordError(error, stack, fatal: true); + return true; + }; runApp(MyApp()); - }, (error, stack) => - FirebaseCrashlytics.instance.recordError(error, stack, fatal: true)); + } ``` diff --git a/packages/firebase_crashlytics/firebase_crashlytics/example/android/app/google-services.json b/packages/firebase_crashlytics/firebase_crashlytics/example/android/app/google-services.json index 71e2bfecccc8..13dc69de2fee 100644 --- a/packages/firebase_crashlytics/firebase_crashlytics/example/android/app/google-services.json +++ b/packages/firebase_crashlytics/firebase_crashlytics/example/android/app/google-services.json @@ -6,6 +6,162 @@ "storage_bucket": "flutterfire-e2e-tests.appspot.com" }, "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:406099696497:android:e0752d466d8936243574d0", + "android_client_info": { + "package_name": "com.example.testcliapp" + } + }, + "oauth_client": [ + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCdRjCVZlhrq72RuEklEyyxYlBRCYhI2Sw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "406099696497-17cfsesi620nhia0sck4map450gngkoh.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "io.flutter.plugins.firebase.appcheck.example", + "app_store_id": "123456" + } + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:406099696497:android:a241c4b471513a203574d0", + "android_client_info": { + "package_name": "io.flutter.plugins.firebase.appcheck.example" + } + }, + "oauth_client": [ + { + "client_id": "406099696497-7bvmqp0fffe24vm2arng0dtdeh2tvkgl.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "io.flutter.plugins.firebase.appcheck.example", + "certificate_hash": "909ca1482ef022bbae45a2db6b6d05d807a4c4aa" + } + }, + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCdRjCVZlhrq72RuEklEyyxYlBRCYhI2Sw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "406099696497-17cfsesi620nhia0sck4map450gngkoh.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "io.flutter.plugins.firebase.appcheck.example", + "app_store_id": "123456" + } + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:406099696497:android:3ef965ff044efc0b3574d0", + "android_client_info": { + "package_name": "io.flutter.plugins.firebase.database.example" + } + }, + "oauth_client": [ + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCdRjCVZlhrq72RuEklEyyxYlBRCYhI2Sw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "406099696497-17cfsesi620nhia0sck4map450gngkoh.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "io.flutter.plugins.firebase.appcheck.example", + "app_store_id": "123456" + } + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:406099696497:android:40da41183cb3d3ff3574d0", + "android_client_info": { + "package_name": "io.flutter.plugins.firebase.dynamiclinksexample" + } + }, + "oauth_client": [ + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCdRjCVZlhrq72RuEklEyyxYlBRCYhI2Sw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "406099696497-17cfsesi620nhia0sck4map450gngkoh.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "io.flutter.plugins.firebase.appcheck.example", + "app_store_id": "123456" + } + } + ] + } + } + }, { "client_info": { "mobilesdk_app_id": "1:406099696497:android:7ca3394493cc601a3574d0", @@ -14,6 +170,14 @@ } }, "oauth_client": [ + { + "client_id": "406099696497-17qn06u8a0dc717u8ul7s49ampk13lul.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "io.flutter.plugins.firebase.functions.example", + "certificate_hash": "a4256c0612686b336af6d138a5479b7dc1ee1af6" + } + }, { "client_id": "406099696497-tvtvuiqogct1gs1s6lh114jeps7hpjm5.apps.googleusercontent.com", "client_type": 1, @@ -40,10 +204,48 @@ "client_type": 3 }, { - "client_id": "406099696497-epk7902e2mb4pj4i4gcotk4q7dp2i9h3.apps.googleusercontent.com", + "client_id": "406099696497-17cfsesi620nhia0sck4map450gngkoh.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "io.flutter.plugins.firebase.appcheck.example", + "app_store_id": "123456" + } + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:406099696497:android:74ebb073d7727cd43574d0", + "android_client_info": { + "package_name": "io.flutter.plugins.firebase.messaging.example" + } + }, + "oauth_client": [ + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCdRjCVZlhrq72RuEklEyyxYlBRCYhI2Sw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "406099696497-17cfsesi620nhia0sck4map450gngkoh.apps.googleusercontent.com", "client_type": 2, "ios_info": { - "bundle_id": "io.flutter.plugins.firebase.crashlytics.example" + "bundle_id": "io.flutter.plugins.firebase.appcheck.example", + "app_store_id": "123456" } } ] @@ -76,10 +278,175 @@ "client_type": 3 }, { - "client_id": "406099696497-epk7902e2mb4pj4i4gcotk4q7dp2i9h3.apps.googleusercontent.com", + "client_id": "406099696497-17cfsesi620nhia0sck4map450gngkoh.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "io.flutter.plugins.firebase.appcheck.example", + "app_store_id": "123456" + } + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:406099696497:android:899c6485cfce26c13574d0", + "android_client_info": { + "package_name": "io.flutter.plugins.firebase_ui_example" + } + }, + "oauth_client": [ + { + "client_id": "406099696497-ltgvphphcckosvqhituel5km2k3aecg8.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "io.flutter.plugins.firebase_ui_example", + "certificate_hash": "a4256c0612686b336af6d138a5479b7dc1ee1af6" + } + }, + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCdRjCVZlhrq72RuEklEyyxYlBRCYhI2Sw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "406099696497-17cfsesi620nhia0sck4map450gngkoh.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "io.flutter.plugins.firebase.appcheck.example", + "app_store_id": "123456" + } + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:406099696497:android:b7a347ba65ca3b803574d0", + "android_client_info": { + "package_name": "io.flutter.plugins.firebaseanalyticsexample" + } + }, + "oauth_client": [ + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCdRjCVZlhrq72RuEklEyyxYlBRCYhI2Sw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "406099696497-17cfsesi620nhia0sck4map450gngkoh.apps.googleusercontent.com", "client_type": 2, "ios_info": { - "bundle_id": "io.flutter.plugins.firebase.crashlytics.example" + "bundle_id": "io.flutter.plugins.firebase.appcheck.example", + "app_store_id": "123456" + } + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:406099696497:android:61e67dfd35ab93ad3574d0", + "android_client_info": { + "package_name": "io.flutter.plugins.firebaseauthexample" + } + }, + "oauth_client": [ + { + "client_id": "406099696497-j20pm6c84pofkl1ivo4f7fe797smfnp4.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "io.flutter.plugins.firebaseauthexample", + "certificate_hash": "a4256c0612686b336af6d138a5479b7dc1ee1af6" + } + }, + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCdRjCVZlhrq72RuEklEyyxYlBRCYhI2Sw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "406099696497-17cfsesi620nhia0sck4map450gngkoh.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "io.flutter.plugins.firebase.appcheck.example", + "app_store_id": "123456" + } + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:406099696497:android:bc0b12b0605df8633574d0", + "android_client_info": { + "package_name": "io.flutter.plugins.firebasecoreexample" + } + }, + "oauth_client": [ + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCdRjCVZlhrq72RuEklEyyxYlBRCYhI2Sw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "406099696497-17cfsesi620nhia0sck4map450gngkoh.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "io.flutter.plugins.firebase.appcheck.example", + "app_store_id": "123456" } } ] @@ -112,10 +479,48 @@ "client_type": 3 }, { - "client_id": "406099696497-epk7902e2mb4pj4i4gcotk4q7dp2i9h3.apps.googleusercontent.com", + "client_id": "406099696497-17cfsesi620nhia0sck4map450gngkoh.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "io.flutter.plugins.firebase.appcheck.example", + "app_store_id": "123456" + } + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:406099696497:android:2751af6868a69f073574d0", + "android_client_info": { + "package_name": "io.flutter.plugins.firebasestorageexample" + } + }, + "oauth_client": [ + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCdRjCVZlhrq72RuEklEyyxYlBRCYhI2Sw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "406099696497-17cfsesi620nhia0sck4map450gngkoh.apps.googleusercontent.com", "client_type": 2, "ios_info": { - "bundle_id": "io.flutter.plugins.firebase.crashlytics.example" + "bundle_id": "io.flutter.plugins.firebase.appcheck.example", + "app_store_id": "123456" } } ] diff --git a/packages/firebase_crashlytics/firebase_crashlytics/example/ios/Runner.xcodeproj/project.pbxproj b/packages/firebase_crashlytics/firebase_crashlytics/example/ios/Runner.xcodeproj/project.pbxproj index 1110354b41e3..0602d8ef8636 100644 --- a/packages/firebase_crashlytics/firebase_crashlytics/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/firebase_crashlytics/firebase_crashlytics/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ @@ -16,6 +16,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + AAE9D7BFA8AAA8783C2860B2 /* GoogleService-Info.plist in Sources */ = {isa = PBXBuildFile; fileRef = 864CBEC4F3EDA362F4B5B76D /* GoogleService-Info.plist */; }; F3CD36E5DA207BF24A9BECE5 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 90669E7218FC80716B8D1896 /* libPods-Runner.a */; }; /* End PBXBuildFile section */ @@ -42,6 +43,7 @@ 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 864CBEC4F3EDA362F4B5B76D /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = ""; }; 90669E7218FC80716B8D1896 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; @@ -104,6 +106,7 @@ 97C146EF1CF9000F007C117D /* Products */, 578F13DB49C24452CA02A630 /* Pods */, 9278C72542532A6D4853596F /* Frameworks */, + 864CBEC4F3EDA362F4B5B76D /* GoogleService-Info.plist */, ); sourceTree = ""; }; @@ -175,6 +178,7 @@ TargetAttributes = { 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; + DevelopmentTeam = YYX2P3XVJ7; }; }; }; @@ -292,6 +296,7 @@ 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, 97C146F31CF9000F007C117D /* main.m in Sources */, 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + AAE9D7BFA8AAA8783C2860B2 /* GoogleService-Info.plist in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -370,7 +375,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = S8QB4VV633; + DEVELOPMENT_TEAM = YYX2P3XVJ7; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -382,7 +387,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebase.crashlytics.firebaseCrashlyticsExample; + PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebase.crashlytics.example; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; @@ -495,6 +500,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = YYX2P3XVJ7; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -506,7 +512,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebase.crashlytics.firebaseCrashlyticsExample; + PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebase.crashlytics.example; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; @@ -518,6 +524,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = YYX2P3XVJ7; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -529,7 +536,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebase.crashlytics.firebaseCrashlyticsExample; + PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebase.crashlytics.example; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; diff --git a/packages/firebase_crashlytics/firebase_crashlytics/example/ios/GoogleService-Info.plist b/packages/firebase_crashlytics/firebase_crashlytics/example/ios/Runner/GoogleService-Info.plist similarity index 54% rename from packages/firebase_crashlytics/firebase_crashlytics/example/ios/GoogleService-Info.plist rename to packages/firebase_crashlytics/firebase_crashlytics/example/ios/Runner/GoogleService-Info.plist index e5559131439f..1da32534601c 100644 --- a/packages/firebase_crashlytics/firebase_crashlytics/example/ios/GoogleService-Info.plist +++ b/packages/firebase_crashlytics/firebase_crashlytics/example/ios/Runner/GoogleService-Info.plist @@ -3,23 +3,23 @@ CLIENT_ID - 448618578101-54jhd806d0tr4vkgode0b4fi8iruvjpn.apps.googleusercontent.com + 406099696497-epk7902e2mb4pj4i4gcotk4q7dp2i9h3.apps.googleusercontent.com REVERSED_CLIENT_ID - com.googleusercontent.apps.448618578101-54jhd806d0tr4vkgode0b4fi8iruvjpn + com.googleusercontent.apps.406099696497-epk7902e2mb4pj4i4gcotk4q7dp2i9h3 ANDROID_CLIENT_ID - 448618578101-velutq65ok2dr5ohh0oi1q62irr920ss.apps.googleusercontent.com + 406099696497-17qn06u8a0dc717u8ul7s49ampk13lul.apps.googleusercontent.com API_KEY - AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0 + AIzaSyDooSUGSf63Ghq02_iIhtnmwMDs4HlWS6c GCM_SENDER_ID - 448618578101 + 406099696497 PLIST_VERSION 1 BUNDLE_ID - io.flutter.plugins.firebase.crashlytics.firebaseCrashlyticsExample + io.flutter.plugins.firebase.crashlytics.example PROJECT_ID - react-native-firebase-testing + flutterfire-e2e-tests STORAGE_BUCKET - react-native-firebase-testing.appspot.com + flutterfire-e2e-tests.appspot.com IS_ADS_ENABLED IS_ANALYTICS_ENABLED @@ -31,8 +31,8 @@ IS_SIGNIN_ENABLED GOOGLE_APP_ID - 1:448618578101:ios:3d7b3d90894e689eac3efc + 1:406099696497:ios:1d042a17c4dd64323574d0 DATABASE_URL - https://react-native-firebase-testing.firebaseio.com + https://flutterfire-e2e-tests-default-rtdb.europe-west1.firebasedatabase.app \ No newline at end of file diff --git a/packages/firebase_crashlytics/firebase_crashlytics/example/ios/Runner/Info.plist b/packages/firebase_crashlytics/firebase_crashlytics/example/ios/Runner/Info.plist index 725e580a2228..ba7b92d7d78c 100644 --- a/packages/firebase_crashlytics/firebase_crashlytics/example/ios/Runner/Info.plist +++ b/packages/firebase_crashlytics/firebase_crashlytics/example/ios/Runner/Info.plist @@ -2,6 +2,8 @@ + CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion en CFBundleExecutable @@ -41,7 +43,5 @@ UIViewControllerBasedStatusBarAppearance - CADisableMinimumFrameDurationOnPhone - diff --git a/packages/firebase_crashlytics/firebase_crashlytics/example/ios/firebase_app_id_file.json b/packages/firebase_crashlytics/firebase_crashlytics/example/ios/firebase_app_id_file.json new file mode 100644 index 000000000000..5a9675ea0399 --- /dev/null +++ b/packages/firebase_crashlytics/firebase_crashlytics/example/ios/firebase_app_id_file.json @@ -0,0 +1,7 @@ +{ + "file_generated_by": "FlutterFire CLI", + "purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory", + "GOOGLE_APP_ID": "1:406099696497:ios:1d042a17c4dd64323574d0", + "FIREBASE_PROJECT_ID": "flutterfire-e2e-tests", + "GCM_SENDER_ID": "406099696497" +} \ No newline at end of file diff --git a/packages/firebase_crashlytics/firebase_crashlytics/example/lib/firebase_options.dart b/packages/firebase_crashlytics/firebase_crashlytics/example/lib/firebase_options.dart index 517df0913456..f73d768a9d41 100644 --- a/packages/firebase_crashlytics/firebase_crashlytics/example/lib/firebase_options.dart +++ b/packages/firebase_crashlytics/firebase_crashlytics/example/lib/firebase_options.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. // File generated by FlutterFire CLI. -// ignore_for_file: lines_longer_than_80_chars +// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform; @@ -26,7 +26,6 @@ class DefaultFirebaseOptions { 'you can reconfigure this by running the FlutterFire CLI again.', ); } - // ignore: missing_enum_constant_in_switch switch (defaultTargetPlatform) { case TargetPlatform.android: return android; @@ -34,49 +33,60 @@ class DefaultFirebaseOptions { return ios; case TargetPlatform.macOS: return macos; + case TargetPlatform.windows: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for windows - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.linux: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for linux - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + default: + throw UnsupportedError( + 'DefaultFirebaseOptions are not supported for this platform.', + ); } - - throw UnsupportedError( - 'DefaultFirebaseOptions are not supported for this platform.', - ); } static const FirebaseOptions android = FirebaseOptions( - apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', - appId: '1:448618578101:ios:3d7b3d90894e689eac3efc', - messagingSenderId: '448618578101', - projectId: 'react-native-firebase-testing', - databaseURL: 'https://react-native-firebase-testing.firebaseio.com', - storageBucket: 'react-native-firebase-testing.appspot.com', + apiKey: 'AIzaSyCdRjCVZlhrq72RuEklEyyxYlBRCYhI2Sw', + appId: '1:406099696497:android:0f3f7bfe78b8b7103574d0', + messagingSenderId: '406099696497', + projectId: 'flutterfire-e2e-tests', + databaseURL: + 'https://flutterfire-e2e-tests-default-rtdb.europe-west1.firebasedatabase.app', + storageBucket: 'flutterfire-e2e-tests.appspot.com', ); static const FirebaseOptions ios = FirebaseOptions( - apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', - appId: '1:448618578101:ios:3d7b3d90894e689eac3efc', - messagingSenderId: '448618578101', - projectId: 'react-native-firebase-testing', - databaseURL: 'https://react-native-firebase-testing.firebaseio.com', - storageBucket: 'react-native-firebase-testing.appspot.com', + apiKey: 'AIzaSyDooSUGSf63Ghq02_iIhtnmwMDs4HlWS6c', + appId: '1:406099696497:ios:1d042a17c4dd64323574d0', + messagingSenderId: '406099696497', + projectId: 'flutterfire-e2e-tests', + databaseURL: + 'https://flutterfire-e2e-tests-default-rtdb.europe-west1.firebasedatabase.app', + storageBucket: 'flutterfire-e2e-tests.appspot.com', androidClientId: - '448618578101-velutq65ok2dr5ohh0oi1q62irr920ss.apps.googleusercontent.com', + '406099696497-17qn06u8a0dc717u8ul7s49ampk13lul.apps.googleusercontent.com', iosClientId: - '448618578101-54jhd806d0tr4vkgode0b4fi8iruvjpn.apps.googleusercontent.com', - iosBundleId: - 'io.flutter.plugins.firebase.crashlytics.firebaseCrashlyticsExample', + '406099696497-epk7902e2mb4pj4i4gcotk4q7dp2i9h3.apps.googleusercontent.com', + iosBundleId: 'io.flutter.plugins.firebase.crashlytics.example', ); static const FirebaseOptions macos = FirebaseOptions( - apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', - appId: '1:448618578101:ios:3d7b3d90894e689eac3efc', - messagingSenderId: '448618578101', - projectId: 'react-native-firebase-testing', - databaseURL: 'https://react-native-firebase-testing.firebaseio.com', - storageBucket: 'react-native-firebase-testing.appspot.com', + apiKey: 'AIzaSyDooSUGSf63Ghq02_iIhtnmwMDs4HlWS6c', + appId: '1:406099696497:ios:1d042a17c4dd64323574d0', + messagingSenderId: '406099696497', + projectId: 'flutterfire-e2e-tests', + databaseURL: + 'https://flutterfire-e2e-tests-default-rtdb.europe-west1.firebasedatabase.app', + storageBucket: 'flutterfire-e2e-tests.appspot.com', androidClientId: - '448618578101-velutq65ok2dr5ohh0oi1q62irr920ss.apps.googleusercontent.com', + '406099696497-17qn06u8a0dc717u8ul7s49ampk13lul.apps.googleusercontent.com', iosClientId: - '448618578101-54jhd806d0tr4vkgode0b4fi8iruvjpn.apps.googleusercontent.com', - iosBundleId: - 'io.flutter.plugins.firebase.crashlytics.firebaseCrashlyticsExample', + '406099696497-epk7902e2mb4pj4i4gcotk4q7dp2i9h3.apps.googleusercontent.com', + iosBundleId: 'io.flutter.plugins.firebase.crashlytics.example', ); } diff --git a/packages/firebase_crashlytics/firebase_crashlytics/example/lib/main.dart b/packages/firebase_crashlytics/firebase_crashlytics/example/lib/main.dart index 281be9d3357e..78516614521a 100644 --- a/packages/firebase_crashlytics/firebase_crashlytics/example/lib/main.dart +++ b/packages/firebase_crashlytics/firebase_crashlytics/example/lib/main.dart @@ -21,16 +21,20 @@ const _kShouldTestAsyncErrorOnInit = false; const _kTestingCrashlytics = true; Future main() async { - await runZonedGuarded(() async { - WidgetsFlutterBinding.ensureInitialized(); - await Firebase.initializeApp( - options: DefaultFirebaseOptions.currentPlatform, - ); - FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError; - runApp(MyApp()); - }, (error, stackTrace) { - FirebaseCrashlytics.instance.recordError(error, stackTrace); - }); + WidgetsFlutterBinding.ensureInitialized(); + await Firebase.initializeApp( + options: DefaultFirebaseOptions.currentPlatform, + ); + FlutterError.onError = (errorDetails) { + // If you wish to record a "non-fatal" exception, please use `FirebaseCrashlytics.instance.recordFlutterError` instead + FirebaseCrashlytics.instance.recordFlutterFatalError(errorDetails); + }; + PlatformDispatcher.instance.onError = (error, stack) { + // If you wish to record a "non-fatal" exception, please remove the "fatal" parameter + FirebaseCrashlytics.instance.recordError(error, stack, fatal: true); + return true; + }; + runApp(MyApp()); } class MyApp extends StatefulWidget { diff --git a/packages/firebase_crashlytics/firebase_crashlytics/example/macos/Runner.xcodeproj/project.pbxproj b/packages/firebase_crashlytics/firebase_crashlytics/example/macos/Runner.xcodeproj/project.pbxproj index 1cf0a894d900..5183e67a9506 100644 --- a/packages/firebase_crashlytics/firebase_crashlytics/example/macos/Runner.xcodeproj/project.pbxproj +++ b/packages/firebase_crashlytics/firebase_crashlytics/example/macos/Runner.xcodeproj/project.pbxproj @@ -26,6 +26,7 @@ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; + 492007BCB1A0ACAE35BFED17 /* GoogleService-Info.plist in Sources */ = {isa = PBXBuildFile; fileRef = F818CA0E0AA6AA728FD7888E /* GoogleService-Info.plist */; }; A778181074198B5AB83282EB /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6342CA55BF53810F97AF20C /* Pods_Runner.framework */; }; B5515A0723F6830A00F4A798 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B5515A0623F6830A00F4A798 /* GoogleService-Info.plist */; }; /* End PBXBuildFile section */ @@ -75,6 +76,7 @@ B5515A0623F6830A00F4A798 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; D6342CA55BF53810F97AF20C /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; F66FF69A43A7D1A9235BA2DA /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + F818CA0E0AA6AA728FD7888E /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -96,7 +98,6 @@ AD1C0B47B3CC4549F903FB8C /* Pods-Runner.release.xcconfig */, 569624C19DCFE29B888EF618 /* Pods-Runner.profile.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -119,6 +120,7 @@ 33CC10EE2044A3C60003C045 /* Products */, D73912EC22F37F3D000D13A0 /* Frameworks */, 1F66EACC943169C3E49C1DC4 /* Pods */, + F818CA0E0AA6AA728FD7888E /* GoogleService-Info.plist */, ); sourceTree = ""; }; @@ -359,6 +361,7 @@ 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + 492007BCB1A0ACAE35BFED17 /* GoogleService-Info.plist in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -449,6 +452,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); + PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebase.crashlytics.example; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; }; @@ -579,6 +583,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); + PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebase.crashlytics.example; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -603,6 +608,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); + PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebase.crashlytics.example; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; }; diff --git a/packages/firebase_crashlytics/firebase_crashlytics/example/macos/Runner/GoogleService-Info.plist b/packages/firebase_crashlytics/firebase_crashlytics/example/macos/Runner/GoogleService-Info.plist index e6c9fe545762..1da32534601c 100644 --- a/packages/firebase_crashlytics/firebase_crashlytics/example/macos/Runner/GoogleService-Info.plist +++ b/packages/firebase_crashlytics/firebase_crashlytics/example/macos/Runner/GoogleService-Info.plist @@ -7,7 +7,7 @@ REVERSED_CLIENT_ID com.googleusercontent.apps.406099696497-epk7902e2mb4pj4i4gcotk4q7dp2i9h3 ANDROID_CLIENT_ID - 406099696497-tvtvuiqogct1gs1s6lh114jeps7hpjm5.apps.googleusercontent.com + 406099696497-17qn06u8a0dc717u8ul7s49ampk13lul.apps.googleusercontent.com API_KEY AIzaSyDooSUGSf63Ghq02_iIhtnmwMDs4HlWS6c GCM_SENDER_ID diff --git a/packages/firebase_crashlytics/firebase_crashlytics/example/macos/firebase_app_id_file.json b/packages/firebase_crashlytics/firebase_crashlytics/example/macos/firebase_app_id_file.json new file mode 100644 index 000000000000..5a9675ea0399 --- /dev/null +++ b/packages/firebase_crashlytics/firebase_crashlytics/example/macos/firebase_app_id_file.json @@ -0,0 +1,7 @@ +{ + "file_generated_by": "FlutterFire CLI", + "purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory", + "GOOGLE_APP_ID": "1:406099696497:ios:1d042a17c4dd64323574d0", + "FIREBASE_PROJECT_ID": "flutterfire-e2e-tests", + "GCM_SENDER_ID": "406099696497" +} \ No newline at end of file