diff --git a/composeApp/src/commonMain/kotlin/com/example/mycrib/network/ApiConfig.kt b/composeApp/src/commonMain/kotlin/com/example/mycrib/network/ApiConfig.kt index cfc83c4..93c2f1f 100644 --- a/composeApp/src/commonMain/kotlin/com/example/mycrib/network/ApiConfig.kt +++ b/composeApp/src/commonMain/kotlin/com/example/mycrib/network/ApiConfig.kt @@ -9,7 +9,7 @@ package com.mycrib.shared.network */ object ApiConfig { // ⚠️ CHANGE THIS TO TOGGLE ENVIRONMENT ⚠️ - val CURRENT_ENV = Environment.LOCAL + val CURRENT_ENV = Environment.DEV enum class Environment { LOCAL, diff --git a/iosApp/iosApp.xcodeproj/project.pbxproj b/iosApp/iosApp.xcodeproj/project.pbxproj index 0ca81a5..d4a69b9 100644 --- a/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/iosApp/iosApp.xcodeproj/project.pbxproj @@ -383,6 +383,8 @@ ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = iosApp/Info.plist; + INFOPLIST_KEY_NSCameraUsageDescription = "MyCrib needs access to your camera to take photos of completed tasks"; + INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "MyCrib needs access to your photo library to select photos of completed tasks"; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; @@ -650,6 +652,8 @@ ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = iosApp/Info.plist; + INFOPLIST_KEY_NSCameraUsageDescription = "MyCrib needs access to your camera to take photos of completed tasks"; + INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "MyCrib needs access to your photo library to select photos of completed tasks"; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; diff --git a/iosApp/iosApp/Info.plist b/iosApp/iosApp/Info.plist index 34c7155..7ae9ca1 100644 --- a/iosApp/iosApp/Info.plist +++ b/iosApp/iosApp/Info.plist @@ -7,17 +7,17 @@ CFBundleURLTypes + CFBundleURLName + com.mycrib.app CFBundleURLSchemes mycrib - CFBundleURLName - com.mycrib.app - NSCameraUsageDescription - MyCrib needs access to your camera to take photos of completed tasks - NSPhotoLibraryUsageDescription - MyCrib needs access to your photo library to select photos of completed tasks + UIBackgroundModes + + remote-notification + diff --git a/iosApp/iosApp/PushNotifications/PushNotificationManager.swift b/iosApp/iosApp/PushNotifications/PushNotificationManager.swift index c26c31e..96a2635 100644 --- a/iosApp/iosApp/PushNotifications/PushNotificationManager.swift +++ b/iosApp/iosApp/PushNotifications/PushNotificationManager.swift @@ -63,7 +63,7 @@ class PushNotificationManager: NSObject, ObservableObject { print("⚠️ No auth token available, will register device after login") return } - + let request = DeviceRegistrationRequest( registrationId: token, platform: "ios" @@ -93,10 +93,10 @@ class PushNotificationManager: NSObject, ObservableObject { if let notificationId = userInfo["notification_id"] as? String { print("Notification ID: \(notificationId)") -// // Mark as read when user taps notification -// Task { -// await markNotificationAsRead(notificationId: notificationId) -// } + // Mark as read when user taps notification + Task { + await markNotificationAsRead(notificationId: notificationId) + } } if let type = userInfo["type"] as? String { @@ -130,24 +130,24 @@ class PushNotificationManager: NSObject, ObservableObject { } } -// private func markNotificationAsRead(notificationId: String) async { -// guard TokenStorage.shared.getToken() != nil, -// let notificationIdInt = Int32(notificationId) else { -// return -// } -// -// do { -// let result = try await APILayer.shared.markNotificationAsRead(notificationId: notificationIdInt) -// -// if result is ApiResultSuccess { -// print("✅ Notification marked as read") -// } else if let error = result as? ApiResultError { -// print("❌ Failed to mark notification as read: \(error.message)") -// } -// } catch { -// print("❌ Error marking notification as read: \(error.localizedDescription)") -// } -// } + private func markNotificationAsRead(notificationId: String) async { + guard TokenStorage.shared.getToken() != nil, + let notificationIdInt = Int32(notificationId) else { + return + } + + do { + let result = try await APILayer.shared.markNotificationAsRead(notificationId: notificationIdInt) + + if result is ApiResultSuccess { + print("✅ Notification marked as read") + } else if let error = result as? ApiResultError { + print("❌ Failed to mark notification as read: \(error.message)") + } + } catch { + print("❌ Error marking notification as read: \(error.localizedDescription)") + } + } // MARK: - Notification Preferences @@ -206,3 +206,4 @@ class PushNotificationManager: NSObject, ObservableObject { UIApplication.shared.applicationIconBadgeNumber = count } } + diff --git a/iosApp/iosApp/iosApp.entitlements b/iosApp/iosApp/iosApp.entitlements index 52e1157..9abf63f 100644 --- a/iosApp/iosApp/iosApp.entitlements +++ b/iosApp/iosApp/iosApp.entitlements @@ -2,6 +2,8 @@ + aps-environment + development com.apple.security.application-groups group.com.tt.mycrib.MyCrib