diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 0a41e8f..903ef39 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -50,6 +50,7 @@ 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 = ""; }; 67EC5B6326AB6B6B093D53CE /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; + 69B9D71F2EB7E2C900F2639E /* 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 = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -105,7 +106,6 @@ 67EC5B6326AB6B6B093D53CE /* Pods-RunnerTests.release.xcconfig */, F230D285980CEE0F11E7B0BC /* Pods-RunnerTests.profile.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -144,6 +144,7 @@ 97C146F01CF9000F007C117D /* Runner */ = { isa = PBXGroup; children = ( + 69B9D71F2EB7E2C900F2639E /* Runner.entitlements */, 97C146FA1CF9000F007C117D /* Main.storyboard */, 97C146FD1CF9000F007C117D /* Assets.xcassets */, 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, @@ -339,10 +340,14 @@ inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); + inputPaths = ( + ); name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); + outputPaths = ( + ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; @@ -371,10 +376,14 @@ inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", ); + inputPaths = ( + ); name = "[CP] Copy Pods Resources"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", ); + outputPaths = ( + ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; @@ -488,6 +497,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -495,7 +505,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.travelMate; + PRODUCT_BUNDLE_IDENTIFIER = be.devdayronvl.TravelMate; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -670,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)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -677,7 +688,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.travelMate; + PRODUCT_BUNDLE_IDENTIFIER = be.devdayronvl.TravelMate; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -692,6 +703,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -699,7 +711,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.travelMate; + PRODUCT_BUNDLE_IDENTIFIER = be.devdayronvl.TravelMate; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; diff --git a/ios/Runner/GoogleService-Info.plist b/ios/Runner/GoogleService-Info.plist index a1f738f..b69402f 100644 --- a/ios/Runner/GoogleService-Info.plist +++ b/ios/Runner/GoogleService-Info.plist @@ -3,11 +3,11 @@ CLIENT_ID - 521527250907-3i1qe2656eojs8k9hjdi573j09i9p41m.apps.googleusercontent.com + 521527250907-196i04qgm4talrosgi0ne0q8en90hkkh.apps.googleusercontent.com REVERSED_CLIENT_ID - com.googleusercontent.apps.521527250907-3i1qe2656eojs8k9hjdi573j09i9p41m + com.googleusercontent.apps.521527250907-196i04qgm4talrosgi0ne0q8en90hkkh ANDROID_CLIENT_ID - 521527250907-lqgj1lmfcsjusm2be9r6kpuanq3jvjcd.apps.googleusercontent.com + 521527250907-19lrclc10eb0p8li1qutepctfqdohn0b.apps.googleusercontent.com API_KEY AIzaSyBFaSzvcvO8qg7El-2jRf7WctZIMKNA4-I GCM_SENDER_ID @@ -15,7 +15,7 @@ PLIST_VERSION 1 BUNDLE_ID - com.example.travelMate + be.devdayronvl.TravelMate PROJECT_ID travelmate-a47f5 STORAGE_BUCKET @@ -31,6 +31,6 @@ IS_SIGNIN_ENABLED GOOGLE_APP_ID - 1:521527250907:ios:64b41be39c54db1c7da1fe + 1:521527250907:ios:52058410e09e5d3a7da1fe \ No newline at end of file diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 3cc8320..1b1e3c5 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -2,6 +2,8 @@ + CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName @@ -20,10 +22,29 @@ $(FLUTTER_BUILD_NAME) CFBundleSignature ???? + CFBundleURLTypes + + + CFBundleURLName + REVERSED_CLIENT_ID + CFBundleURLSchemes + + com.googleusercontent.apps.521527250907-3i1qe2656eojs8k9hjdi573j09i9p41m + + + CFBundleVersion $(FLUTTER_BUILD_NUMBER) + GIDClientID + 521527250907-3i1qe2656eojs8k9hjdi573j09i9p41m.apps.googleusercontent.com LSRequiresIPhoneOS + NSLocationAlwaysUsageDescription + Cette application a besoin de votre position pour afficher votre localisation sur la carte + NSLocationWhenInUseUsageDescription + Cette application a besoin de votre position pour afficher votre localisation sur la carte + UIApplicationSupportsIndirectInputEvents + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -41,27 +62,5 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - CADisableMinimumFrameDurationOnPhone - - UIApplicationSupportsIndirectInputEvents - - NSLocationWhenInUseUsageDescription - Cette application a besoin de votre position pour afficher votre localisation sur la carte - NSLocationAlwaysUsageDescription - Cette application a besoin de votre position pour afficher votre localisation sur la carte - GIDClientID - 521527250907-3i1qe2656eojs8k9hjdi573j09i9p41m.apps.googleusercontent.com - CFBundleURLTypes - - - CFBundleURLName - REVERSED_CLIENT_ID - CFBundleURLSchemes - - com.googleusercontent.apps.521527250907-3i1qe2656eojs8k9hjdi573j09i9p41m - - - - diff --git a/ios/Runner/Runner.entitlements b/ios/Runner/Runner.entitlements new file mode 100644 index 0000000..a812db5 --- /dev/null +++ b/ios/Runner/Runner.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.developer.applesignin + + Default + + + diff --git a/lib/services/auth_service.dart b/lib/services/auth_service.dart index 496cf91..2110fe6 100644 --- a/lib/services/auth_service.dart +++ b/lib/services/auth_service.dart @@ -3,60 +3,64 @@ import 'package:google_sign_in_platform_interface/google_sign_in_platform_interf import 'package:travel_mate/services/error_service.dart'; /// Service for handling Firebase authentication operations. -/// +/// /// This service provides methods for user authentication including email/password /// sign-in, Google sign-in, Apple sign-in, password reset, and account management. /// It acts as a wrapper around Firebase Auth functionality. class AuthService { /// Error service for logging authentication errors. final _errorService = ErrorService(); - + /// Firebase Auth instance for authentication operations. final FirebaseAuth firebaseAuth = FirebaseAuth.instance; /// Gets the currently authenticated user. - /// + /// /// Returns null if no user is currently signed in. User? get currentUser => firebaseAuth.currentUser; /// Stream that emits authentication state changes. - /// + /// /// Emits the current user when authenticated, null when not authenticated. Stream get authStateChanges => firebaseAuth.authStateChanges(); /// Signs in a user with email and password. - /// + /// /// Returns a [UserCredential] containing the authenticated user's information. /// Throws [FirebaseAuthException] if authentication fails. Future signInWithEmailAndPassword({ required String email, - required String password + required String password, }) async { return await firebaseAuth.signInWithEmailAndPassword( - email: email, password: password); + email: email, + password: password, + ); } /// Creates a new user account with email and password. - /// + /// /// Returns a [UserCredential] containing the new user's information. /// Throws [FirebaseAuthException] if account creation fails. Future signUpWithEmailAndPassword({ - required String email, - required String password - }) async { + required String email, + required String password, + }) async { return await firebaseAuth.createUserWithEmailAndPassword( - email: email, password: password); + email: email, + password: password, + ); } /// Signs out the current user. - /// + /// /// Clears the authentication state and signs out the user from Firebase. Future signOut() async { await firebaseAuth.signOut(); } /// Sends a password reset email to the specified email address. - /// + /// /// The user will receive an email with instructions to reset their password. /// Throws [FirebaseAuthException] if the email is invalid or other errors occur. Future resetPassword(String email) async { @@ -64,20 +68,18 @@ class AuthService { } /// Updates the display name of the current user. - /// + /// /// Requires a user to be currently authenticated. /// Throws if no user is signed in. - Future updateDisplayName({ - required String displayName, - }) async { + Future updateDisplayName({required String displayName}) async { await currentUser!.updateDisplayName(displayName); } /// Deletes the current user's account permanently. - /// + /// /// Requires re-authentication with the user's current password for security. /// This operation cannot be undone. - /// + /// /// [password] - The user's current password for re-authentication /// [email] - The user's email address for re-authentication Future deleteAccount({ @@ -85,8 +87,10 @@ class AuthService { required String email, }) async { // Re-authenticate the user for security - AuthCredential credential = - EmailAuthProvider.credential(email: email, password: password); + AuthCredential credential = EmailAuthProvider.credential( + email: email, + password: password, + ); await currentUser!.reauthenticateWithCredential(credential); // Delete the user account permanently @@ -95,10 +99,10 @@ class AuthService { } /// Resets the user's password after re-authentication. - /// + /// /// This method allows users to change their password by providing their /// current password for security verification. - /// + /// /// [currentPassword] - The user's current password for verification /// [newPassword] - The new password to set /// [email] - The user's email address for re-authentication @@ -108,8 +112,10 @@ class AuthService { required String email, }) async { // Re-authenticate the user for security - AuthCredential credential = - EmailAuthProvider.credential(email: email, password: currentPassword); + AuthCredential credential = EmailAuthProvider.credential( + email: email, + password: currentPassword, + ); await currentUser!.reauthenticateWithCredential(credential); // Update to the new password @@ -117,23 +123,24 @@ class AuthService { } /// Ensures Google Sign-In is properly initialized. - /// + /// /// This method must be called before attempting Google authentication. - Future ensureInitialized(){ + Future ensureInitialized() { return GoogleSignInPlatform.instance.init(const InitParameters()); } /// Signs in a user using Google authentication. - /// + /// /// Handles the complete Google Sign-In flow including platform initialization /// and credential exchange with Firebase. - /// + /// /// Returns a [UserCredential] containing the authenticated user's information. /// Throws various exceptions if authentication fails. Future signInWithGoogle() async { try { await ensureInitialized(); - final AuthenticationResults result = await GoogleSignInPlatform.instance.authenticate(const AuthenticateParameters()); + final AuthenticationResults result = await GoogleSignInPlatform.instance + .authenticate(const AuthenticateParameters()); final String? idToken = result.authenticationTokens.idToken; if (idToken == null) { throw FirebaseAuthException( @@ -141,31 +148,38 @@ class AuthService { message: 'Missing Google ID Token', ); } else { - final OAuthCredential credential = GoogleAuthProvider.credential(idToken: idToken); - UserCredential userCredential = await firebaseAuth.signInWithCredential(credential); - + final OAuthCredential credential = GoogleAuthProvider.credential( + idToken: idToken, + ); + UserCredential userCredential = await firebaseAuth.signInWithCredential( + credential, + ); + // Return the UserCredential instead of void return userCredential; } - } on GoogleSignInException catch (e) { _errorService.logError('Google Sign-In error: $e', StackTrace.current); rethrow; } on FirebaseAuthException catch (e) { - _errorService.logError('Firebase error during Google Sign-In initialization: $e', StackTrace.current); + _errorService.logError( + 'Firebase error during Google Sign-In initialization: $e', + StackTrace.current, + ); rethrow; } catch (e) { - _errorService.logError('Unknown error during Google Sign-In initialization: $e', StackTrace.current); + _errorService.logError( + 'Unknown error during Google Sign-In initialization: $e', + StackTrace.current, + ); rethrow; } } /// Signs in a user using Apple authentication. - /// - /// TODO: Implement Apple Sign-In functionality + /// /// This method is currently a placeholder for future Apple authentication support. Future signInWithApple() async { // TODO: Implement Apple sign-in } - -} \ No newline at end of file +}