From 0b8daad9453e35979347f44f55a2a4a2774d9abb Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 6 Jun 2024 23:28:19 +0800 Subject: [PATCH] :heavy_plus_sign: Add firebase --- android/app/build.gradle | 3 + android/app/google-services.json | 29 ++++ android/app/src/main/AndroidManifest.xml | 7 + android/settings.gradle | 3 + firebase.json | 1 + ios/Podfile | 2 +- ios/Podfile.lock | 95 ++++++++++++- ios/Runner.xcodeproj/project.pbxproj | 9 ++ ios/Runner/GoogleService-Info.plist | 30 ++++ ios/Runner/Info.plist | 2 + ios/Runner/Runner.entitlements | 8 ++ lib/firebase_options.dart | 88 ++++++++++++ lib/main.dart | 8 ++ lib/providers/account.dart | 21 +++ lib/providers/auth.dart | 2 + linux/flutter/generated_plugin_registrant.cc | 4 + linux/flutter/generated_plugins.cmake | 1 + macos/Flutter/GeneratedPluginRegistrant.swift | 8 ++ macos/Runner.xcodeproj/project.pbxproj | 4 + macos/Runner/GoogleService-Info.plist | 30 ++++ pubspec.lock | 132 +++++++++++++++++- pubspec.yaml | 3 + .../flutter/generated_plugin_registrant.cc | 6 + windows/flutter/generated_plugins.cmake | 2 + 24 files changed, 490 insertions(+), 8 deletions(-) create mode 100644 android/app/google-services.json create mode 100644 firebase.json create mode 100644 ios/Runner/GoogleService-Info.plist create mode 100644 ios/Runner/Runner.entitlements create mode 100644 lib/firebase_options.dart create mode 100644 macos/Runner/GoogleService-Info.plist diff --git a/android/app/build.gradle b/android/app/build.gradle index 6e32cea..a0d5e6b 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,5 +1,8 @@ plugins { id "com.android.application" + // START: FlutterFire Configuration + id 'com.google.gms.google-services' + // END: FlutterFire Configuration id "kotlin-android" id "dev.flutter.flutter-gradle-plugin" } diff --git a/android/app/google-services.json b/android/app/google-services.json new file mode 100644 index 0000000..8cf7efe --- /dev/null +++ b/android/app/google-services.json @@ -0,0 +1,29 @@ +{ + "project_info": { + "project_number": "961776991058", + "project_id": "solian-0x001", + "storage_bucket": "solian-0x001.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:961776991058:android:a8d3f7995b0b8e86f4188b", + "android_client_info": { + "package_name": "dev.solsynth.solian" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyDvFNudXYs29uDtcCv6pFR8h5tXBs90FYk" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index eeb521c..cfe8185 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -13,6 +13,13 @@ + + + 10.27.0) + - firebase_core (3.0.0): + - Firebase/CoreOnly (= 10.27.0) + - Flutter + - firebase_messaging (15.0.0): + - Firebase/Messaging (= 10.27.0) + - firebase_core + - Flutter + - FirebaseCore (10.27.0): + - FirebaseCoreInternal (~> 10.0) + - GoogleUtilities/Environment (~> 7.12) + - GoogleUtilities/Logger (~> 7.12) + - FirebaseCoreInternal (10.27.0): + - "GoogleUtilities/NSData+zlib (~> 7.8)" + - FirebaseInstallations (10.27.0): + - FirebaseCore (~> 10.0) + - GoogleUtilities/Environment (~> 7.8) + - GoogleUtilities/UserDefaults (~> 7.8) + - PromisesObjC (~> 2.1) + - FirebaseMessaging (10.27.0): + - FirebaseCore (~> 10.0) + - FirebaseInstallations (~> 10.0) + - GoogleDataTransport (~> 9.3) + - GoogleUtilities/AppDelegateSwizzler (~> 7.8) + - GoogleUtilities/Environment (~> 7.8) + - GoogleUtilities/Reachability (~> 7.8) + - GoogleUtilities/UserDefaults (~> 7.8) + - nanopb (< 2.30911.0, >= 2.30908.0) - Flutter (1.0.0) - flutter_local_notifications (0.0.1): - Flutter @@ -46,11 +78,45 @@ PODS: - flutter_webrtc (0.9.36): - Flutter - WebRTC-SDK (= 114.5735.10) + - GoogleDataTransport (9.4.1): + - GoogleUtilities/Environment (~> 7.7) + - nanopb (< 2.30911.0, >= 2.30908.0) + - PromisesObjC (< 3.0, >= 1.2) + - GoogleUtilities/AppDelegateSwizzler (7.13.3): + - GoogleUtilities/Environment + - GoogleUtilities/Logger + - GoogleUtilities/Network + - GoogleUtilities/Privacy + - GoogleUtilities/Environment (7.13.3): + - GoogleUtilities/Privacy + - PromisesObjC (< 3.0, >= 1.2) + - GoogleUtilities/Logger (7.13.3): + - GoogleUtilities/Environment + - GoogleUtilities/Privacy + - GoogleUtilities/Network (7.13.3): + - GoogleUtilities/Logger + - "GoogleUtilities/NSData+zlib" + - GoogleUtilities/Privacy + - GoogleUtilities/Reachability + - "GoogleUtilities/NSData+zlib (7.13.3)": + - GoogleUtilities/Privacy + - GoogleUtilities/Privacy (7.13.3) + - GoogleUtilities/Reachability (7.13.3): + - GoogleUtilities/Logger + - GoogleUtilities/Privacy + - GoogleUtilities/UserDefaults (7.13.3): + - GoogleUtilities/Logger + - GoogleUtilities/Privacy - image_picker_ios (0.0.1): - Flutter - livekit_client (2.1.5): - Flutter - WebRTC-SDK (= 114.5735.10) + - nanopb (2.30910.0): + - nanopb/decode (= 2.30910.0) + - nanopb/encode (= 2.30910.0) + - nanopb/decode (2.30910.0) + - nanopb/encode (2.30910.0) - package_info_plus (0.4.5): - Flutter - path_provider_foundation (0.0.1): @@ -58,6 +124,7 @@ PODS: - FlutterMacOS - permission_handler_apple (9.3.0): - Flutter + - PromisesObjC (2.4.0) - SDWebImage (5.19.2): - SDWebImage/Core (= 5.19.2) - SDWebImage/Core (5.19.2) @@ -83,6 +150,8 @@ DEPENDENCIES: - connectivity_plus (from `.symlinks/plugins/connectivity_plus/darwin`) - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) - file_picker (from `.symlinks/plugins/file_picker/ios`) + - firebase_core (from `.symlinks/plugins/firebase_core/ios`) + - firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`) - Flutter (from `Flutter`) - flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`) - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) @@ -102,6 +171,15 @@ SPEC REPOS: trunk: - DKImagePickerController - DKPhotoGallery + - Firebase + - FirebaseCore + - FirebaseCoreInternal + - FirebaseInstallations + - FirebaseMessaging + - GoogleDataTransport + - GoogleUtilities + - nanopb + - PromisesObjC - SDWebImage - Sentry - SwiftyGif @@ -114,6 +192,10 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/device_info_plus/ios" file_picker: :path: ".symlinks/plugins/file_picker/ios" + firebase_core: + :path: ".symlinks/plugins/firebase_core/ios" + firebase_messaging: + :path: ".symlinks/plugins/firebase_messaging/ios" Flutter: :path: Flutter flutter_local_notifications: @@ -149,15 +231,26 @@ SPEC CHECKSUMS: DKImagePickerController: 946cec48c7873164274ecc4624d19e3da4c1ef3c DKPhotoGallery: b3834fecb755ee09a593d7c9e389d8b5d6deed60 file_picker: 09aa5ec1ab24135ccd7a1621c46c84134bfd6655 + Firebase: 26b040b20866a55f55eb3611b9fcf3ae64816b86 + firebase_core: 5926464bbb028fef87d2443369b73ada2a8a3608 + firebase_messaging: 17bc029302b3342daa1c5905a1ee4258bcf47572 + FirebaseCore: a2b95ae4ce7c83ceecfbbbe3b6f1cddc7415a808 + FirebaseCoreInternal: 4b297a2d56063dbea2c1d0d04222d44a8d058862 + FirebaseInstallations: 766dabca09fd94aef922538aaf144cc4a6fb6869 + FirebaseMessaging: 585984d0a1df120617eb10b44cad8968b859815e Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086 flutter_secure_storage: d33dac7ae2ea08509be337e775f6b59f1ff45f12 flutter_webrtc: b33475c3a57d59ff05bf87b4f5d3feceac63f291 + GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a + GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15 image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1 livekit_client: e6adadd527ee8e52fff579498467ee89921d99f6 + nanopb: 438bc412db1928dac798aa6fd75726007be04262 package_info_plus: 58f0028419748fad15bf008b270aaa8e54380b1c path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2 + PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 SDWebImage: dfe95b2466a9823cf9f0c6d01217c06550d7b29a Sentry: 51b056d96914a741f63eca774d118678b1eb05a1 sentry_flutter: e8397d13e297a5d4b6be8a752e33140b21c5cc97 @@ -168,6 +261,6 @@ SPEC CHECKSUMS: wakelock_plus: 78ec7c5b202cab7761af8e2b2b3d0671be6c4ae1 WebRTC-SDK: 8c0edd05b880a39648118192c252667ea06dea51 -PODFILE CHECKSUM: f9420bd595da8fbce156b547dcd3368afc5226ff +PODFILE CHECKSUM: a57f30d18f102dd3ce366b1d62a55ecbef2158e5 COCOAPODS: 1.15.2 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index d50f68f..22bab02 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -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 */; }; + DA05013449E99A927762ECFB /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7E5383C11873DEAF66E16385 /* GoogleService-Info.plist */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -49,10 +50,12 @@ 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 644CB23863BAC87225224BEB /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 73EB49922C11F3D300A080A2 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; 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 = ""; }; 7507B5B1756DA08A398095AC /* 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 = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 7E5383C11873DEAF66E16385 /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = ""; }; 875B1905BB09FD3E418F83BE /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 8C092932B0B7297947BE9263 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 925B960477E1606F0EF59C87 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; @@ -137,6 +140,7 @@ 331C8082294A63A400263BE5 /* RunnerTests */, 7BA6BD8939A7BE19A2C7086C /* Pods */, 47971B15D8567924545E35C5 /* Frameworks */, + 7E5383C11873DEAF66E16385 /* GoogleService-Info.plist */, ); sourceTree = ""; }; @@ -152,6 +156,7 @@ 97C146F01CF9000F007C117D /* Runner */ = { isa = PBXGroup; children = ( + 73EB49922C11F3D300A080A2 /* Runner.entitlements */, 97C146FA1CF9000F007C117D /* Main.storyboard */, 97C146FD1CF9000F007C117D /* Assets.xcassets */, 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, @@ -264,6 +269,7 @@ 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + DA05013449E99A927762ECFB /* GoogleService-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -487,6 +493,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = W7HPZ53V6B; ENABLE_BITCODE = NO; @@ -673,6 +680,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = W7HPZ53V6B; ENABLE_BITCODE = NO; @@ -696,6 +704,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = W7HPZ53V6B; ENABLE_BITCODE = NO; diff --git a/ios/Runner/GoogleService-Info.plist b/ios/Runner/GoogleService-Info.plist new file mode 100644 index 0000000..66327cf --- /dev/null +++ b/ios/Runner/GoogleService-Info.plist @@ -0,0 +1,30 @@ + + + + + API_KEY + AIzaSyCzQIyiYKoYHTpGXhN-IjgMML8z797WVD8 + GCM_SENDER_ID + 961776991058 + PLIST_VERSION + 1 + BUNDLE_ID + dev.solsynth.solian + PROJECT_ID + solian-0x001 + STORAGE_BUCKET + solian-0x001.appspot.com + IS_ADS_ENABLED + + IS_ANALYTICS_ENABLED + + IS_APPINVITE_ENABLED + + IS_GCM_ENABLED + + IS_SIGNIN_ENABLED + + GOOGLE_APP_ID + 1:961776991058:ios:727229d368cc47e1f4188b + + \ No newline at end of file diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 603c02c..fff2af0 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -2,6 +2,8 @@ + FirebaseMessagingAutoInitEnabled + CADisableMinimumFrameDurationOnPhone CFBundleDevelopmentRegion diff --git a/ios/Runner/Runner.entitlements b/ios/Runner/Runner.entitlements new file mode 100644 index 0000000..903def2 --- /dev/null +++ b/ios/Runner/Runner.entitlements @@ -0,0 +1,8 @@ + + + + + aps-environment + development + + diff --git a/lib/firebase_options.dart b/lib/firebase_options.dart new file mode 100644 index 0000000..c6667f8 --- /dev/null +++ b/lib/firebase_options.dart @@ -0,0 +1,88 @@ +// File generated by FlutterFire CLI. +// ignore_for_file: type=lint +import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; +import 'package:flutter/foundation.dart' + show defaultTargetPlatform, kIsWeb, TargetPlatform; + +/// Default [FirebaseOptions] for use with your Firebase apps. +/// +/// Example: +/// ```dart +/// import 'firebase_options.dart'; +/// // ... +/// await Firebase.initializeApp( +/// options: DefaultFirebaseOptions.currentPlatform, +/// ); +/// ``` +class DefaultFirebaseOptions { + static FirebaseOptions get currentPlatform { + if (kIsWeb) { + return web; + } + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return android; + case TargetPlatform.iOS: + return ios; + case TargetPlatform.macOS: + return macos; + case TargetPlatform.windows: + return windows; + 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.', + ); + } + } + + static const FirebaseOptions web = FirebaseOptions( + apiKey: 'AIzaSyBKfIQpTouj5rXnlzkEieSlbAzepm4mgJE', + appId: '1:961776991058:web:b91d12f2892a5609f4188b', + messagingSenderId: '961776991058', + projectId: 'solian-0x001', + authDomain: 'solian-0x001.firebaseapp.com', + storageBucket: 'solian-0x001.appspot.com', + measurementId: 'G-XY3HHKG0PE', + ); + + static const FirebaseOptions android = FirebaseOptions( + apiKey: 'AIzaSyDvFNudXYs29uDtcCv6pFR8h5tXBs90FYk', + appId: '1:961776991058:android:a8d3f7995b0b8e86f4188b', + messagingSenderId: '961776991058', + projectId: 'solian-0x001', + storageBucket: 'solian-0x001.appspot.com', + ); + + static const FirebaseOptions ios = FirebaseOptions( + apiKey: 'AIzaSyCzQIyiYKoYHTpGXhN-IjgMML8z797WVD8', + appId: '1:961776991058:ios:727229d368cc47e1f4188b', + messagingSenderId: '961776991058', + projectId: 'solian-0x001', + storageBucket: 'solian-0x001.appspot.com', + iosBundleId: 'dev.solsynth.solian', + ); + + static const FirebaseOptions macos = FirebaseOptions( + apiKey: 'AIzaSyCzQIyiYKoYHTpGXhN-IjgMML8z797WVD8', + appId: '1:961776991058:ios:727229d368cc47e1f4188b', + messagingSenderId: '961776991058', + projectId: 'solian-0x001', + storageBucket: 'solian-0x001.appspot.com', + iosBundleId: 'dev.solsynth.solian', + ); + + static const FirebaseOptions windows = FirebaseOptions( + apiKey: 'AIzaSyBKfIQpTouj5rXnlzkEieSlbAzepm4mgJE', + appId: '1:961776991058:web:dcd731c8c5ce1281f4188b', + messagingSenderId: '961776991058', + projectId: 'solian-0x001', + authDomain: 'solian-0x001.firebaseapp.com', + storageBucket: 'solian-0x001.appspot.com', + measurementId: 'G-EF9BZMKBC3', + ); +} diff --git a/lib/main.dart b/lib/main.dart index ff3b76e..d174f11 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,8 @@ +import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; +import 'package:solian/firebase_options.dart'; import 'package:solian/providers/account.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/providers/chat.dart'; @@ -15,6 +17,12 @@ import 'package:solian/theme.dart'; import 'package:solian/translations.dart'; void main() async { + WidgetsFlutterBinding.ensureInitialized(); + + await Firebase.initializeApp( + options: DefaultFirebaseOptions.currentPlatform, + ); + await SentryFlutter.init( (options) { options.dsn = diff --git a/lib/providers/account.dart b/lib/providers/account.dart index 6a8cab2..5c4f03f 100644 --- a/lib/providers/account.dart +++ b/lib/providers/account.dart @@ -2,8 +2,10 @@ import 'dart:convert'; import 'dart:io'; import 'dart:math' as math; +import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:get/get.dart'; import 'package:permission_handler/permission_handler.dart'; +import 'package:platform_device_id/platform_device_id.dart'; import 'package:solian/models/notification.dart'; import 'package:solian/models/packet.dart'; import 'package:solian/models/pagination.dart'; @@ -165,4 +167,23 @@ class AccountProvider extends GetxController { } } } + + Future registerPushNotifications() async { + final AuthProvider auth = Get.find(); + if (!await auth.isAuthorized) throw Exception('unauthorized'); + + final deviceUuid = await PlatformDeviceId.getDeviceId; + final token = await FirebaseMessaging.instance.setAutoInitEnabled(true); + + final client = auth.configureClient(service: 'passport'); + + final resp = await client.post('/api/notifications/subtribe', { + 'provider': 'firebase', + 'device_token': token, + 'device_id': deviceUuid, + }); + if (resp.statusCode != 200) { + throw Exception(resp.bodyString); + } + } } diff --git a/lib/providers/auth.dart b/lib/providers/auth.dart index 192cd92..96a0cd7 100644 --- a/lib/providers/auth.dart +++ b/lib/providers/auth.dart @@ -141,6 +141,8 @@ class AuthProvider extends GetConnect { storage.deleteAll(); } + // Data Layer + Response? _cachedUserProfileResponse; Future get isAuthorized => storage.containsKey(key: 'auth_credentials'); diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index c5ec9f0..583ccac 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -22,6 +23,9 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) flutter_webrtc_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterWebRTCPlugin"); flutter_web_r_t_c_plugin_register_with_registrar(flutter_webrtc_registrar); + g_autoptr(FlPluginRegistrar) platform_device_id_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "PlatformDeviceIdLinuxPlugin"); + platform_device_id_linux_plugin_register_with_registrar(platform_device_id_linux_registrar); g_autoptr(FlPluginRegistrar) sentry_flutter_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "SentryFlutterPlugin"); sentry_flutter_plugin_register_with_registrar(sentry_flutter_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 1faa6d7..534fa8e 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -6,6 +6,7 @@ list(APPEND FLUTTER_PLUGIN_LIST file_selector_linux flutter_secure_storage_linux flutter_webrtc + platform_device_id_linux sentry_flutter url_launcher_linux ) diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index df8a4d0..47d1e94 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -8,12 +8,16 @@ import Foundation import connectivity_plus import device_info_plus import file_selector_macos +import firebase_core +import firebase_messaging import flutter_local_notifications import flutter_secure_storage_macos import flutter_webrtc import livekit_client import package_info_plus import path_provider_foundation +import platform_device_id +import platform_device_id_macos import sentry_flutter import sqflite import url_launcher_macos @@ -24,12 +28,16 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) + FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) + FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin")) FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin")) FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin")) FlutterWebRTCPlugin.register(with: registry.registrar(forPlugin: "FlutterWebRTCPlugin")) LiveKitPlugin.register(with: registry.registrar(forPlugin: "LiveKitPlugin")) FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + PlatformDeviceIdMacosPlugin.register(with: registry.registrar(forPlugin: "PlatformDeviceIdMacosPlugin")) + PlatformDeviceIdMacosPlugin.register(with: registry.registrar(forPlugin: "PlatformDeviceIdMacosPlugin")) SentryFlutterPlugin.register(with: registry.registrar(forPlugin: "SentryFlutterPlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index f5e7931..fefafc4 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -29,6 +29,7 @@ 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; 7EA791CAE9710BE5D384F1BB /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FB45492936527B3666668F /* Pods_RunnerTests.framework */; }; + 82C4BEF1059AD8782ACC8913 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = F5A1F26CD12AC94D82E51EC4 /* GoogleService-Info.plist */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -88,6 +89,7 @@ 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; A9258CF6356D15783726DC84 /* 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 = ""; }; BA5247A2B03173FDFDFCFF93 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; + F5A1F26CD12AC94D82E51EC4 /* 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 */ @@ -151,6 +153,7 @@ 33CC10EE2044A3C60003C045 /* Products */, D73912EC22F37F3D000D13A0 /* Frameworks */, 27286574DE31F9C9A78B355D /* Pods */, + F5A1F26CD12AC94D82E51EC4 /* GoogleService-Info.plist */, ); sourceTree = ""; }; @@ -316,6 +319,7 @@ files = ( 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + 82C4BEF1059AD8782ACC8913 /* GoogleService-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/macos/Runner/GoogleService-Info.plist b/macos/Runner/GoogleService-Info.plist new file mode 100644 index 0000000..66327cf --- /dev/null +++ b/macos/Runner/GoogleService-Info.plist @@ -0,0 +1,30 @@ + + + + + API_KEY + AIzaSyCzQIyiYKoYHTpGXhN-IjgMML8z797WVD8 + GCM_SENDER_ID + 961776991058 + PLIST_VERSION + 1 + BUNDLE_ID + dev.solsynth.solian + PROJECT_ID + solian-0x001 + STORAGE_BUCKET + solian-0x001.appspot.com + IS_ADS_ENABLED + + IS_ANALYTICS_ENABLED + + IS_APPINVITE_ENABLED + + IS_GCM_ENABLED + + IS_SIGNIN_ENABLED + + GOOGLE_APP_ID + 1:961776991058:ios:727229d368cc47e1f4188b + + \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 6d9e129..ec53d79 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _flutterfire_internals: + dependency: transitive + description: + name: _flutterfire_internals + sha256: "13e611501ef36044655852215b4f30aed81123654a4f55193d0051a0e8705658" + url: "https://pub.dev" + source: hosted + version: "1.3.36" archive: dependency: transitive description: @@ -185,6 +193,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.10" + device_info: + dependency: transitive + description: + name: device_info + sha256: f4a8156cb7b7480d969cb734907d18b333c8f0bc0b1ad0b342cdcecf30d62c48 + url: "https://pub.dev" + source: hosted + version: "2.0.3" + device_info_platform_interface: + dependency: transitive + description: + name: device_info_platform_interface + sha256: b148e0bf9640145d09a4f8dea96614076f889e7f7f8b5ecab1c7e5c2dbc73c1b + url: "https://pub.dev" + source: hosted + version: "2.0.1" device_info_plus: dependency: transitive description: @@ -273,6 +297,54 @@ packages: url: "https://pub.dev" source: hosted version: "0.9.3+1" + firebase_core: + dependency: "direct main" + description: + name: firebase_core + sha256: "0d436d29b16fd9844a098ece2a3ce75efc290e5fe0844d282c5e8987173b0d02" + url: "https://pub.dev" + source: hosted + version: "3.0.0" + firebase_core_platform_interface: + dependency: transitive + description: + name: firebase_core_platform_interface + sha256: c437ae5d17e6b5cc7981cf6fd458a5db4d12979905f9aafd1fea930428a9fe63 + url: "https://pub.dev" + source: hosted + version: "5.0.0" + firebase_core_web: + dependency: transitive + description: + name: firebase_core_web + sha256: "22fcb352744908224fc7be3caae254836099786acfe5df6e9fe901e9c2575a41" + url: "https://pub.dev" + source: hosted + version: "2.17.1" + firebase_messaging: + dependency: "direct main" + description: + name: firebase_messaging + sha256: "62fb18daf69ee5f65c0ea5ef4c611481ec50584f54a9d7bcb2de511ad821b45d" + url: "https://pub.dev" + source: hosted + version: "15.0.0" + firebase_messaging_platform_interface: + dependency: transitive + description: + name: firebase_messaging_platform_interface + sha256: aec6972698a5f70557b44946923d6be2c0cda127b60b462a1b1f7f08a8a325a5 + url: "https://pub.dev" + source: hosted + version: "4.5.38" + firebase_messaging_web: + dependency: transitive + description: + name: firebase_messaging_web + sha256: "17979bda5f4474b76c069d547294955e775e3c4484ae80f621a06aa27f5ac5d8" + url: "https://pub.dev" + source: hosted + version: "3.8.8" fixnum: dependency: transitive description: @@ -812,10 +884,10 @@ packages: dependency: transitive description: name: permission_handler_apple - sha256: e9ad66020b89ff1b63908f247c2c6f931c6e62699b756ef8b3c4569350cd8662 + sha256: e6f6d73b12438ef13e648c4ae56bd106ec60d17e90a59c4545db6781229082a0 url: "https://pub.dev" source: hosted - version: "9.4.4" + version: "9.4.5" permission_handler_html: dependency: transitive description: @@ -864,6 +936,54 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.11" + platform_device_id: + dependency: "direct main" + description: + name: platform_device_id + sha256: "7a12ec84de4a823bb10eba2f0e1ad29e2365abba17790489a0d78029904f562e" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + platform_device_id_linux: + dependency: transitive + description: + name: platform_device_id_linux + sha256: "994b1608593e527a629af2d5aeb241c60d308d3434bc78b0f6fcb3c1a02dff43" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + platform_device_id_macos: + dependency: transitive + description: + name: platform_device_id_macos + sha256: "968db2a504c611294b12a031b3734432d6df10553a0d3ae3b33ed21abfdbaba0" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + platform_device_id_platform_interface: + dependency: transitive + description: + name: platform_device_id_platform_interface + sha256: c61607594252aaddacf3e4c4371ab08f2ef85ff427817fa6e48a169429610c46 + url: "https://pub.dev" + source: hosted + version: "1.0.0" + platform_device_id_web: + dependency: transitive + description: + name: platform_device_id_web + sha256: "58e124594e1165db7f108395a780b1d1e1cd403021978e5228cf4289fbe736d5" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + platform_device_id_windows: + dependency: transitive + description: + name: platform_device_id_windows + sha256: dbf8dcf03ad8555320ebae2403a3081b79f137f37661874e161fe2de0a84eeeb + url: "https://pub.dev" + source: hosted + version: "1.0.0" plugin_platform_interface: dependency: transitive description: @@ -1049,10 +1169,10 @@ packages: dependency: "direct main" description: name: url_launcher - sha256: "6ce1e04375be4eed30548f10a315826fd933c1e493206eab82eed01f438c8d2e" + sha256: "21b704ce5fa560ea9f3b525b43601c678728ba46725bab9b01187b4831377ed3" url: "https://pub.dev" source: hosted - version: "6.2.6" + version: "6.3.0" url_launcher_android: dependency: transitive description: @@ -1169,10 +1289,10 @@ packages: dependency: "direct main" description: name: video_player_win - sha256: b99e8dfe7fa87a6732b5c91caef4955ae3453fd6255fb8860a7686beccdcfe43 + sha256: df61a6c271e9b3dbe9bd53c528e35ca6228de2041113a476d1b3f2fa90497ee9 url: "https://pub.dev" source: hosted - version: "2.3.6" + version: "2.3.7" vm_service: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 9826fa1..fbf6cec 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -65,6 +65,9 @@ dependencies: flutter_background: ^1.2.0 cached_network_image: ^3.3.1 sentry_flutter: ^8.2.0 + firebase_core: ^3.0.0 + firebase_messaging: ^15.0.0 + platform_device_id: ^1.0.1 dev_dependencies: flutter_test: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 6d376d6..5d61019 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -8,10 +8,12 @@ #include #include +#include #include #include #include #include +#include #include #include #include @@ -21,6 +23,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); FileSelectorWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("FileSelectorWindows")); + FirebaseCorePluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); FlutterSecureStorageWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin")); FlutterWebRTCPluginRegisterWithRegistrar( @@ -29,6 +33,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("LiveKitPlugin")); PermissionHandlerWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); + PlatformDeviceIdWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("PlatformDeviceIdWindowsPlugin")); SentryFlutterPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("SentryFlutterPlugin")); UrlLauncherWindowsRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index ff41c9d..24c757d 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -5,10 +5,12 @@ list(APPEND FLUTTER_PLUGIN_LIST connectivity_plus file_selector_windows + firebase_core flutter_secure_storage_windows flutter_webrtc livekit_client permission_handler_windows + platform_device_id_windows sentry_flutter url_launcher_windows video_player_win