From 777043e2ca0b4692facaa0f683d384825562dab5 Mon Sep 17 00:00:00 2001 From: Yasien Mac Mini Date: Wed, 10 Dec 2025 10:18:57 +0200 Subject: [PATCH] NEW: Config firebase Cloud Messaging for Notifications --- Frontend/android/app/build.gradle.kts | 3 + Frontend/android/app/google-services.json | 29 ++++++ Frontend/android/settings.gradle.kts | 3 + Frontend/firebase.json | 1 + Frontend/ios/Runner.xcodeproj/project.pbxproj | 4 + Frontend/ios/Runner/GoogleService-Info.plist | 30 +++++++ Frontend/lib/firebase_options.dart | 88 +++++++++++++++++++ Frontend/lib/main_dev.dart | 5 ++ Frontend/lib/main_prod.dart | 9 +- .../macos/Runner.xcodeproj/project.pbxproj | 6 +- .../macos/Runner/GoogleService-Info.plist | 30 +++++++ Frontend/pubspec.lock | 2 +- Frontend/pubspec.yaml | 1 + 13 files changed, 208 insertions(+), 3 deletions(-) create mode 100644 Frontend/android/app/google-services.json create mode 100644 Frontend/firebase.json create mode 100644 Frontend/ios/Runner/GoogleService-Info.plist create mode 100644 Frontend/lib/firebase_options.dart create mode 100644 Frontend/macos/Runner/GoogleService-Info.plist diff --git a/Frontend/android/app/build.gradle.kts b/Frontend/android/app/build.gradle.kts index c96f5437..0aea73ef 100644 --- a/Frontend/android/app/build.gradle.kts +++ b/Frontend/android/app/build.gradle.kts @@ -3,6 +3,9 @@ import java.io.FileInputStream plugins { id("com.android.application") + // START: FlutterFire Configuration + id("com.google.gms.google-services") + // END: FlutterFire Configuration id("kotlin-android") // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id("dev.flutter.flutter-gradle-plugin") diff --git a/Frontend/android/app/google-services.json b/Frontend/android/app/google-services.json new file mode 100644 index 00000000..4f9479a5 --- /dev/null +++ b/Frontend/android/app/google-services.json @@ -0,0 +1,29 @@ +{ + "project_info": { + "project_number": "33677883408", + "project_id": "mzansi-innovation-hub", + "storage_bucket": "mzansi-innovation-hub.firebasestorage.app" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:33677883408:android:ebd8565991c56257223295", + "android_client_info": { + "package_name": "za.co.mzansiinnovationhub.mih" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyBUkjWdu9YcgiF-e9TC5hoiEoCjPyjA5hU" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/Frontend/android/settings.gradle.kts b/Frontend/android/settings.gradle.kts index ab39a10a..bd7522f7 100644 --- a/Frontend/android/settings.gradle.kts +++ b/Frontend/android/settings.gradle.kts @@ -19,6 +19,9 @@ pluginManagement { plugins { id("dev.flutter.flutter-plugin-loader") version "1.0.0" id("com.android.application") version "8.7.3" apply false + // START: FlutterFire Configuration + id("com.google.gms.google-services") version("4.3.15") apply false + // END: FlutterFire Configuration id("org.jetbrains.kotlin.android") version "2.1.0" apply false } diff --git a/Frontend/firebase.json b/Frontend/firebase.json new file mode 100644 index 00000000..d3d23465 --- /dev/null +++ b/Frontend/firebase.json @@ -0,0 +1 @@ +{"flutter":{"platforms":{"android":{"default":{"projectId":"mzansi-innovation-hub","appId":"1:33677883408:android:ebd8565991c56257223295","fileOutput":"android/app/google-services.json"}},"ios":{"default":{"projectId":"mzansi-innovation-hub","appId":"1:33677883408:ios:2048dac086428716223295","uploadDebugSymbols":false,"fileOutput":"ios/Runner/GoogleService-Info.plist"}},"macos":{"default":{"projectId":"mzansi-innovation-hub","appId":"1:33677883408:ios:e2db11a42fc3452e223295","uploadDebugSymbols":false,"fileOutput":"macos/Runner/GoogleService-Info.plist"}},"dart":{"lib/firebase_options.dart":{"projectId":"mzansi-innovation-hub","configurations":{"android":"1:33677883408:android:ebd8565991c56257223295","ios":"1:33677883408:ios:2048dac086428716223295","macos":"1:33677883408:ios:e2db11a42fc3452e223295","web":"1:33677883408:web:47b8021df7fcacd2223295","windows":"1:33677883408:web:e08becaef3261c59223295"}}}}}} \ No newline at end of file diff --git a/Frontend/ios/Runner.xcodeproj/project.pbxproj b/Frontend/ios/Runner.xcodeproj/project.pbxproj index 17117b47..d8dfea8d 100644 --- a/Frontend/ios/Runner.xcodeproj/project.pbxproj +++ b/Frontend/ios/Runner.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 71E3C54FEF20104FD7A5C7E5 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 277EDD110F2042FAAC4E5333 /* Pods_Runner.framework */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 75DB4569FB42001E83B22FC4 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 486D5A0EDC898EC440394271 /* GoogleService-Info.plist */; }; 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 */; }; @@ -52,6 +53,7 @@ 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 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 = ""; }; + 486D5A0EDC898EC440394271 /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = ""; }; 523DAF296A6B559B71F587AF /* 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 = ""; }; 52DEBFF4174C303DD5BF01CA /* 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 = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; @@ -138,6 +140,7 @@ 331C8082294A63A400263BE5 /* RunnerTests */, 7241FE2A1582C644953298C9 /* Pods */, 7A61115B6A9E6DA8069C4DD9 /* Frameworks */, + 486D5A0EDC898EC440394271 /* GoogleService-Info.plist */, ); sourceTree = ""; }; @@ -266,6 +269,7 @@ 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + 75DB4569FB42001E83B22FC4 /* GoogleService-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Frontend/ios/Runner/GoogleService-Info.plist b/Frontend/ios/Runner/GoogleService-Info.plist new file mode 100644 index 00000000..afac0e1e --- /dev/null +++ b/Frontend/ios/Runner/GoogleService-Info.plist @@ -0,0 +1,30 @@ + + + + + API_KEY + AIzaSyDRqY5I5CXjEtWkUX1YUfKT8IUlln9PUuY + GCM_SENDER_ID + 33677883408 + PLIST_VERSION + 1 + BUNDLE_ID + za.co.mzansiinnovationhub.mih + PROJECT_ID + mzansi-innovation-hub + STORAGE_BUCKET + mzansi-innovation-hub.firebasestorage.app + IS_ADS_ENABLED + + IS_ANALYTICS_ENABLED + + IS_APPINVITE_ENABLED + + IS_GCM_ENABLED + + IS_SIGNIN_ENABLED + + GOOGLE_APP_ID + 1:33677883408:ios:2048dac086428716223295 + + \ No newline at end of file diff --git a/Frontend/lib/firebase_options.dart b/Frontend/lib/firebase_options.dart new file mode 100644 index 00000000..648849ea --- /dev/null +++ b/Frontend/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: 'AIzaSyDN-f4sJ4n_fyvrLR193_IIkTsccRVUQxw', + appId: '1:33677883408:web:47b8021df7fcacd2223295', + messagingSenderId: '33677883408', + projectId: 'mzansi-innovation-hub', + authDomain: 'mzansi-innovation-hub.firebaseapp.com', + storageBucket: 'mzansi-innovation-hub.firebasestorage.app', + measurementId: 'G-Y3B5E3HCJY', + ); + + static const FirebaseOptions android = FirebaseOptions( + apiKey: 'AIzaSyBUkjWdu9YcgiF-e9TC5hoiEoCjPyjA5hU', + appId: '1:33677883408:android:ebd8565991c56257223295', + messagingSenderId: '33677883408', + projectId: 'mzansi-innovation-hub', + storageBucket: 'mzansi-innovation-hub.firebasestorage.app', + ); + + static const FirebaseOptions ios = FirebaseOptions( + apiKey: 'AIzaSyDRqY5I5CXjEtWkUX1YUfKT8IUlln9PUuY', + appId: '1:33677883408:ios:2048dac086428716223295', + messagingSenderId: '33677883408', + projectId: 'mzansi-innovation-hub', + storageBucket: 'mzansi-innovation-hub.firebasestorage.app', + iosBundleId: 'za.co.mzansiinnovationhub.mih', + ); + + static const FirebaseOptions macos = FirebaseOptions( + apiKey: 'AIzaSyDRqY5I5CXjEtWkUX1YUfKT8IUlln9PUuY', + appId: '1:33677883408:ios:e2db11a42fc3452e223295', + messagingSenderId: '33677883408', + projectId: 'mzansi-innovation-hub', + storageBucket: 'mzansi-innovation-hub.firebasestorage.app', + iosBundleId: 'com.example.patientManager', + ); + + static const FirebaseOptions windows = FirebaseOptions( + apiKey: 'AIzaSyDN-f4sJ4n_fyvrLR193_IIkTsccRVUQxw', + appId: '1:33677883408:web:e08becaef3261c59223295', + messagingSenderId: '33677883408', + projectId: 'mzansi-innovation-hub', + authDomain: 'mzansi-innovation-hub.firebaseapp.com', + storageBucket: 'mzansi-innovation-hub.firebasestorage.app', + measurementId: 'G-FKKENBX8TT', + ); +} diff --git a/Frontend/lib/main_dev.dart b/Frontend/lib/main_dev.dart index c0bd70f0..a510d6c3 100644 --- a/Frontend/lib/main_dev.dart +++ b/Frontend/lib/main_dev.dart @@ -1,3 +1,4 @@ +import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_native_splash/flutter_native_splash.dart'; @@ -5,6 +6,7 @@ import 'package:flutter_web_plugins/url_strategy.dart' if (dart.library.html) 'package:flutter_web_plugins/url_strategy.dart'; import 'package:go_router/go_router.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; +import 'package:mzansi_innovation_hub/firebase_options.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_go_router.dart'; import 'package:pwa_install/pwa_install.dart'; @@ -19,6 +21,9 @@ void main() async { apiDomain: AppEnviroment.baseApiUrl, apiBasePath: "/auth", ); + await Firebase.initializeApp( + options: DefaultFirebaseOptions.currentPlatform, + ); if (!kIsWeb) { const List testDeviceIds = ['733d4c68-9b54-453a-9622-2df407310f40']; MobileAds.instance.updateRequestConfiguration( diff --git a/Frontend/lib/main_prod.dart b/Frontend/lib/main_prod.dart index 2facd8be..c305d522 100644 --- a/Frontend/lib/main_prod.dart +++ b/Frontend/lib/main_prod.dart @@ -1,3 +1,4 @@ +import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_native_splash/flutter_native_splash.dart'; @@ -5,6 +6,7 @@ import 'package:flutter_web_plugins/url_strategy.dart' if (dart.library.html) 'package:flutter_web_plugins/url_strategy.dart'; import 'package:go_router/go_router.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; +import 'package:mzansi_innovation_hub/firebase_options.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_go_router.dart'; import 'package:pwa_install/pwa_install.dart'; @@ -19,6 +21,9 @@ void main() async { apiDomain: AppEnviroment.baseApiUrl, apiBasePath: "/auth", ); + await Firebase.initializeApp( + options: DefaultFirebaseOptions.currentPlatform, + ); if (!kIsWeb) { MobileAds.instance.initialize(); } else { @@ -29,5 +34,7 @@ void main() async { }); final GoRouter appRouter = MihGoRouter().mihRouter; FlutterNativeSplash.remove(); - runApp(MzansiInnovationHub(router: appRouter,)); + runApp(MzansiInnovationHub( + router: appRouter, + )); } diff --git a/Frontend/macos/Runner.xcodeproj/project.pbxproj b/Frontend/macos/Runner.xcodeproj/project.pbxproj index fdf9f49d..23af1321 100644 --- a/Frontend/macos/Runner.xcodeproj/project.pbxproj +++ b/Frontend/macos/Runner.xcodeproj/project.pbxproj @@ -27,6 +27,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 */; }; + 87A3ECC0300895438D998868 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7ED8EFF855C30D0E25B6A6B4 /* GoogleService-Info.plist */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -64,7 +65,7 @@ 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; - 33CC10ED2044A3C60003C045 /* patient_manager.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "patient_manager.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10ED2044A3C60003C045 /* patient_manager.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = patient_manager.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; @@ -77,6 +78,7 @@ 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 7ED8EFF855C30D0E25B6A6B4 /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; /* End PBXFileReference section */ @@ -125,6 +127,7 @@ 331C80D6294CF71000263BE5 /* RunnerTests */, 33CC10EE2044A3C60003C045 /* Products */, D73912EC22F37F3D000D13A0 /* Frameworks */, + 7ED8EFF855C30D0E25B6A6B4 /* GoogleService-Info.plist */, ); sourceTree = ""; }; @@ -284,6 +287,7 @@ files = ( 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + 87A3ECC0300895438D998868 /* GoogleService-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Frontend/macos/Runner/GoogleService-Info.plist b/Frontend/macos/Runner/GoogleService-Info.plist new file mode 100644 index 00000000..380f61da --- /dev/null +++ b/Frontend/macos/Runner/GoogleService-Info.plist @@ -0,0 +1,30 @@ + + + + + API_KEY + AIzaSyDRqY5I5CXjEtWkUX1YUfKT8IUlln9PUuY + GCM_SENDER_ID + 33677883408 + PLIST_VERSION + 1 + BUNDLE_ID + com.example.patientManager + PROJECT_ID + mzansi-innovation-hub + STORAGE_BUCKET + mzansi-innovation-hub.firebasestorage.app + IS_ADS_ENABLED + + IS_ANALYTICS_ENABLED + + IS_APPINVITE_ENABLED + + IS_GCM_ENABLED + + IS_SIGNIN_ENABLED + + GOOGLE_APP_ID + 1:33677883408:ios:e2db11a42fc3452e223295 + + \ No newline at end of file diff --git a/Frontend/pubspec.lock b/Frontend/pubspec.lock index 631b8f23..1e564625 100644 --- a/Frontend/pubspec.lock +++ b/Frontend/pubspec.lock @@ -586,7 +586,7 @@ packages: source: hosted version: "6.1.0" firebase_core: - dependency: transitive + dependency: "direct main" description: name: firebase_core sha256: "1f2dfd9f535d81f8b06d7a50ecda6eac1e6922191ed42e09ca2c84bd2288927c" diff --git a/Frontend/pubspec.yaml b/Frontend/pubspec.yaml index 7be73bbd..5d559a4a 100644 --- a/Frontend/pubspec.yaml +++ b/Frontend/pubspec.yaml @@ -15,6 +15,7 @@ dependencies: cupertino_icons: ^1.0.8 font_awesome_flutter: ^10.7.0 + firebase_core: ^4.2.1 syncfusion_flutter_core: ^29.2.10 syncfusion_flutter_pdfviewer: ^29.2.10 universal_html: ^2.2.4