main
Laurent 3 years ago
parent 3352cc6e4e
commit 5322f59f43
  1. 37
      LeCountdown/LeCountdownApp.swift
  2. 2
      LeCountdown/Views/ContentView.swift

@ -10,6 +10,7 @@ import CoreData
import BackgroundTasks
import AVFoundation
import Combine
import CloudKit
@main
struct LeCountdownApp: App {
@ -79,6 +80,8 @@ struct LeCountdownApp: App {
Logger.log("preferredLanguages = \(String(describing: Locale.preferredLanguages))")
self._patch()
let containerAvailable = self.isICloudContainerAvailable()
Logger.log("isICloudContainerAvailable = \(containerAvailable)")
// let voices = AVSpeechSynthesisVoice.speechVoices()
// let grouped = Dictionary(grouping: voices, by: { $0.language })
@ -115,7 +118,6 @@ struct LeCountdownApp: App {
}
fileprivate func _patch() {
let context = PersistenceController.shared.container.viewContext
@ -131,4 +133,37 @@ struct LeCountdownApp: App {
}
func isICloudContainerAvailable() -> Bool {
print(#function)
CKContainer.default().accountStatus { (accountStatus, error) in
if accountStatus == .available {
return
}
///
// Checking account availability
// Silently return if everything goes well, or do a second check 200ms after the first failure
//
DispatchQueue.global().asyncAfter(deadline: .now() + 0.2) {
guard error != nil, accountStatus != CKAccountStatus.available else {return}
print("iCloud account is not available! Be sure you have signed in iCloud on this device!")
}
}
if FileManager.default.ubiquityIdentityToken != nil {
//print("User logged in")
return true
}
else {
//print("User is not logged in")
return false
}
}
}

@ -170,8 +170,6 @@ struct MainToolbarView: ToolbarContent {
@Binding var isEditing: Bool
// @State var type: TimerType? = nil
@State var showSettingsSheet: Bool = false
@State var showStatsSheet: Bool = false
@State var showAddSheet: Bool = false

Loading…
Cancel
Save