ios push notifications

This commit is contained in:
Trey t
2025-11-13 16:13:36 -06:00
parent b2f2627ad5
commit ff390a85c2
5 changed files with 37 additions and 30 deletions

View File

@@ -9,7 +9,7 @@ package com.mycrib.shared.network
*/ */
object ApiConfig { object ApiConfig {
// ⚠️ CHANGE THIS TO TOGGLE ENVIRONMENT ⚠️ // ⚠️ CHANGE THIS TO TOGGLE ENVIRONMENT ⚠️
val CURRENT_ENV = Environment.LOCAL val CURRENT_ENV = Environment.DEV
enum class Environment { enum class Environment {
LOCAL, LOCAL,

View File

@@ -383,6 +383,8 @@
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = iosApp/Info.plist; 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_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES;
@@ -650,6 +652,8 @@
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = iosApp/Info.plist; 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_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES;

View File

@@ -7,17 +7,17 @@
<key>CFBundleURLTypes</key> <key>CFBundleURLTypes</key>
<array> <array>
<dict> <dict>
<key>CFBundleURLName</key>
<string>com.mycrib.app</string>
<key>CFBundleURLSchemes</key> <key>CFBundleURLSchemes</key>
<array> <array>
<string>mycrib</string> <string>mycrib</string>
</array> </array>
<key>CFBundleURLName</key>
<string>com.mycrib.app</string>
</dict> </dict>
</array> </array>
<key>NSCameraUsageDescription</key> <key>UIBackgroundModes</key>
<string>MyCrib needs access to your camera to take photos of completed tasks</string> <array>
<key>NSPhotoLibraryUsageDescription</key> <string>remote-notification</string>
<string>MyCrib needs access to your photo library to select photos of completed tasks</string> </array>
</dict> </dict>
</plist> </plist>

View File

@@ -93,10 +93,10 @@ class PushNotificationManager: NSObject, ObservableObject {
if let notificationId = userInfo["notification_id"] as? String { if let notificationId = userInfo["notification_id"] as? String {
print("Notification ID: \(notificationId)") print("Notification ID: \(notificationId)")
// // Mark as read when user taps notification // Mark as read when user taps notification
// Task { Task {
// await markNotificationAsRead(notificationId: notificationId) await markNotificationAsRead(notificationId: notificationId)
// } }
} }
if let type = userInfo["type"] as? String { if let type = userInfo["type"] as? String {
@@ -130,24 +130,24 @@ class PushNotificationManager: NSObject, ObservableObject {
} }
} }
// private func markNotificationAsRead(notificationId: String) async { private func markNotificationAsRead(notificationId: String) async {
// guard TokenStorage.shared.getToken() != nil, guard TokenStorage.shared.getToken() != nil,
// let notificationIdInt = Int32(notificationId) else { let notificationIdInt = Int32(notificationId) else {
// return return
// } }
//
// do { do {
// let result = try await APILayer.shared.markNotificationAsRead(notificationId: notificationIdInt) let result = try await APILayer.shared.markNotificationAsRead(notificationId: notificationIdInt)
//
// if result is ApiResultSuccess<Notification> { if result is ApiResultSuccess<ComposeApp.Notification> {
// print(" Notification marked as read") print("✅ Notification marked as read")
// } else if let error = result as? ApiResultError { } else if let error = result as? ApiResultError {
// print(" Failed to mark notification as read: \(error.message)") print("❌ Failed to mark notification as read: \(error.message)")
// } }
// } catch { } catch {
// print(" Error marking notification as read: \(error.localizedDescription)") print("❌ Error marking notification as read: \(error.localizedDescription)")
// } }
// } }
// MARK: - Notification Preferences // MARK: - Notification Preferences
@@ -206,3 +206,4 @@ class PushNotificationManager: NSObject, ObservableObject {
UIApplication.shared.applicationIconBadgeNumber = count UIApplication.shared.applicationIconBadgeNumber = count
} }
} }

View File

@@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.security.application-groups</key> <key>com.apple.security.application-groups</key>
<array> <array>
<string>group.com.tt.mycrib.MyCrib</string> <string>group.com.tt.mycrib.MyCrib</string>