Update signing configuration to use 88oakapps.feels identifiers
- Update App Group IDs from group.com.tt.feels to group.com.88oakapps.feels - Update iCloud container IDs from iCloud.com.tt.feels to iCloud.com.88oakapps.feels - Sync code constants with entitlements across all targets (iOS, Watch, Widget) - Update documentation in CLAUDE.md and PROJECT_OVERVIEW.md Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -261,6 +261,60 @@ class HealthKitManager: ObservableObject {
|
||||
])
|
||||
}
|
||||
|
||||
// MARK: - Delete All Moods from HealthKit
|
||||
|
||||
/// Deletes all State of Mind samples created by this app
|
||||
/// Note: HealthKit only allows deleting samples that your app created
|
||||
func deleteAllMoods() async throws -> Int {
|
||||
guard isHealthKitAvailable else {
|
||||
throw HealthKitError.notAvailable
|
||||
}
|
||||
|
||||
guard let stateOfMindType = stateOfMindType else {
|
||||
throw HealthKitError.typeNotAvailable
|
||||
}
|
||||
|
||||
guard checkAuthorizationStatus() == .sharingAuthorized else {
|
||||
throw HealthKitError.notAuthorized
|
||||
}
|
||||
|
||||
logger.info("Starting deletion of all State of Mind samples from this app")
|
||||
|
||||
// Fetch all State of Mind samples (HealthKit will only return ones we can delete - our own)
|
||||
let samples = try await fetchMoods(
|
||||
from: Date(timeIntervalSince1970: 0),
|
||||
to: Date().addingTimeInterval(86400) // Include today + 1 day buffer
|
||||
)
|
||||
|
||||
guard !samples.isEmpty else {
|
||||
logger.info("No State of Mind samples found to delete")
|
||||
return 0
|
||||
}
|
||||
|
||||
logger.info("Found \(samples.count) State of Mind samples to delete")
|
||||
|
||||
// Delete in batches
|
||||
let batchSize = 50
|
||||
var deletedCount = 0
|
||||
|
||||
for batchStart in stride(from: 0, to: samples.count, by: batchSize) {
|
||||
let batchEnd = min(batchStart + batchSize, samples.count)
|
||||
let batch = Array(samples[batchStart..<batchEnd])
|
||||
|
||||
do {
|
||||
try await healthStore.delete(batch)
|
||||
deletedCount += batch.count
|
||||
logger.info("Deleted batch \(batchStart/batchSize + 1): \(batch.count) samples")
|
||||
} catch {
|
||||
logger.error("Failed to delete batch starting at \(batchStart): \(error.localizedDescription)")
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("Successfully deleted \(deletedCount) State of Mind samples from HealthKit")
|
||||
return deletedCount
|
||||
}
|
||||
|
||||
// MARK: - Read Mood from HealthKit
|
||||
|
||||
func fetchMoods(from startDate: Date, to endDate: Date) async throws -> [HKStateOfMind] {
|
||||
|
||||
Reference in New Issue
Block a user