From d32fd2a48556b8c55ddb9dccbff8b545e1f45d31 Mon Sep 17 00:00:00 2001 From: 3003h Date: Fri, 3 Nov 2023 23:05:45 +0800 Subject: [PATCH] add filebase --- .gitattributes | 5 +- .gitignore | 12 +-- README.md | 3 +- README_cn.md | 6 +- android/app/build.gradle | 4 + android/app/google-services.json | Bin 0 -> 1273 bytes android/build.gradle | 4 + ios/Runner.xcodeproj/project.pbxproj | 34 ++++++++- ios/Runner/GoogleService-Info.plist | Bin 0 -> 1122 bytes ios/firebase_app_id_file.json | Bin 0 -> 287 bytes lib/common/global.dart | 7 ++ lib/firebase_options.dart | Bin 0 -> 2518 bytes lib/firebase_options_sample.dart | 10 +++ lib/main.dart | 27 ++++++- macos/Flutter/GeneratedPluginRegistrant.swift | 6 ++ pubspec.lock | 72 ++++++++++++++++++ pubspec.yaml | 2 + .../flutter/generated_plugin_registrant.cc | 3 + windows/flutter/generated_plugins.cmake | 1 + 19 files changed, 180 insertions(+), 16 deletions(-) create mode 100644 android/app/google-services.json create mode 100644 ios/Runner/GoogleService-Info.plist create mode 100644 ios/firebase_app_id_file.json create mode 100644 lib/firebase_options.dart create mode 100644 lib/firebase_options_sample.dart diff --git a/.gitattributes b/.gitattributes index abc8d1511..92e6d9dae 100644 --- a/.gitattributes +++ b/.gitattributes @@ -38,5 +38,8 @@ GoogleService-Info.plist filter=git-crypt diff=git-crypt binary google-service.json filter=git-crypt diff=git-crypt binary +google-services.json filter=git-crypt diff=git-crypt binary +firebase_app_id_file.json filter=git-crypt diff=git-crypt binary +/lib/firebase_options.dart filter=git-crypt diff=git-crypt binary +/lib/config/config.dart filter=git-crypt diff=git-crypt binary /lib/firebase_options.dart filter=git-crypt diff=git-crypt binary -/lib/config/config.dart filter=git-crypt diff=git-crypt binary \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5c72323be..2a457d671 100644 --- a/.gitignore +++ b/.gitignore @@ -43,9 +43,9 @@ app.*.map.json # Exceptions to above rules. /packages/flutter_tools/test/data/dart_dependencies_test/**/.packages /ios/build/ -/ios/Runner/GoogleService-Info.plist -/ios/firebase_app_id_file.json -/android/app/google-services.json +#/ios/Runner/GoogleService-Info.plist +#/ios/firebase_app_id_file.json +#/android/app/google-services.json /android/app/asd.json #*.g.dart @@ -57,9 +57,9 @@ app.*.map.json /assets/openl.json /assets/sentry.json -GoogleService-Info.plist -google-service.json -/lib/firebase_options.dart +#GoogleService-Info.plist +#google-service.json +#/lib/firebase_options.dart android/app/keystore.jks #/pubspec.lock diff --git a/README.md b/README.md index 0c3e8ecaf..aaa8b1e89 100644 --- a/README.md +++ b/README.md @@ -91,4 +91,5 @@ Translation ## About compiling flutter version is the latest release version \ -rename `/lib/config/config.dart.sample` to `/lib/config/config.dart` +rename `lib/config/config.dart.sample` to `lib/config/config.dart` \ +rename `lib/firebase_options_sample.dart` to `lib/firebase_options.dart` diff --git a/README_cn.md b/README_cn.md index 68f606335..5aa89fdbd 100644 --- a/README_cn.md +++ b/README_cn.md @@ -96,6 +96,6 @@ ehentai译文数据库 ## 编译相关 -flutter版本为最新release版本 \ -`/lib/config/config.dart` 文件为存放敏感信息数据的文件,github里看到是加密处理的 \ -如果需要自行编译的话,复制 `/lib/config.dart.sample` 为 `/lib/config/config.dart` 进行操作 +如果需要自行编译的话 \ +复制 `lib/config.dart.sample` 为 `lib/config/config.dart` \ +复制 `lib/firebase_options_sample.dart` 为 `lib/firebase_options.dart` diff --git a/android/app/build.gradle b/android/app/build.gradle index 6804e0ddb..0bd95f760 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -35,6 +35,10 @@ def _storeFile = file(System.getenv("KEYSTORE") ?: keystoreProperties.getPropert def _storePassword = System.getenv("KEYSTORE_PASSWORD") ?: keystoreProperties.getProperty("storePassword") apply plugin: 'com.android.application' +// START: FlutterFire Configuration +apply plugin: 'com.google.gms.google-services' +apply plugin: 'com.google.firebase.crashlytics' +// END: FlutterFire Configuration apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" diff --git a/android/app/google-services.json b/android/app/google-services.json new file mode 100644 index 0000000000000000000000000000000000000000..bd7ad880c323d51bcb4f178cbce0c1ed1b221c59 GIT binary patch literal 1273 zcmVn-mD zhPN-uL(`m69Vtv&er53-|C1STyPK6mfO3ax3od?}c51tm*s4CUMo`N(SW31tZ@#c*6E$GTfX@}#EAoqGV2;EW8is@}? z)J>xqop9tx)W3R=Lc_!nX{;unM#=Y58PPo$P?t?Q82*)+Wf%shM(;_#2ah#-^g}yH z{)acbLPc|e9}fce49eWG=8?p3I~M90G$9?cNpI#Zj2olk&y=n7-~;;EsFaozEXp=- z@lGzOK3THoUM#THyN-w)<-Aw-;9#@wT*sU+esCl$M9d72hWfQSpHBWAZZlzDi_Fy1 z_}b;P&>~VL!IBmg2v!muuZhLPV$`8-b}^NBw@k*!%-)Jt-pA-?IaNWjf;#cP;+=u& zxh*A>S6NI%gd6vwZ=hU5{2yfAx<4)#I>L3`{n|dI9t1H%J|~f|QO1B62eY*Uop0L< zWttoH%?-u-dNuE9{|?4Yn{?*a^0mWKtq#R0oHQQvQ=wpBKhK`6oU&o$ac8>Wk475R z0C9|{vp>6j50qEi38FeF!NH6j2kzonZr1cMdx=2vf#YqhXzH5D=+Saq>)*AJhiqv@U2V0js&-Fg8T_6*=TH$H z-djT;pFMq3mX)|3dbhE`4CSHRB3BG#H_@VP%tBnHf;hF->1tgL@fGB2PLq@WQkBBP z+wH_YG~q2>xNK`?ZO-=Jgxuid>?k>aW1SkyzCoyVa-FiK=Z()2S@qrG?~Eo+mqFk< zkdsHFzW&J%msmUw@s-HTUFIa+Dk|^yYUgP}bjo>Jn{Py-a-W?fezcIY_p1(}U$E4P zB-=CtC&U1l>Dj|5ptqCAqPD^n1qyt<@rW4P#=r2e4S($*gfP^HvoJMKoncbqKnh(> zZHacqviw7RDL3+PIFRg&y>%z7miF0K-+h(ln;#KR32c*^4rJHr{dMAbU=qBp#gS53 z^5=GRWzn4d`dmG=jH!L7{V%sf6a@QyG=H%J#C;xg z!Alalp+VQxucxQCEUD76CK4@XHUCrX@?!`uv?+jJgLHI52;dthSB z5Hrc!1s@va3wvof5mdOKk*|-P*S=mt_xmg)Z(61vl{QHq5N(1YuuMO2-uiM+G0T2h z-=W+wUDs3SpLXCZ=etzjLMRdRlPbx~je)ZHF-tE#Pm|F+-uzhum4UkyN(_u(;tyXT zPa)r%Z-L&j5m}p&Xbc?D`_b}s#!(va8Xcu)KN!!HVS zuaZI;0<{7n5VdE0+IhQJjbs&dK!ZG=WUslulOhLcN?^qmzOu?x>z=c=y}0>|Efx0Z z+myT8pJ5e~zAKdQz)zkf5@PR)39R&-id-OQY5c>J0&(}-rnyEe!5Lf4i3-7>jE6K% j7n_3DCOq78lpLnPn`*NMqf1XXCZ6?tE>1N`_6@^PM4Eq0 literal 0 HcmV?d00001 diff --git a/android/build.gradle b/android/build.gradle index 3f423ed91..c474ae182 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -10,6 +10,10 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:7.4.2' + // START: FlutterFire Configuration + classpath 'com.google.gms:google-services:4.3.14' + classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1' + // END: FlutterFire Configuration classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index c9deedd31..0d754dfa1 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; BA373B2925D2A11600C042FA /* SecurityBlurEffect.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA373B2825D2A11600C042FA /* SecurityBlurEffect.swift */; }; + BFED4257903270F2E29ACBB6 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 76AED4914C4C6C44220F53A2 /* GoogleService-Info.plist */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -49,6 +50,7 @@ 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 76AED4914C4C6C44220F53A2 /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 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 = ""; }; @@ -116,6 +118,7 @@ BD2B51B0799E31FC8C88C126 /* Pods */, 8E17D831CCF214C421795E99 /* Frameworks */, BA3ACC1B286B687300C23A87 /* fehviewer.app */, + 76AED4914C4C6C44220F53A2 /* GoogleService-Info.plist */, ); sourceTree = ""; wrapsLines = 0; @@ -173,6 +176,7 @@ 3B06AD1E1E4923F5004D2608 /* Thin Binary */, BA0498CA2553F1EA008DE488 /* Embed App Extensions */, 95CD7AC50C01DD7235DDE61E /* [CP] Embed Pods Frameworks */, + F7742035D917A11792ED261A /* [firebase_crashlytics] Crashlytics Upload Symbols */, ); buildRules = ( ); @@ -230,6 +234,7 @@ 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + BFED4257903270F2E29ACBB6 /* GoogleService-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -306,6 +311,29 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + F7742035D917A11792ED261A /* [firebase_crashlytics] Crashlytics Upload Symbols */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}\"", + "\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/\"", + "\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist\"", + "\"$(TARGET_BUILD_DIR)/$(EXECUTABLE_PATH)\"", + "\"$(PROJECT_DIR)/firebase_app_id_file.json\"", + ); + name = "[firebase_crashlytics] Crashlytics Upload Symbols"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$PODS_ROOT/FirebaseCrashlytics/upload-symbols\" --flutter-project \"$PROJECT_DIR/firebase_app_id_file.json\" "; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -439,7 +467,7 @@ "$(PROJECT_DIR)/Flutter", ); MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)"; - PRODUCT_BUNDLE_IDENTIFIER = dev2.cn.honjow.fehv; + PRODUCT_BUNDLE_IDENTIFIER = cn.honjow.fehv; PRODUCT_NAME = fehviewer; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -588,7 +616,7 @@ "$(PROJECT_DIR)/Flutter", ); MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)"; - PRODUCT_BUNDLE_IDENTIFIER = dev2.cn.honjow.fehv; + PRODUCT_BUNDLE_IDENTIFIER = cn.honjow.fehv; PRODUCT_NAME = fehviewer; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -627,7 +655,7 @@ "$(PROJECT_DIR)/Flutter", ); MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)"; - PRODUCT_BUNDLE_IDENTIFIER = dev2.cn.honjow.fehv; + PRODUCT_BUNDLE_IDENTIFIER = cn.honjow.fehv; PRODUCT_NAME = fehviewer; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/ios/Runner/GoogleService-Info.plist b/ios/Runner/GoogleService-Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..3aad857511c1496fc3f46d859fab1379e8c1881d GIT binary patch literal 1122 zcmV-o1fBZ;M@dveQdv+`02t1qbk5A5Ny1n}m=TT?B)+IGcG}7><`^Il1oz9bmL{bG zCv2hwcIJElX#TMk(0qdW`>ItF`~bIVQ5&muR^#fJ_CdZg2v~c40pNOYi-70tv;qgv z6a;iiV40*aI?erOFrA#?RXoe;or~e8zP(IKSnPQQo|XTj&BlXH)C#R>^ynG(xur5v zV1W!PI^y0*)EZ~V2jV(WWmuOOVjj|5$Iaa^?mAhaHl9F5A|G}?2Ns&#;gX0upLm_T zf^Ak%YO{rMY^NMbxAOIKab{orjtm4BX?)InX4#;ndMrxgM)@*+GpdozpVz0xX38|j z@GIxs=~+3Fqkt8M^39`5wCEJ-;DJ5k8^oN~mhIAhS-ol;nz_MUWK%3y_3hc)NaJJZ zL^mQr$LPT0&Bywjz7S8@6T41~%5?Q%jA=O_G_B-ie6@i^{O?s0x0m?5bnEfiGB3C^ zV`(c`>#DPiq%Ueqk{ImImAqs!U@ae@7QMcxoys6e^S-spCdSaaX_3>H-n*Z`3PZHj)kE%QRb5{guH0o!Iy8`cTFBlJhXgTL=>=?9>cZ$*?_Yly{xQC9&vch(& zB<};RGuTTRrUN%=#u&w87Z6X1JDToHGD;$jQOR7tko4($GQfYMZy{zL>%WiFIj)HBLtmj%a3Xah zsnlaFpxg0T+iq3GZ_qaa|D@T0BTex@>o(@zT!M-w5&AQ5n)P`tY9X3~Ie5P8*Xcir zh@VEur-g8bs;6|Rt9XGH`!7OLgW422N>noa{}-{4l2tpb z3|yyC`;LEjTpr7Ep~~7XCRM2=hCutt<@Zo-wBeM2q9N>staXNCh}`tw6<=o1J2V`= zPEFY`xQkOa>!aETQ#VI%d+7tSU*+li1f`l!cd1qEn4Bq(2K=UP4ii o%jFf@QAP3gml;u4ICWZZr2jYyUIyo6h2biEz&8Um<#J`0X?BG?3IG5A literal 0 HcmV?d00001 diff --git a/ios/firebase_app_id_file.json b/ios/firebase_app_id_file.json new file mode 100644 index 0000000000000000000000000000000000000000..df49114e74dec156529a316d144aa60d5e314f72 GIT binary patch literal 287 zcmV+)0pR`sM@dveQdv+`04>!5zP1e@Dwk6fY=3Cqlib4++?w-p~ET4V3$pl-!Dl8k*X z7M8nBh(VE%)QW(%ji^3YJD8c8fX5uIB=A^xFX5BlvA{m-x&o#E3pDefh9RcJ#w8^P znJTg)xC$Q%_DEiV&Op!`I8p^TLPp08_gEiA-oatM!jj9bv_oD9&|N04lKwlk)&L)B lXZe$lv#F#RAQwDIdU0psvu6iM;1O8q+CMSdvbDzDnWQo-i1h#f literal 0 HcmV?d00001 diff --git a/lib/common/global.dart b/lib/common/global.dart index 7e8382089..5db76719a 100644 --- a/lib/common/global.dart +++ b/lib/common/global.dart @@ -16,6 +16,8 @@ import 'package:fehviewer/store/hive/hive.dart'; import 'package:fehviewer/store/hive/hive_cache.dart'; import 'package:fehviewer/utils/http_override.dart'; import 'package:fehviewer/utils/storage.dart'; +import 'package:firebase_analytics/firebase_analytics.dart'; +import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:flutter_downloader/flutter_downloader.dart'; @@ -107,10 +109,15 @@ class Global { static bool canCheckBiometrics = false; + static bool enableFirebase = false; + User get user => profile.user; set user(User val) => profile = profile.copyWith(user: val); + static FirebaseApp? firebaseApp; + static FirebaseAnalytics? analytics; + // init static Future init() async { // 判断是否debug模式 diff --git a/lib/firebase_options.dart b/lib/firebase_options.dart new file mode 100644 index 0000000000000000000000000000000000000000..46a89e7d7abe4ca1b0e1256d0f2b9fa4c7c2b170 GIT binary patch literal 2518 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 literal 0 HcmV?d00001 diff --git a/lib/firebase_options_sample.dart b/lib/firebase_options_sample.dart new file mode 100644 index 000000000..36e84e375 --- /dev/null +++ b/lib/firebase_options_sample.dart @@ -0,0 +1,10 @@ +import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; + +class DefaultFirebaseOptions { + static FirebaseOptions get currentPlatform => const FirebaseOptions( + apiKey: '', + appId: '', + messagingSenderId: '', + projectId: '', + ); +} diff --git a/lib/main.dart b/lib/main.dart index 8584dadf3..7b7b509e9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -10,6 +10,9 @@ import 'package:fehviewer/common/service/theme_service.dart'; import 'package:fehviewer/fehviewer.dart'; import 'package:fehviewer/store/get_store.dart'; import 'package:fehviewer/widget/system_ui_overlay.dart'; +import 'package:firebase_analytics/firebase_analytics.dart'; +import 'package:firebase_core/firebase_core.dart'; +import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; @@ -19,6 +22,7 @@ import 'package:logger/logger.dart'; import 'package:oktoast/oktoast.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; +import 'firebase_options_sample.dart' as fo; import 'get_init.dart'; import 'widget/desktop.dart'; @@ -28,6 +32,17 @@ Future main() async { WidgetsFlutterBinding.ensureInitialized(); final dsn = await getSentryDsn(); + Global.enableFirebase = + fo.DefaultFirebaseOptions.currentPlatform.apiKey.isNotEmpty; + + if (Global.enableFirebase) { + final FirebaseApp firebaseApp = await Firebase.initializeApp( + options: fo.DefaultFirebaseOptions.currentPlatform, + ); + Global.firebaseApp = firebaseApp; + Global.analytics = FirebaseAnalytics.instanceFor(app: firebaseApp); + } + Get.lazyPut(() => LogService(), fenix: true); Get.lazyPut(() => GStore()); await Global.init(); @@ -43,6 +58,14 @@ Future main() async { resetLogLevel(); updateTagTranslate(); + if (Global.enableFirebase) { + FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError; + PlatformDispatcher.instance.onError = (error, stack) { + FirebaseCrashlytics.instance.recordError(error, stack, fatal: true); + return true; + }; + } + if (dsn != null && dsn.isNotEmpty) { await SentryFlutter.init( (SentryFlutterOptions options) { @@ -149,8 +172,8 @@ class _MyAppState extends State with WidgetsBindingObserver { debugShowCheckedModeBanner: false, onGenerateTitle: (BuildContext context) => L10n.of(context).app_title, navigatorObservers: [ - // if (GetPlatform.isMobile) - // FirebaseAnalyticsObserver(analytics: analytics), + if (GetPlatform.isMobile && Global.analytics != null) + FirebaseAnalyticsObserver(analytics: Global.analytics!), SentryNavigatorObserver(), FlutterSmartDialog.observer, MainNavigatorObserver(), diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index bc38db8b2..e95427652 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,6 +7,9 @@ import Foundation import bitsdojo_window_macos import device_info_plus +import firebase_analytics +import firebase_core +import firebase_crashlytics import isar_flutter_libs import package_info import package_info_plus @@ -22,6 +25,9 @@ import window_size func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { BitsdojoWindowPlugin.register(with: registry.registrar(forPlugin: "BitsdojoWindowPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) + FLTFirebaseAnalyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAnalyticsPlugin")) + FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) + FLTFirebaseCrashlyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCrashlyticsPlugin")) IsarFlutterLibsPlugin.register(with: registry.registrar(forPlugin: "IsarFlutterLibsPlugin")) FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin")) FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) diff --git a/pubspec.lock b/pubspec.lock index 31aef575f..0697a0973 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -9,6 +9,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "61.0.0" + _flutterfire_internals: + dependency: transitive + description: + name: _flutterfire_internals + sha256: "5dadadeecceac19d6a63c9d2e037bb8df58ddd4aedb94e8a056af2f39ee50f9d" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.11" analyzer: dependency: transitive description: @@ -610,6 +618,70 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "6.0.0" + firebase_analytics: + dependency: "direct main" + description: + name: firebase_analytics + sha256: fb8c29d97d29aed258d2fd98ba0ffc04ccca2c7b830b149187679524757f5d9d + url: "https://pub.flutter-io.cn" + source: hosted + version: "10.6.3" + firebase_analytics_platform_interface: + dependency: transitive + description: + name: firebase_analytics_platform_interface + sha256: "85fe94377732a168896a705410441b721a49c0703679c24e3edca0c680a45bb7" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.7.5" + firebase_analytics_web: + dependency: transitive + description: + name: firebase_analytics_web + sha256: "99a39a97e4760011ca0f2135c68a40f65dc9b260a0c27db2fdcb1258052c588b" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.5.5+5" + firebase_core: + dependency: transitive + description: + name: firebase_core + sha256: "7706f4ade6cc2698c70074083bc262586a185047f6bfdd53938dcc35d35cbb9e" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.21.0" + firebase_core_platform_interface: + dependency: transitive + description: + name: firebase_core_platform_interface + sha256: c437ae5d17e6b5cc7981cf6fd458a5db4d12979905f9aafd1fea930428a9fe63 + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.0.0" + firebase_core_web: + dependency: transitive + description: + name: firebase_core_web + sha256: "0631a2ec971dbc540275e2fa00c3a8a2676f0a7adbc3c197d6fba569db689d97" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.8.1" + firebase_crashlytics: + dependency: "direct main" + description: + name: firebase_crashlytics + sha256: c1f6b7a75df5f83af187b396d763de0e7673fcb358093e04be68e82e6d80d41a + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.4.3" + firebase_crashlytics_platform_interface: + dependency: transitive + description: + name: firebase_crashlytics_platform_interface + sha256: "08f0a3a99a12a31a47a08ccb268efe163c2f0d89fec74eb5b8a86b219611175c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.6.11" fixnum: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index cb076261c..b82fd8bba 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -186,6 +186,8 @@ dependencies: flutter_widget_from_html_core: ^0.14.4 quiver: ^3.1.0 # 工具库 native_dio_adapter: ^1.0.0+2 + firebase_analytics: ^10.6.3 + firebase_crashlytics: ^3.4.3 dev_dependencies: # flutter pub run build_runner build --delete-conflicting-outputs diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 151aca32c..81bdc0f53 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,6 +7,7 @@ #include "generated_plugin_registrant.h" #include +#include #include #include #include @@ -18,6 +19,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { BitsdojoWindowPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("BitsdojoWindowPlugin")); + FirebaseCorePluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); IsarFlutterLibsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("IsarFlutterLibsPlugin")); LocalAuthPluginRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 6e7d68d41..1e8ddda81 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -4,6 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST bitsdojo_window_windows + firebase_core isar_flutter_libs local_auth_windows permission_handler_windows